Bug 273268 - Enormous performance problem in org.eclipse.jdt.core.IType.resolveType(String)
Summary: Enormous performance problem in org.eclipse.jdt.core.IType.resolveType(String)
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4.2   Edit
Hardware: PC Windows XP
: P3 major with 1 vote (vote)
Target Milestone: 3.5 RC1   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2009-04-22 10:26 EDT by Alexis R. CLA
Modified: 2009-05-15 05:21 EDT (History)
4 users (show)

See Also:


Attachments
org.eclipse.jdt.core.IType.resolveType(String) Performance analysis for java.lang.* (27.29 KB, text/Excel2007)
2009-04-22 10:28 EDT, Alexis R. CLA
no flags Details
Performance (Text) (62.04 KB, text/plain)
2009-04-27 04:51 EDT, Alexis R. CLA
no flags Details
Code snippet that demonstrates the bug. ( Eclipse Plug-in Project) (8.38 KB, application/zip)
2009-04-29 06:36 EDT, Alexis R. CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alexis R. CLA 2009-04-22 10:26:28 EDT
Build ID: M20090211-1700

Steps To Reproduce:
Calling the method resolveType on bytecode classes with a bytecode class name as a parameter is extremely slow.

Example:

envClass.resolveType(String className) 

For envClass -> class Attributes
    className -> java.lang.Object

Performance (in milliseconds): 
Eclipse 3.3.2 -> 0   
Eclipse 3.4.2 -> 124 
Eclipse 3.5M6 -> 125


More information:
 In our project (where all bytecode classes are parsed) this results in a performance decrease of 1000%! 
The exact same code takes 20 seconds in Eclipse 3.4.2 but only 3 seconds in Eclipse 3.3.2 ! 
The bottleneck is resolveType(String name).

The attached spreadsheet contains all resolveType(String name) method calls for java.lang.* and the performance comparison between Eclipse versions.
Comment 1 Alexis R. CLA 2009-04-22 10:28:40 EDT
Created attachment 132777 [details]
org.eclipse.jdt.core.IType.resolveType(String) Performance analysis for java.lang.*
Comment 2 Srikanth Sankaran CLA 2009-04-27 03:15:25 EDT
(In reply to comment #1)
> Created an attachment (id=132777) [details]
> org.eclipse.jdt.core.IType.resolveType(String) Performance analysis for
> java.lang.*

Would it be possible to attach a text report (comma separated values).
I am having trouble opening the attachment with both lotus symphony
and MS excel. Thanks!

Comment 3 Srikanth Sankaran CLA 2009-04-27 03:22:15 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > Created an attachment (id=132777) [details] [details]
> > org.eclipse.jdt.core.IType.resolveType(String) Performance analysis for
> > java.lang.*
> Would it be possible to attach a text report (comma separated values).
> I am having trouble opening the attachment with both lotus symphony
> and MS excel. Thanks!

Also if you have the code snippet that you used to gather
these measurements and it is shareable, please do share - thanks.

Comment 4 Alexis R. CLA 2009-04-27 04:51:07 EDT
Created attachment 133312 [details]
Performance (Text)

A plain text version of the Excel file.
Comment 5 Alexis R. CLA 2009-04-27 04:52:41 EDT
(In reply to comment #3)
> (In reply to comment #2)
> > (In reply to comment #1)
> > > Created an attachment (id=132777) [details] [details] [details]
> > > org.eclipse.jdt.core.IType.resolveType(String) Performance analysis for
> > > java.lang.*
> > Would it be possible to attach a text report (comma separated values).
> > I am having trouble opening the attachment with both lotus symphony
> > and MS excel. Thanks!
> 
> Also if you have the code snippet that you used to gather
> these measurements and it is shareable, please do share - thanks.
> 

 I gathered these measurements directly from our projects code. So I don't have a code snippet per se, but I will try to cook one up and post it!
Comment 6 Alexis R. CLA 2009-04-29 06:36:55 EDT
Created attachment 133740 [details]
Code snippet that demonstrates the bug. ( Eclipse Plug-in Project)

 Here is a small Eclipse Plug-in that demonstrates the bug. The attached archive contains the Eclipse Plug-In Project.  Simply run the plug-in and select the "Test Bytecode Speed" action from the "Bug 273268" Menu.

Hope this helps!
Comment 7 Srikanth Sankaran CLA 2009-05-08 04:34:24 EDT
(In reply to comment #6)
> Created an attachment (id=133740) [details]
> Code snippet that demonstrates the bug. ( Eclipse Plug-in Project)
>  Here is a small Eclipse Plug-in that demonstrates the bug. The attached
> archive contains the Eclipse Plug-In Project.  Simply run the plug-in and
> select the "Test Bytecode Speed" action from the "Bug 273268" Menu.
> Hope this helps!

That was helpful, thanks, I'll see what is going on here,

Comment 8 Srikanth Sankaran CLA 2009-05-08 08:35:35 EDT
(In reply to comment #7)
> (In reply to comment #6)

[...]

> That was helpful, thanks, I'll see what is going on here,

    OK, here is the scoop: The "enormous performance problem" you
are reporting is actually a legitimate side effect of the fix for
the bug# 206597. Behavior prior to that fix (3.3.2 behavior you are
measuring) is simply to return null as in this method of BinaryType. 

/*
 * @see IType#resolveType(String)
 */
public String[][] resolveType(String typeName) {
	// not implemented for binary types
	return null;
}

So, it is not surprising that the cost of this operation shows up
as zero while the cost of the real and full implementation shows 
up as a few hundreds of milli seconds. In the light of this, it is
not clear that we are staring at a performance problem at all.

What is the situation with your own project, is it material at all
that you need to resolveType's against BinaryTypes ? After all at
3.3.2 time you were getting a null and if that is NOT impacting your
project in any significant way, then you can simply short circuit
the call if the IType you have is an instance of BinaryType, thereby
eliminating the 1000% performance degradation you are seeing ?  



Comment 9 Alexis R. CLA 2009-05-12 03:32:49 EDT

Ok that makes sense. Should have catched it ourselfes, but the part of the code where this method is called is undocumented and around 5 years old. Turns out that null works just as well and thus 90% of the class does absolutely nothing.

Thank you very much for the help!

Alexis


(In reply to comment #8)
> (In reply to comment #7)
> > (In reply to comment #6)
> 
> [...]
> 
> > That was helpful, thanks, I'll see what is going on here,
> 
>     OK, here is the scoop: The "enormous performance problem" you
> are reporting is actually a legitimate side effect of the fix for
> the bug# 206597. Behavior prior to that fix (3.3.2 behavior you are
> measuring) is simply to return null as in this method of BinaryType. 
> 
> /*
>  * @see IType#resolveType(String)
>  */
> public String[][] resolveType(String typeName) {
>         // not implemented for binary types
>         return null;
> }
> 
> So, it is not surprising that the cost of this operation shows up
> as zero while the cost of the real and full implementation shows 
> up as a few hundreds of milli seconds. In the light of this, it is
> not clear that we are staring at a performance problem at all.
> 
> What is the situation with your own project, is it material at all
> that you need to resolveType's against BinaryTypes ? After all at
> 3.3.2 time you were getting a null and if that is NOT impacting your
> project in any significant way, then you can simply short circuit
> the call if the IType you have is an instance of BinaryType, thereby
> eliminating the 1000% performance degradation you are seeing ?  
> 

Comment 10 David Audel CLA 2009-05-15 05:21:45 EDT
Verified for 3.5RC1.