Bug 35363 - Calculating all plug-in prereqs recursively is inefficient with "dependsOn".
Summary: Calculating all plug-in prereqs recursively is inefficient with "dependsOn".
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 2.0.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2003-03-20 09:03 EST by Dan Kehn CLA
Modified: 2004-04-29 05:52 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 Dan Kehn CLA 2003-03-20 09:03:09 EST
I've noticed that opening and switching perspectives is slow with the base 
Eclipse 2.0.2 and especially with WSAD.  So I tried to find out why as my 
first foray into the WSAD Profiler.  It led me to a method in 
AcceleratorRegistry that gives me pause: 

        private boolean dependsOn(IPluginRegistry registry,IPluginDescriptor 
descriptor0, IPluginDescriptor descriptor1) { 
                IPluginPrerequisite[] prerequisites= 
descriptor0.getPluginPrerequisites(); 
                for (int i= 0; i < prerequisites.length; i++) { 
                        IPluginPrerequisite prerequisite= prerequisites[i]; 
                        String id= prerequisite.getUniqueIdentifier
();                         
                        IPluginDescriptor descriptor= 
registry.getPluginDescriptor(id); 
                        if (descriptor != null && (descriptor.equals
(descriptor1) || dependsOn(registry,descriptor, descriptor1))) 
                                return true; 
                } 
                
                return false; 
        } 

This method is recursive, and it is walking the plug-in prerequisites.  
Opening a perspective (in this case the CVS Repository Exploring) yielded 189K 
calls to the above method, and the switch while under the profiler took over 
45 seconds.  I commented out this code and returned false, assuming that the 
worse thing that would happen is that some accelerators wouldn't work.  That 
reduced the number of invocations of dependsOn to 84 and the switch took six 
seconds, again under the profiler. 

This test was on Eclipse 2.0.2.  I see that this class is no longer in 2.1, 
but several copies of this method are still there (search on 
getPluginPrerequisites).  If this is really necessary, perhaps 
IPluginDescriptor shouid implement a "getAllPluginPrerequisites" or "dependsOn
(IPluginDescriptor)" method that saves the result as a set to speed up 
subsequent invocations.
Comment 1 Nick Edgar CLA 2003-03-21 12:05:16 EST
AcceleratorRegistry is gone in 2.1, replaced by the new key bindings story.
This pattern no longer occurs in Platform UI (no senders of 
getPluginPrerequisites()).

Here are the remaining refs I found:

org.eclipse.help.internal.appserver.PluginClassLoaderWrapper.getPrereqClasspath
(IPluginDescriptor)
org.eclipse.help.ui.internal.browser.win32.IEBrowserAdapter.addRequiredPluginID
s(String, Collection)
org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor.depen
dsOn(IPluginDescriptor, IPluginDescriptor)
org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.getFol
derChildren(IPluginDescriptor, int)
org.eclipse.ui.texteditor.AbstractTextEditor.ConfigurationElementComparator.dep
endsOn(IPluginDescriptor, IPluginDescriptor)

The ones in AbstractTextEditor and JavaEditorTextHoverDescriptor would likely 
be the most sensitive ones, so I'm moving this to Platform-Text.

cc'ing Dorian and Dejan for the refs in Help and PDE.


Comment 2 Dorian Birsan CLA 2003-03-21 12:33:53 EST
The calls in help do not have any problems:

org.eclipse.help.internal.appserver.PluginClassLoaderWrapper.getPrereqClasspath
(IPluginDescriptor) should not be called because we use pre-complied JSP's. In 
self-hosting or other scenarios in which users disable precompiled JSP then the 
code gets called, but the pre-req chain is small.


org.eclipse.help.ui.internal.browser.win32.IEBrowserAdapter.addRequiredPluginID
s(String, Collection) is only called once, and then the result is cached (we 
noticed some performance problems and fixed for M4).
Comment 3 Dani Megert CLA 2004-04-29 05:52:15 EDT
This has been fixed some time ago in the 3.0 stream.