Bug 325244 - 'Open from Clipboard' is slow and reports progress twice
Summary: 'Open from Clipboard' is slow and reports progress twice
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2010-09-14 08:54 EDT by Markus Keller CLA
Modified: 2010-10-26 06:42 EDT (History)
4 users (show)

See Also:


Attachments
fix (16.22 KB, patch)
2010-09-20 05:15 EDT, Deepak Azad CLA
no flags Details | Diff
fix (15.57 KB, text/plain)
2010-09-20 11:08 EDT, Deepak Azad CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-09-14 08:54:35 EDT
I20100914-0100

I tried to open this reference in my dev workspace:
org.eclipse.swt.events.MouseAdapter.mouseDown(MouseEvent)

Search took very long (25s) and after progress bar was at the end, it started again at zero (but second search was at least quicker). I think this could be improved a lot if you used the same JDT/Core APIs I would use if I opened the type with Open Type and then used the Quick Outline.
Comment 1 Deepak Azad CLA 2010-09-14 11:47:15 EDT
(In reply to comment #0)
> I think this could be
> improved a lot if you used the same JDT/Core APIs I would use if I opened the
> type with Open Type and then used the Quick Outline.
Are you also suggesting this for the case when the fully qualified name is not there. e.g. MouseAdapter.mouseDown(MouseEvent) ?

...essentially this would be a faster method search when the type name is available, and could possibly be done in JDT/Core. I will investigate.
Comment 2 Markus Keller CLA 2010-09-14 12:39:14 EDT
(In reply to comment #1)
> Are you also suggesting this for the case when the fully qualified name is not
> there. e.g. MouseAdapter.mouseDown(MouseEvent) ?

Whatever is faster ;-). I did not yet look at the code. Maybe it's also a problem of wrong flags or the scope is expensive to compute, or ... .

But it could indeed be a performance problem in JDT/Core. Search for declarations of a fully qualified method name is also quite slow in the Search dialog.
Comment 3 Dani Megert CLA 2010-09-15 06:32:41 EDT
> But it could indeed be a performance problem in JDT/Core. Search for
> declarations of a fully qualified method name is also quite slow in the Search
> dialog.
In my big dev workspace the action is almost unsable in some cases, e.g. "Worker.run" takes more than a minute. This is definitely due to the Java search which also takes about 1'10''.
Comment 4 Dani Megert CLA 2010-09-15 06:45:48 EDT
> This is definitely due to the Java
> search which also takes about 1'10''.
One reason is probably bug 324189.
Comment 5 Satyam Kandula CLA 2010-09-15 11:13:12 EDT
Search for method declarations in JDT/Core is not really optimized for TypeName.Method(). 

It gets all the files which declares Method(), parses those files and if the Method is really there, it finds out if the type is in the hierarchy and if so it reports the Method. This algo is shared across for both declarations and references. 

Though this algo is necessary for references, it can be optimized for declarations especially when TypeName is given. Either the parsing can be limited to only those types in the hierarchy of the types matching TypeName or only the Types in the hierarchy of TypeName can be looked for the method. 

Though these optimizations can be done in JDT/Core, the api's you manage to call the JDT/Core can also be modified to fit this :) 

However, I think the best and easy solution should be the one that Markus had pointed in comment 0.
Comment 6 Deepak Azad CLA 2010-09-20 05:15:31 EDT
Created attachment 179231 [details]
fix

I have changed OpenFromClipboardAction code to use SearchEngine.searchAllTypeNames(...) whenever the type name is available. I have tried this patch on my large dev workspace and performance is really good now. For example results for 'Worker.run()' come within a couple of seconds.

I also think that JDT/Core's SearchEngine.search(...) APIs should use the fastest way of searching all the time, so that all clients get the fastest performance possible. I will open a separate bug for that.

(The patch also has the fix for Bug 325239 as it was a small fix and affects the same files)
Comment 7 Dani Megert CLA 2010-09-20 10:23:21 EDT
Performance looks much better now!

Patch is good except that I'd MEMBER_1/2. Reading the Javadoc the second pattern is for methods - why not name it like that?

>(The patch also has the fix for Bug 325239 as it was a small fix and affects
>the same files)
Verified that this is also working.
Comment 8 Deepak Azad CLA 2010-09-20 11:08:22 EDT
Created attachment 179253 [details]
fix

(In reply to comment #7)
> Patch is good except that I'd MEMBER_1/2. Reading the Javadoc the second
> pattern is for methods - why not name it like that?
Changed to MEMBER_PATTERN and METHOD_JAVADOC_REFERENCE_PATTERN.

Darin, if the patch looks good to you then can you please commit it. Thanks!
Comment 9 Darin Wright CLA 2010-09-20 13:53:56 EDT
Applied/Fixed.
Comment 10 Dani Megert CLA 2010-10-26 06:42:20 EDT
Verified in I20101025-1800.