Bug 11164 - [resources] Finding markers is slow
Summary: [resources] Finding markers is slow
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P2 major (vote)
Target Milestone: 2.1 M4   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
: 7460 12618 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-03-12 09:25 EST by Kevin Haaland CLA
Modified: 2002-12-12 06:25 EST (History)
4 users (show)

See Also:


Attachments
switching to java perspective on a bug workspace (27.76 KB, text/plain)
2002-12-04 05:39 EST, Adam Kiezun CLA
no flags Details
startup of big workspace (32.12 KB, text/plain)
2002-12-04 06:10 EST, Adam Kiezun CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Haaland CLA 2002-03-12 09:25:04 EST
It takes a significant amount of time to find markers as it currently requires 
a taversal of the entire resource tree. If it turns out that markers are 
relatively few and sparse the addition of a "marker count" may avoid taversing 
areas of the tree where we know there are no markers.
Comment 1 DJ Houghton CLA 2002-04-03 17:03:17 EST
*** Bug 7460 has been marked as a duplicate of this bug. ***
Comment 2 DJ Houghton CLA 2002-04-15 09:30:19 EDT
Closing for now but will consider at end of cycle as part of performance work 
(time permitting) or will investigate post 2.0.
Comment 3 DJ Houghton CLA 2002-09-10 12:21:19 EDT
Reopening for investigation.
Comment 4 Nick Edgar CLA 2002-11-21 09:40:24 EST
Maintaining a marker count would help.  Also, recursiveFindMarkers uses 
getResourceInfo and getChildren, resulting in many lookups.  Recursing over the 
delta data tree directly would be much more efficient (would need to ensure 
latest tree is the complete representation first).

In my self-hosting workspace (org.eclipse.jface* and org.eclipse.ui* in source, 
and the rest as binaries), opening the Bookmarks view generated:
- about 800K of garbage (mostly Paths)
- ~3500 calls to Workspace.recursiveFindMarkers and getResourceInfo
- ~25000 calls to AbstractDataTreeNode.childAtOrNull
- ~30000 calls to AbstractDataTreeNode.indexOfChild
- ~97000 calls to String.compareTo

About 3/4 of the time to open the bookmarks view was in findMarkers (2500ms on 
my laptop under OptimizeIt).  
This is a lot of work to determine that there are 0 bookmarks <g>.
Comment 5 DJ Houghton CLA 2002-11-21 15:36:19 EST
After discussing with NE, some thoughts.

- a count could be kept for each resource which represents the number of 
markers on it and its children
- a value of -1 would mean "don't know" and we'd have to re-calculate
- -1 could be the default on save so it would be re-calculated the first time 
each session?
Comment 6 Adam Kiezun CLA 2002-12-04 05:39:37 EST
Created attachment 2643 [details]
switching to java perspective on a bug workspace

i took the 'big workspace' from core website
here's the profile of the first opening of the java perspective
37% of time is spent in Resource.findMarkers()
Comment 7 Adam Kiezun CLA 2002-12-04 06:10:05 EST
Created attachment 2644 [details]
startup of big workspace

Resource.findMarkers takes 41% of startup time on a big workspace
(find 'Resource.findMarkers' in the attached profile) 

we must either acknowledge that it's slow and not call it so frequently 
or fix the slowness
Comment 8 John Arthorne CLA 2002-12-04 11:15:45 EST
Adam, any idea on the number of times findMarkers is invoked?

As an extra data point, I ran a "findMarkers" benchmark on a running "big
workspace" (74,409 resources, 812 markers).  The average time for a single
findMarkers call in the workspace root takes 190ms on my machine.  I don't deny
there are opportunities to improve this, but it would be interesting to see how
many times it is called on startup.
Comment 9 Adam Kiezun CLA 2002-12-04 11:49:28 EST
no idea, sorry - but the number you gave suggests that it must be thousands of 
times.
we may need to call it less often instead of making it cheaper.
or provide a different model altogether
Comment 10 Adam Kiezun CLA 2002-12-04 11:51:51 EST
that might be the biggest gain on startup performance improvement. so it might 
be worth investigating.
Comment 11 John Arthorne CLA 2002-12-05 10:48:36 EST
I have tweaked the findMarkers implementation for roughly a 4x improvement.  On
my computer the benchmark went from 190ms to 49ms.  However, there are
definitely some opportunities to reduce the number of invocations of
findMarkers.  I have entered bug 27764 for further JDT investigation of the
number of times findMarkers is called.  I have included in that bug report some
details of my initial investigation.
Comment 12 Adam Kiezun CLA 2002-12-10 13:23:12 EST
*** Bug 12618 has been marked as a duplicate of this bug. ***
Comment 13 John Arthorne CLA 2002-12-11 11:16:31 EST
Released fix to HEAD.  Finding markers on a large workspace (74,409 resources)
now takes 16ms for a total speedup of 12x over the original result.

I have created bug 27948 to investigate exposing the fast tree traversal
infrastructure that was used as general API.

Note to clients: this does NOT mean you can now call findMarkers twelve times as
often <g>.
Comment 14 Adam Kiezun CLA 2002-12-11 11:22:19 EST
did any of that speedup find its way to 20021210?
Comment 15 John Arthorne CLA 2002-12-11 11:43:22 EST
Nope.  Next build.  It's now in HEAD if you want to try it out.
Comment 16 Adam Kiezun CLA 2002-12-12 06:25:07 EST
works really great - thanks