Bug 3658 - JDT change listener efficiency issue (1GEMN5F)
Summary: JDT change listener efficiency issue (1GEMN5F)
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All Windows 2000
: P3 critical (vote)
Target Milestone: 2.0 M2   Edit
Assignee: Claude Knaus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 7597
Blocks:
  Show dependency tree
 
Reported: 2001-10-10 22:58 EDT by Jeff McAffer CLA
Modified: 2002-01-24 10:09 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff McAffer CLA 2001-10-10 22:58:44 EDT
ClassFileMarkerAnnotationModel.visit is very much less than optimal if fMarkerResource is set.
It traverses the entire delta only looking for a particular resource!  I don't understand when fMarkerResource
is set and when it is not but in the case I saw, it was set to be a particular project resource which was not
even in the list of resources which changed in the large delta I was processing.  The net result of 
this was that the listener traversed the entire delta (~1500 resources) checking at each node to see 
if the node was equal to fMarkerResource.  

Since the listener knows that it is only interested in that one resource, it should just take the delta
and look in it to see if the resource in question is there.   The current IResourceDelta api is not 
optimal for doing this but it certainly can be done and would be very much more efficient than the
current approach.  We will look at adding the required API but this late in the game I would not hope
for too much.

NOTES:

JBL (6/1/2001 11:47:09 AM)
	ClassFileMarkerAnnotationModel is JUI.
	Moving to ITPJUI.

KUM (8/6/2001 4:41:57 PM)
	Sent mail to JMA regarding expected core support.
Comment 1 DJ Houghton CLA 2001-10-24 07:15:51 EDT
PRODUCT VERSION:
116

Comment 2 Kai-Uwe Maetzel CLA 2002-01-11 10:22:11 EST
Should make use of public IResourceDelta findMember(IPath path);
Comment 3 Claude Knaus CLA 2002-01-15 08:44:39 EST
As a test case, I make a search with lots of results (all references to 
IJavaElement) and see how long the update of the marker takes.

I'd like to see 7597 fixed to be able to verify this fix.
Comment 4 Claude Knaus CLA 2002-01-16 11:16:13 EST
Jeff,

What kind of test case do you have for testing this performance issue?
Comment 5 Erich Gamma CLA 2002-01-18 06:13:22 EST
added DJ, may be he can answer the question from Claude below.
Comment 6 John Arthorne CLA 2002-01-22 12:18:11 EST
I don't have one handy, but it's very easy to construct one.  Create a large 
workspace (such as an eclipse-in-eclipse workspace), then install your listener 
and perform the following operation many times (for example install a toolbar 
button that runs the benchmark):

ResourcesPlugin.getWorkspace().getRoot().accept(new IResourceVisitor() {
  public boolean visit(IResource resource) throws CoreException {
    resource.touch(null);
    return true;
  }
});

I will send you a plugin that graphically displays the timing information for 
all installed resource change listeners.

For a quick and dirty test you can call:

org.eclipse.core.internal.utils.ResourceStats#dumpStats

to print out info on how much time was taken by each listener.  
Comment 7 Claude Knaus CLA 2002-01-24 10:09:46 EST
fixed > 20020123
However, I cannot see any performance difference whatsoever.
I have no test case which proves that this traversal is expensive in any way.