Bug 67139 - [classpath] n^2 classpath computations
Summary: [classpath] n^2 classpath computations
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2004-06-14 17:29 EDT by John Arthorne CLA
Modified: 2005-05-13 06:57 EDT (History)
4 users (show)

See Also:


Attachments
Profiler output of classpath computation (329.18 KB, text/html)
2004-06-14 17:29 EDT, John Arthorne CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2004-06-14 17:29:19 EDT
Build: 3.0 RC2

Test case: Start large workspace in Java perspective, two Java editors open on
files in the workspace. Workspace contains 134 Java projects (Jeff's big
self-hosting test workspace from 2.1.3).

The profiler shows 2% of startup time is in
JavaProject.computeExpandedClasspath. The method is called 118,680 times during
startup. This is greater than n^2 where n is the number of projects in the
workspace.

I am not very familiar with the code, but it looks like
DeltaProcessor.resetProjectCaches is called for each project classpath that gets
initialized. This discards the current cached classpath, and eagerly recomputes
it. Thus it looks like every project has its classpath computed for each
project's classpath initialization. If resetProjectCaches did NOT eagerly
recompute the classpath, perhaps it wouldn't need to be recomputed so many times
for each project?

OptimizeIt profiler output attached.
Comment 1 John Arthorne CLA 2004-06-14 17:29:49 EDT
Created attachment 12090 [details]
Profiler output of classpath computation
Comment 2 Jerome Lanneluc CLA 2004-10-13 11:46:01 EDT
Relevant call trace:

JavaProject.computeExpandedClasspath(ClasspathEntry, boolean, boolean, HashSet,
ObjectVector, Map, Map) line: 422
JavaProject.computeExpandedClasspath(ClasspathEntry, boolean, boolean, HashSet,
ObjectVector, Map, Map) line: 455
JavaProject.getExpandedClasspath(boolean, boolean, Map, Map) line: 1454
JavaProject.getExpandedClasspath(boolean) line: 1433
DeltaProcessor.addDependentProjects(IPath, HashSet) line: 277
DeltaProcessor.resetProjectCaches() line: 1703
DeltaProcessor.processResourceDelta(IResourceDelta) line: 1642
DeltaProcessor.resourceChanged(IResourceChangeEvent) line: 1783
DeltaProcessingState.resourceChanged(IResourceChangeEvent) line: 414
NotificationManager$2.run() line: 283
InternalPlatform.run(ISafeRunnable) line: 616
Platform.run(ISafeRunnable) line: 747
NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[],
IResourceChangeEvent, boolean) line: 277
NotificationManager.broadcastChanges(ElementTree, int, boolean) line: 151
Workspace.broadcastChanges(int, boolean) line: 172
Workspace.endOperation(ISchedulingRule, boolean, IProgressMonitor) line: 901
Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 1683
NotificationManager$NotifyJob.run(IProgressMonitor) line: 38
Worker.run() line: 66
Comment 3 Tod Creasey CLA 2005-03-07 11:54:35 EST
If this is not a performance issue please remove the performance keyword as we
are now tracking these more closely.
Comment 4 Jerome Lanneluc CLA 2005-03-07 11:57:21 EST
Looks like a perfomance issue to me.
Comment 5 Tod Creasey CLA 2005-03-07 11:57:26 EST
Adding my name to the cc list as we are now tracking performance issues more
closely. Please remove the performance keyword if this is not a performance bug.
Comment 6 Jerome Lanneluc CLA 2005-04-20 09:48:57 EDT
Changed SetClasspathOperation#updateAffectedProjects(IPath) to ignore projects
than are not in the JavaModelCache as their namelookup cache doesn't need to be
updated.
Comment 7 Mike Wilson CLA 2005-04-25 10:51:12 EDT
Are there outstanding work items for this bug?
Comment 8 Jerome Lanneluc CLA 2005-04-25 10:56:50 EDT
Yes, I need to do some measurement to see the gain of my last change, and maybe
optimize other call to computeExpandedClasspath.
Comment 9 Jerome Lanneluc CLA 2005-04-27 07:43:29 EDT
Changed DeltaProcessor to compute a light weight dependency map (during
DeltaProcessingState#initializeRoots()) instead of using getExpandedClasspath()
which is expensive.

In my monster workspace (more than 1000 plugins) resetting the project caches
during delta processing used to take 85,000ms after a crash (0ms in case of no
crash). It now takes 10ms after a crash (and still 0ms in case of no crash).
Comment 10 Frederic Fusier CLA 2005-05-13 06:57:18 EDT
Verified for 3.1 M7 using build I20050513-0010.