Community
Participate
Working Groups
build 3.2RC7 I have a workspace with more than 1800 plugin projects as binary inside. This workspace contains the plugin org.eclipse.jdt.core as source. The renaming of org.eclipse.jdt.internal.compiler.batch.Main#addNewEntry(...) with the refactoring action (Refactor>Rename )is very slow (more than 4 minutes). I profiled this test case and i noticed that 99% of the time is spend inside WorkspaceeRoot#getProject(String). The problem occured only the first time i tried to refactor the method. when i tried to rename the method a second time, the refactoring wasn't slow. I will attach the result the profiling.
Created attachment 44275 [details] profiling result
I was worried about this code because I put in a late fix for bug 138737. I didn't want to add synchronization because I am optimizing for subsequent calls to getProject(). Four minutes to initialize this cache is surprising. I will investigate.
I did a quick test and I can reproduce the bottle neck. This snippet took 103 seconds to run on my machine: IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); for (int i = 0; i < 2000; i++) root.getProject(Integer.toString(i));
After doing some benchmarks I have opted to use a synchronized HashMap. The performance is only slightly slower than an unsynchronized map. The snippet in comment #3 now runs in about 30ms. I have released this fix to HEAD and will contribute to the 3.2.1 stream when available. Thanks David, good catch!
I tested with HEAD and my test case take around 10 sec now. Good!
Fix released to 3_2_maintenance stream for next 3.2.1 build.