You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "mbien (via GitHub)" <gi...@apache.org> on 2025/04/14 23:25:24 UTC
[PR] Implement fast path for JS embedder annotation scanner [netbeans]
mbien opened a new pull request, #8423:
URL: https://github.com/apache/netbeans/pull/8423
Reduced scan time from 102s to 13ms for a synthetic test file containing 10k inner classes with Override annotations (no javascript).
closes #8419
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement fast path for JS embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#discussion_r2043951961
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -158,8 +162,7 @@ public Void visitMethod(
final MethodTree m,
final List<? super LiteralTree> p) {
for (AnnotationTree a : m.getModifiers().getAnnotations()) {
- final TypeElement ae = (TypeElement) trees.getElement(TreePath.getPath(cu, a.getAnnotationType()));
- if (ae != null && JS_ANNOTATION.contentEquals(ae.getQualifiedName())) {
+ if (isJsAnnotation(a)) {
Review Comment:
Your suggestion works and is as fast - will update it soon after testing it a bit longer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix performance scaling problem in JS-embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#discussion_r2043973555
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -187,6 +190,19 @@ public Void visitLiteral(LiteralTree node, List<? super LiteralTree> p) {
return super.visitLiteral(node, p);
}
+ private boolean isJsAnnotation(AnnotationTree a) {
+ Tree type = a.getAnnotationType();
+ if (type.getKind() != Tree.Kind.IDENTIFIER) {
Review Comment:
good catch - haven't noticed this during testing. (This method is now no longer needed)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement fast path for JS embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#discussion_r2043951961
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -158,8 +162,7 @@ public Void visitMethod(
final MethodTree m,
final List<? super LiteralTree> p) {
for (AnnotationTree a : m.getModifiers().getAnnotations()) {
- final TypeElement ae = (TypeElement) trees.getElement(TreePath.getPath(cu, a.getAnnotationType()));
- if (ae != null && JS_ANNOTATION.contentEquals(ae.getQualifiedName())) {
+ if (isJsAnnotation(a)) {
Review Comment:
Your suggestion works, is simpler and is as fast - will update it soon after testing it a bit longer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement fast path for JS embedder annotation scanner [netbeans]
Posted by "lahodaj (via GitHub)" <gi...@apache.org>.
lahodaj commented on code in PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#discussion_r2043888403
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -187,6 +190,19 @@ public Void visitLiteral(LiteralTree node, List<? super LiteralTree> p) {
return super.visitLiteral(node, p);
}
+ private boolean isJsAnnotation(AnnotationTree a) {
+ Tree type = a.getAnnotationType();
+ if (type.getKind() != Tree.Kind.IDENTIFIER) {
Review Comment:
Sorry, but this is not correct. If the name is a (the) FQN, the tree kind will be `MEMBER_SELECT`.
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -158,8 +162,7 @@ public Void visitMethod(
final MethodTree m,
final List<? super LiteralTree> p) {
for (AnnotationTree a : m.getModifiers().getAnnotations()) {
- final TypeElement ae = (TypeElement) trees.getElement(TreePath.getPath(cu, a.getAnnotationType()));
- if (ae != null && JS_ANNOTATION.contentEquals(ae.getQualifiedName())) {
+ if (isJsAnnotation(a)) {
Review Comment:
Unless I am terribly mistaken, the issue here is the call to `TreePath.getPath` - that is slow, causes `n^2` complexity, and should be avoided if at all possible.
But the solution here might be (or hopefully is) to construct the `TreePath` cheaper. I am fairly sure, although I didn't try, that something like:
```
new TreePath(new TreePath(new TreePath(getCurrentPath(), m.getModifiers()), a), a.getAnnotationType())
```
should work without playing tricks with checking trees.
This is attempting to reconstruct the `TreePath` properly, as it should be. But, knowing how the implementation looks inside, this should work as well:
```
new TreePath(getCurrentPath(), a.getAnnotationType())
```
(as the `Element` is a property of the leaf tree, and the path is not really checked normally, surely not in much detail.) I tend to prefer to formal way.
There's also `Trees.getPath(CompilationUnitTree, Tree)`, where there's theoretically a possibility to do caching (which is virtually impossible for `TreePath.getPath`). But that wasn't pursued so far.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement fast path for JS embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#discussion_r2043928745
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -158,8 +162,7 @@ public Void visitMethod(
final MethodTree m,
final List<? super LiteralTree> p) {
for (AnnotationTree a : m.getModifiers().getAnnotations()) {
- final TypeElement ae = (TypeElement) trees.getElement(TreePath.getPath(cu, a.getAnnotationType()));
- if (ae != null && JS_ANNOTATION.contentEquals(ae.getQualifiedName())) {
+ if (isJsAnnotation(a)) {
Review Comment:
interesting, will give it a try and report back if it reaches similar performance. 13ms for the artificial 10k inner-class file was already faster than expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix performance scaling problem in JS-embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien merged PR #8423:
URL: https://github.com/apache/netbeans/pull/8423
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Fix performance scaling problem in JS-embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#issuecomment-2804895649
awesome. Thanks again for the review! merging for NB 26.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
Re: [PR] Implement fast path for JS embedder annotation scanner [netbeans]
Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien commented on code in PR #8423:
URL: https://github.com/apache/netbeans/pull/8423#discussion_r2043973555
##########
java/editor.htmlui/src/org/netbeans/modules/editor/htmlui/JSEmbeddingProvider.java:
##########
@@ -187,6 +190,19 @@ public Void visitLiteral(LiteralTree node, List<? super LiteralTree> p) {
return super.visitLiteral(node, p);
}
+ private boolean isJsAnnotation(AnnotationTree a) {
+ Tree type = a.getAnnotationType();
+ if (type.getKind() != Tree.Kind.IDENTIFIER) {
Review Comment:
good catch - haven't noticed this during testing. This method is no longer needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists