Bug 179685 - JREContainerInitializer average initialization time
Summary: JREContainerInitializer average initialization time
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.2.2   Edit
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Darin Wright CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2007-03-28 04:58 EDT by Eric Jodet CLA
Modified: 2007-04-27 11:41 EDT (History)
3 users (show)

See Also:


Attachments
screenshot (156.68 KB, image/png)
2007-04-05 15:48 EDT, Michael Rennie CLA
no flags Details
patch (9.49 KB, patch)
2007-04-17 17:35 EDT, Darin Wright CLA
no flags Details | Diff
further work in progress (14.83 KB, patch)
2007-04-18 16:31 EDT, Michael Rennie CLA
no flags Details | Diff
screen shot (131.20 KB, image/png)
2007-04-18 16:38 EDT, Michael Rennie CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Jodet CLA 2007-03-28 04:58:29 EDT
Using RAD 7.0.0.1 - which uses org.eclipse.jdt.debug_3.2.2.r322_v20070130

instrumented jdt.core plugin to measure ClasspathContainerInitializer initialization durations.

scenario: start RAD against a 110+ J2EE projects
and collect average ClasspathContainerInitializer initialization durations

the JREContainerInitializer takes more time than others.

Initializer com.ibm.ws.ast.st.core.internal.runtime.ServerClasspathContainerInitializer@3b543b54
initialized 90 times
Total duration: 260 ms
Average duration: 2 ms


Initializer org.eclipse.jst.server.core.internal.RuntimeClasspathContainerInitializer@640064
initialized 108 times
Total duration: 190 ms
Average duration: 1 ms


Initializer org.eclipse.jdt.internal.launching.JREContainerInitializer@5b605b60
initialized 116 times
Total duration: 1873 ms
Average duration: 16 ms

this init duration might have an impact on startup times.
Comment 1 Seng Phung Lu CLA 2007-03-28 17:44:40 EDT
Eric,
when we tried this test by launching into the J2EE perspective on startup, the classpath initializers were running off the scale.  The initialers ran numbers times (8-9times), and their respective durations became longer.

Here's the result for the JREContainerInitializer:
Initializer org.eclipse.jdt.internal.launching.JREContainerInitializer@76f876f8
initialized 42 times
Total duration: 23122 ms
Average duration: 550 ms

Would it be possible to try launching your 100+ project workspace into the J2EE perspective and confirming my results?

Thanks!
Comment 2 Eric Jodet CLA 2007-03-29 04:58:38 EDT
(In reply to comment #1)
Seng,
had another test run using a more recent version and obtained an average init time of 98 ms for the JREContainerInitializer.
Performed 12 warm startup runs.
I'll send you the raw data and you'll notice that init time can vary from 20 to 298 ms ! though I was just starting / stopping RAD
Comment 3 Darin Wright CLA 2007-03-29 14:03:05 EDT
Marking as P1, as this slows down startup.
Comment 4 Michael Rennie CLA 2007-04-05 15:43:04 EDT
Applied a fix to StandardVMType where we were looping over lots of loops many times causing a fair amount of work. Now we iterate over the collect once. Took about 2 seconds out of startup work.

Other findings:

JavaCore.newLibraryEntry(IPath, IPath, IPath, IAccessRule[], ClasspathAttribute[], boolean) is a very expensive method  (as seen in the first attached screen shot), which seems to be causing a fair amount of startup work
Comment 5 Michael Rennie CLA 2007-04-05 15:48:20 EDT
Created attachment 63099 [details]
screenshot

Shows JavaCore.newLibraryEntry(...) and the amount of work out of the totals it actually does. Notice in the cases shown in the screenshot it does more than half of the work each place it is called, although it does have a high invocation count (and each invocation is less than 1ms), this might be worth looking at, maybe we can cut down on the the number of calls to it.
Comment 6 Darin Wright CLA 2007-04-17 17:35:35 EDT
Created attachment 64105 [details]
patch

Work in progress. When access rule participants always return the same set of rules, we can cache/reuse classpath entries. However, when access rule participants don't return the same set of access rules, this cache just grows (bad).
Comment 7 Michael Rennie CLA 2007-04-18 16:31:26 EDT
Created attachment 64230 [details]
further work in progress

Worked on what you provided so far, profiled the heck out of it and made a few changes. We are now down to 32 invocations for JavaCore.newLibraryEntry, and have dropped almost 5 seconds off of the profiled timings.

Darin, have a look at the new code and see if you can see any more places to squeeze blood out of this stone :). Will post screenshot of latest profile session with this patch applied.
Comment 8 Michael Rennie CLA 2007-04-18 16:38:01 EDT
Created attachment 64232 [details]
screen shot

newest profiling session showing 3 second improvement in the JREContainerInitializer#initialize timing over the original profiling session (the first screen shot)
Comment 9 Darin Wright CLA 2007-04-18 18:12:04 EDT
Looks good. Comments:

* ExecutionEnvironment needs to be a VM listener to clear its caches as VM's change/remove.
* In ExecutionEnvironment we use equals(..) on a Map to test whether to re-use the cached access rules. However, we are relying on identity of the IAccessRule[][] arrays. We could do extra processing here in case rule collections are equal but not identical? (similar to what we do in the JREContainer).
Comment 10 Michael Rennie CLA 2007-04-20 10:09:33 EDT
Released changes to HEAD including making the ExecutionEnvironment containers VM listeners so they can update more appropriately.

Subsequent profilings show the performance steady in line with the last screen shot.


Changes to ExecutionEnvironment and JREContainer
Comment 11 Michael Rennie CLA 2007-04-20 10:10:20 EDT
Darin W please verify the changes and the performance changes.
Comment 12 Eric Jodet CLA 2007-04-24 00:56:09 EDT
(In reply to comment #10)
Darin,
any chances we could backport this one to 3.2, so that other eclipse based products (like RAD) could benefit it?
Comment 13 Philipe Mulet CLA 2007-04-24 05:59:46 EDT
+1 for 3.2 backporting
Comment 14 Darin Wright CLA 2007-04-24 09:03:04 EDT
Is there a performance problem in 3.2? We did not support access rules on execution environments in 3.2 - that was new in 3.3.
Comment 15 Eric Jodet CLA 2007-04-24 09:06:49 EDT
(In reply to comment #14)
Please refer to the initial comment when openening this bug.
RAD 7.0.0.X uses org.eclipse.jdt.debug_3.2.2.r322_v20070130
Comment 16 Darin Wright CLA 2007-04-24 11:02:01 EDT
Re-opening. Looks like there's more work to do here in terms of JREContainerInitializer.resolveVM(..).
Comment 17 Michael Rennie CLA 2007-04-25 12:01:41 EDT
After more profilings and further testing the performance between 3.2.2 and 3.3 is almost identical when execution environments are not used for the 100+ projects. If however execution environments are used there is an appreciable timing difference, as we have to do more work. We have mitigated this difference as much as we can by creating a new caching scheme for access rules in 3.3.

The invocation count issue mentioned in comment 16 was due to a mis-configuration between my 3.3 and 3.2.2 workspace. Once that was fixed the profilings were identical (as they should be since that code has not changed).

remarking as FIXED.
Comment 18 Michael Rennie CLA 2007-04-25 12:02:23 EDT
Darin, please re-verify the findings.
Comment 19 Michael Rennie CLA 2007-04-26 11:03:36 EDT
reopening to reassign
Comment 20 Michael Rennie CLA 2007-04-26 11:04:42 EDT
Darin W, do your thing
Comment 21 Darin Wright CLA 2007-04-27 11:41:01 EDT
Verified.