-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
performance: avoid O(n^2) in PDEJavaHelper #747
Conversation
Test Results 261 files - 12 261 suites - 12 43m 41s ⏱️ - 21m 30s For more details on these failures, see this check. Results for commit 42c0a49. ± Comparison against base commit f5c8301. ♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the caching better done in the IJavaProject
implementation?
Then all callers benefit from it immediatly and the cache has to be build only once. And the impl probably also knows best when to invalidate the cache.
ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/util/PDEJavaHelper.java
Outdated
Show resolved
Hide resolved
i don't know who this could be implemented as the result currently depends on files/directory on filesystem, which could have changed.
together with eclipse-jdt/eclipse.jdt.ui#796 i just adapted all known repeated callers. |
@vogella please undo "merge" and use rebase instead |
If it is querying the file-system over and over again it would be an even better reason to cache it for all since we both know that this is slow. Is it querying the files directly through standard java API or through Eclipse |
no - see stacktrace in eclipse-jdt/eclipse.jdt.core#303 - java.io |
1bd180a
to
ce63951
Compare
Too bad. |
if (classRootPath != null) { | ||
rootsByPath.put(classRootPath, classpathRoot); | ||
} | ||
} | ||
ListIterator<IPath> li = libPaths.listIterator(); | ||
while (li.hasNext()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you already touched this, could you please convert this while loop and if you want the outer for loop over all projects into an enhanced for loop?
Btw. I wonder why there is no quick-fix that suggest to convert this iterator+while into an enhanced for-loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a cleanup, that could do this. but it currently fails. let's wait till that is fixed: eclipse-jdt/eclipse.jdt.ui#798
In general wonder if the number of libraries is that often greater than one. For In that case it is probably faster to keep the current behavior since caching will then probably be more expensive because it collects all roots in any case, even if the first one would already match. Plus the memory overhead. A all pleasing solution would probably be something like:
Although it is now much longer than before. |
Thats not an even a performance improvement. findPackageFragmentRoot internally calls getAllPackageFragmentRoots anyway. |
ce63951
to
5256249
Compare
findPackageFragmentRoot() searches through all PackageFragment Roots and is called for every libPaths. This can be slow due to involved file access. see eclipse-jdt/eclipse.jdt.core#303 Instead call getAllPackageFragmentRoots() only once, index the result and use O(1) hash access.
5256249
to
42c0a49
Compare
OK, then just disregard my remark and AFAICT this looks fine to me. Maybe it would be worth to consider in JDT to make |
PRs welcome. i can review. |
findPackageFragmentRoot() searches through all PackageFragment Roots and is called for every libPaths. This can be slow due to involved file access.
see eclipse-jdt/eclipse.jdt.core#303
Instead call getAllPackageFragmentRoots() only once, index the result and use O(1) hash access.