Refactoring: Improve listClassPathHints() performance#8948
Refactoring: Improve listClassPathHints() performance#8948mbien merged 1 commit intoapache:masterfrom
Conversation
The binary class path Set has the tendency to have duplicated roots. The added deduplication pass ensures that findSourceRoots2 isn't called more often than necessary. This can significantly improve the performance during code inspect and transform actions, esp when many projects are open.
eirikbakke
left a comment
There was a problem hiding this comment.
Seems like a simple change, gathering up FileObject instances in a Set to deduplicate before iterating over them. Plus some cosmetic code cleanup (renamed variables etc.). Thanks for this!
| Set<FileObject> roots = new HashSet<>(); | ||
|
|
||
| // deduplicate before running queries | ||
| Set<FileObject> unique = new HashSet<>(128); |
There was a problem hiding this comment.
Does iteration order matter for these sets? I always tend to use LinkedHashSet, to avoid items being randomized.
There was a problem hiding this comment.
it shouldn't matter in this particular case, the method input already was a regular HashSet. Since its an internal utility class we could change this based on usage I think.
lahodaj
left a comment
There was a problem hiding this comment.
Looks good to me, thanks! I don't think the order is particularly important, the input ClassPaths are in a set anyways.
|
thanks for the reviews! merging some smaller PRs like this one here. |
The binary class path Set has the tendency to have duplicated roots. The added deduplication pass ensures that
findSourceRoots2isn't called more often than necessary.This can significantly improve the performance during code inspect and transform actions, esp when many projects are open.
relative time spent in
listClassPathHints()during inspect/transform dialog open.before:

after:

benchmark was a project wide code inspection run with all 856 NetBeans modules open.
listClassPathHints()execution time in msbefore:
after:
the number of entries was reduced from 154997 to 1258 in that use case.