Community
Participate
Working Groups
Looking at the implementation it seems to be at least O(NĀ²): JavaRuntime.resolveRuntimeClasspath(IRuntimeClasspathEntry[], ILaunchConfiguration) - loops over all entries given as parameter (in our case > 1500) - calls JavaProject#findPackageFragmentRoot(IRuntimeClasspathEntry#getPath()) - JavaProject#findPackageFragmentRoot itself calls findPackageFragmentRoot0 - findPackageFragmentRoot0 calls getAllPackageFragmentRoots and then loops over all the roots to find a match - getAllPackageFragmentRoots loops over the resolved classpath calling computePackageFragmentRoots for each entry The worst case could potentially be much higher.
Note, this method is called multiple times during launching a JUnit launch configuration, making it slow to launch.
I can only reproduce this on Windows. I can reproduce this with TestNG as well. TestNG also resolves the classpath five times. A profiler shows that most time is spend in File.getCanonicalPath() called by JavaProject.canonicalizePath(). JavaProject.canonicalizePath() is doing a lot more work if the file system is case-insensitive. NTSF is case-insensitive. - When I import the projects with the buildship plugin the hot spot is in JavaRuntime.resolveRuntimeClasspath(). More precisely GradleClasspathContainerRuntimeClasspathEntryResolver.runtimeClasspathWithTestSources(). - When I use Gradle's 'eclipse' plugin and import the projects using "Existing Projects into Workspace", then the hot spot is in DefaultProjectClasspathEntry.expandProject() called by JavaRuntime.computeUnresolvedRuntimeDependencies().
New Gerrit change created: https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/180456
The exampleWorkspace.zip (https://bugs.eclipse.org/bugs/attachment.cgi?id=286382) attached to Bug 573479 can be used to reproduce the issue. Please note that a performance improvement is not really visible until Bug 573479 is fixed. On my machine Bug 573479 improves the launch time from 45s to 5s and the fix of this ticket further improves the launch time from 5s to 2s. I ran the tests on Windows. I get much better launch times on Linux.
Gerrit change https://git.eclipse.org/r/c/jdt/eclipse.jdt.debug/+/180456 was merged to [master]. Commit: http://git.eclipse.org/c/jdt/eclipse.jdt.debug.git/commit/?id=18e024b1e8baf52cad9dbb1f97ea9ed39022b8c6
Thanks Andreas. Would be great, if you could verify the fix of this bug and bug 573479 by using latest 4.21 nightly build from https://download.eclipse.org/eclipse/downloads/drops4/I20210725-1800.
Thanks Andrey. Verified. The performance improved as expected. I tested TestNG and Junit tests. I did not come across any class path related issues.