Bug 296936 - [touchpoint] Performance issues when installing features
Summary: [touchpoint] Performance issues when installing features
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4.2+   Edit
Assignee: P2 Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2009-12-04 12:16 EST by DJ Houghton CLA
Modified: 2010-01-07 13:56 EST (History)
4 users (show)

See Also:


Attachments
eclipse.touchpoint JAR for Eclipse 3.4.2 (91.92 KB, application/octet-stream)
2009-12-07 11:41 EST, DJ Houghton CLA
no flags Details
patch for 3.4.x and 3.5.x (4.88 KB, patch)
2009-12-11 13:41 EST, DJ Houghton CLA
no flags Details | Diff
Patch against 3.6 HEAD (16.99 KB, patch)
2009-12-16 15:12 EST, John Arthorne CLA
no flags Details | Diff
Fix for platform.xml caching only (7.32 KB, patch)
2009-12-18 14:09 EST, John Arthorne CLA
no flags Details | Diff
Updated patch for 3.4.x stream that removes visibility changes (5.32 KB, patch)
2010-01-07 13:54 EST, John Arthorne CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description DJ Houghton CLA 2009-12-04 12:16:26 EST
When a user installs a feature, we add it to the appropriate site in the platform.xml file. When a user installs 2300 features, we do the same. Unfortunately we don't do any caching so we parse this file every time.

We should investigate:
- caching the platform.xml in memory
- batching operations
- conversion of the parsing from DOM to SAX

Check out the Configuration class in the Eclipse touchpoint.
Comment 1 DJ Houghton CLA 2009-12-07 11:41:23 EST
Created attachment 153934 [details]
eclipse.touchpoint JAR for Eclipse 3.4.2

This is a new org.eclipse.equinox.p2.touchpoint.eclipse JAR for Eclipse 3.4.2 which contains code which caches the Configuration file. In a local test it reduced the number of times we parse the platform.xml file from n+1 to 1. (where n is the number of features that we are trying to install via the drop-ins)

Note we are still writing the file n+1 times.
Comment 2 DJ Houghton CLA 2009-12-07 16:05:01 EST
Released platform.xml caching change into api_branch.
Comment 3 Mike Wilson CLA 2009-12-09 09:13:22 EST
Is it possible to detect that you are in a state where you do not need to write the configuration file (because a follow on step will cause it to be written)?
Comment 4 Pascal Rapicault CLA 2009-12-09 13:28:32 EST
This should be possible since there are some lifecycles. However this change was originally developed to be applied in 3.4 where we wanted to be conservative and the writing of the file was not an issue (parsing was). For 3.6, this could be revised.
Comment 5 DJ Houghton CLA 2009-12-11 13:41:15 EST
Created attachment 154326 [details]
patch for 3.4.x and 3.5.x
Comment 6 John Arthorne CLA 2009-12-16 09:54:02 EST
DJ and I investigated this yesterday, and we found at least three other places where we are n^2 or worse where n is the number of features being installed. Here they are in order of decreasing impact on performance:

1) PublisherResult#query. On each query this method copies all the existing results from a map into a list, and then creates an iterator and checks each one. For InstallableUnitQuery we can make this O(1) because we already store a map keyed by installable unit id. This is the most common (only?) query on PublisherResult during publishing (at least it's the only one that showed up under the profiler).

2) LocalMetadataRepository#query. This uses a linear search each time a feature is requested.

3) PublisherInfo#getAdvice(). This does a linear search over all advice in the info object. Each feature and bundle that gets installed contributes at least on BundleShapeAdvice, so this search is O(n) and is called many times during publishing.

I have patches ready for 1) and 2) and they make a big improvement using our test data. 3) is a little bit more complicated and may not be worth the optimization.
Comment 7 John Arthorne CLA 2009-12-16 15:12:15 EST
Created attachment 154591 [details]
Patch against 3.6 HEAD

This patch contains:

 - New implementation of DJ's platform configuration caching on read
 - Fixes for issues 1) and 2) in my list of O(n^2) performance issues during reconcile.
Comment 8 John Arthorne CLA 2009-12-18 14:07:20 EST
After more investigation, it turns out none of the problems in comment #6 apply to the 3.4.x stream. Those are performance regressions introduced by moving to the publisher in 3.5. I have opened bug 298216 to track those problems in 3.6 (and possibly 3.5.2), and will leave this bug to track problems in the 3.4.x stream.
Comment 9 John Arthorne CLA 2009-12-18 14:09:43 EST
Created attachment 154808 [details]
Fix for platform.xml caching only

This is the most up to date version of DJ's patch to cache reading of platform.xml. That is the only fix that seems to have any impact on reconciler performance in the 3.4.x stream.
Comment 10 John Arthorne CLA 2010-01-07 13:54:40 EST
Created attachment 155529 [details]
Updated patch for 3.4.x stream that removes visibility changes
Comment 11 John Arthorne CLA 2010-01-07 13:56:02 EST
DJ and I have done some further testing on the patch this morning and we're satisfied with it. Released into 3.4.x stream.