Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 344347

Summary: [region] linear search to find a bundle's region hurts performance
Product: [Eclipse Project] Equinox Reporter: Thomas Watson <tjwatson>
Component: ComponentsAssignee: Thomas Watson <tjwatson>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: glyn.normington
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
work in progress + performance tests
none
updated patch and tests none

Description Thomas Watson CLA 2011-04-29 16:45:15 EDT
Created attachment 194410 [details]
work in progress + performance tests

org.eclipse.equinox.internal.region.StandardRegionDigraph.getRegion(long) performs a linear search over all regions to find the region a bundle belongs to.  This causes significant slow down for resolve, bundle, service operations.  For example, simply having 100 regions created shows about 4x slowdown in performance of getBundles methods.

I think we need to consider hashing the Bundle->Region relationship similar to how we hashed the Region->Edges relationship.  The attached patch does this.  It also has some performance tests that show the slow down.

In order to run the performance tests you need the following project org.eclipse.core.tests.harness at http://dev.eclipse.org/viewsvn/viewvc.cgi/org.eclipse.core.tests.harness/

Glyn, please take a look.  The patch adds a new global map to digraph that all regions must use to record the Bundle->Region map.
Comment 1 Thomas Watson CLA 2011-05-02 10:15:14 EDT
I forgot that you also need org.eclipse.test.performance:

http://dev.eclipse.org/viewsvn/viewvc.cgi/org.eclipse.test.performance/
Comment 2 Thomas Watson CLA 2011-05-02 16:34:10 EDT
Created attachment 194541 [details]
updated patch and tests

Here is an updated patch.  I decided to remove the ConcurrentMap used to keep the set of bundle ids that belong to a region.  This could potentially make Region.getBundle(String, Version) slower, but I don't think that is a method that gets called very much (if at all).
Comment 3 Thomas Watson CLA 2011-05-02 16:46:20 EDT
I released this last patch.