Bug 20061 - Closing the Workbench is slow, writing .registry is slow
Summary: Closing the Workbench is slow, writing .registry 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 normal (vote)
Target Milestone: 2.0 F4   Edit
Assignee: Debbie Wilson CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2002-06-12 15:04 EDT by Jason Crawford CLA
Modified: 2002-06-19 13:32 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Crawford CLA 2002-06-12 15:04:58 EDT
A month ago it took about a 10 seconds.  As of about two weeks ago it has begun 
taking 60 seconds.  This is impacting the ability of folks to debug plugins.  
The problem appears to be the writing of the .registry file.  The objectArray
has over 7000 elements in it and is implemented as an ArrayList.  Additionally
the process of saving calls indexOf (which is implemented linearly) against the 
array *many* times (70000 times maybe?) which of course creates O(n**2) 
situation.  Additionally, the implementation of ArrayList.indexOf() uses the 
equals() method on the objects, not the == operator.  As you might imagine... 
and can easily measure, this slows things down a lot.   I understand why an 
ArrayList is being used, but you need to use some other structure to do the 
semantic equivalent of the "indexOf" operation when writing out the .registry 
file.
   To reproduce this, start the workbench in a debugger, quit the workbench, and 
stop the code a few times after the workbench window disappears.  You should 
find that most of the times you stop the code you'll be in either the equals() 
method or the indexOf() method.
Comment 1 DJ Houghton CLA 2002-06-14 14:30:12 EDT
Will investigate.
Comment 2 DJ Houghton CLA 2002-06-14 16:20:49 EDT
build F3
J9 VM
2GHz machine
427 plug-ins

reading registry: 1045ms
writing registry: 19450ms
Comment 3 DJ Houghton CLA 2002-06-14 17:27:10 EDT
Currently we always write out the .registry file on shutdown. A quick 
optimization would be to only write it out if it is dirty from last startup.

- startup
- read registry cache
- if cache is valid then continue
- otherwise delete cache from disk and parse plug-ins
...
- on shutdown
- does cache file exist?
- if true do nothing
- otherwise write out the registry

We still need to investigate the use of ArrayLists.
Comment 4 Gary Karasiuk CLA 2002-06-16 07:37:28 EDT
The quick optimization would be a good thing also, but using a
better structure than ArrayList (perhaps a HashMap) is the real heart
of the problem. 
Comment 5 Gary Karasiuk CLA 2002-06-16 07:38:49 EDT
Thanks for looking into this so quickly! This is quite an important bug for us.
Comment 6 Jason Crawford CLA 2002-06-16 15:45:13 EDT
That alternative data structure probably only needs to exist during the save 
process.
Comment 7 David Williams CLA 2002-06-16 23:14:12 EDT
Thought I'd mention this may not be relevent to only shutdown, per se, but 
with the timed "save workspace" option in F3, there's been a few times that my 
F3 workbench has appeared to hang for several minutes. I don't know if the 
delay is all related to writing the registry, but something takes several 
minutes (not seconds). (This is on a 800 GHz machine, 1 Gig of ram, with 
several hundred plugin projects) It doesn't seem to consistently take that much 
time, but thought I'm make this observation here.
Comment 8 Gary Karasiuk CLA 2002-06-17 05:58:49 EDT
David, I don't know if this is related to your problem or not, but the one 
place where I have seen long delays, is if the Eclipse process gets swapped out 
by Windows. Swapping it back in then takes a very long time. 

During one of these delays if you open the Task Manager, you can tell if this 
is the cause of the delay by watching the memory usage of the eclipse process. 
If it is slowing growing (a couple of Meg a second) then thats most likely the 
cause. 
Comment 9 Debbie Wilson CLA 2002-06-17 13:45:52 EDT
Have fixed this by writing out the registry cache only if it has changed (as 
per DJ's comments on 2002-06-14 17:27). If the cache has changed, we delete the 
cache file.

The issue of using ArrayLists has been documented as bug 20480 and will be 
investigated post 2.0.
Comment 10 DJ Houghton CLA 2002-06-17 13:48:34 EDT
In the original comment, you mention that it used to take 10 seconds to write 
out the registry and as of late it has gotten considerably worse. The registry 
cache serialization code hasn't changed in months so this increase in time is 
curious. Has your number of plug-ins significantly increased in this time?
Comment 11 Gary Karasiuk CLA 2002-06-17 15:17:30 EDT
You wrote: 

"A quick optimization would be to only write it out if it is dirty from last 
startup." 

Do you have a feel for how many times the quick optimization would apply? What 
are some of the end user actions that would cause the quick optimization not to 
apply? 
Comment 12 DJ Houghton CLA 2002-06-17 15:26:49 EDT
The registry cache will not be written out in a normal scenerio. It will be 
written out via the same operations that would have invalidated the registry 
cache before. Essentially modifying the plugins directory. (installing new 
plugins, removing plugins, editing plugin.xml files, etc)
Comment 13 Jason Crawford CLA 2002-06-19 12:55:17 EDT
DJ_Houghton asked if we've increased the number of plugins recently because
he doesn't think the code in question has changed recently.

Unfortuntately I don't know.  I don't normally work at the plugin level and 
I no longer have any builds from last month with which to do a comparison.  
I do think  that's a good question though.

I will clarify something though.  I said 10 seconds vs 60 seconds in my 
original posting.  The 60 second figure was accurately measured.  10 seconds
was just my recollection.  I think that might have been as high as 25 seconds,
but it clearly wasn't as long as I'm currently seeing... and it's clearly
too long.
Comment 14 Gary Karasiuk CLA 2002-06-19 13:32:11 EDT
The number of plugins in WSAD has increased since release 4. In release 4 we 
had 196 plugins (68 were from eclipse).  We currently have 418 (70 from 
eclipse). But I didn't think that the number had gone up recently, but I am not 
sure.