Bug 329656 - Revisit conditional diet parse in SourceTypeConverter.convert(ISourceType[], CompilationResult)
Summary: Revisit conditional diet parse in SourceTypeConverter.convert(ISourceType[], ...
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2010-11-08 02:59 EST by Jay Arthanareeswaran CLA
Modified: 2011-01-25 11:17 EST (History)
2 users (show)

See Also:


Attachments
Performance test used (2.10 KB, patch)
2010-12-10 02:10 EST, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jay Arthanareeswaran CLA 2010-11-08 02:59:43 EST
The SourceTypeConverter has the following condition for a diet parse:

if (this.has1_5Compliance && ((CompilationUnitElementInfo) ((JavaElement) this.cu).getElementInfo()).annotationNumber > 10) { // experimental value

While the purpose of the diet parse (in case the number of annotations being more than 10) seemed to be better performance, the question is:
In the case where the client is not interested in LOCAL_TYPE, should there be a full parse at all? Deciding to do or not do something based on this number alone is unconvincing.

I suggest we do parse the methods only when the clients are interested in them (i.e. 'flags' contains LOCAL_TYPE). This needs to be investigated, though, for any missing functionality.
Comment 1 Olivier Thomann CLA 2010-11-08 10:57:03 EST
Not sure how many times we actually end up doing a diet parse.
Please clean up that code is necessary, but make sure we don't drop in performance.
Comment 2 Srikanth Sankaran CLA 2010-11-08 23:25:52 EST
What is motivating the change ?
Comment 3 Jay Arthanareeswaran CLA 2010-11-08 23:39:10 EST
(In reply to comment #2)
> What is motivating the change ?

One of the eclipse clients ran in to a performance problem. On investigation, we found that they were using IType#resolveType() heavily. I believe doing a full parse could have also contributed to the problem, albeit not in a big way. I will use this bug to investigate that, come up with some numbers in terms of performance and make changes if required.
Comment 4 Jay Arthanareeswaran CLA 2010-12-09 04:21:02 EST
Interestingly some of the tests reveal that diet parsing take more system resources than a full parsing. For instance resolving type JavaCore in the context of JavaModelManager produces the following numbers:

Full parsing
-------------
Scenario 'org.eclipse.jdt.core.tests.performance.FullSourceWorkspaceTypeHierarchyTests#testTypeResolve()' (average over 10 samples):
  Used Java Heap:         9.54M         (95% in [9.53M, 9.55M])        
  Working Set:           197.6K         (95% in [-104.11K, 499.31K])   
  Committed:             153.2K         (95% in [-208.04K, 514.44K])   
  Working Set Peak:       65.6K         (95% in [-64.82K, 196.02K])    
  Elapsed Process:         476ms        (95% in [411ms, 541ms])        
  Kernel time:               4ms        (95% in [-2ms, 12ms])          
  Page Faults:              85          (95% in [7, 164])              
  CPU Time:                464ms        (95% in [365ms, 562ms])        
  GDI Objects:               0          (95% in [0, 0])  
  
Diet parsing
-------------
Scenario 'org.eclipse.jdt.core.tests.performance.FullSourceWorkspaceTypeHierarchyTests#testTypeResolve()' (average over 10 samples):
  Used Java Heap:        10.28M         (95% in [9.81M, 10.74M])       
  Working Set:            1.06M         (95% in [-1.2M, 3.31M])        
  Committed:             973.2K         (95% in [-2.31M, 4.22M])       
  Working Set Peak:       1.02M         (95% in [-1.2M, 3.24M])        
  Elapsed Process:        3.86s         (95% in [3.52s, 4.21s])        
  Kernel time:               7ms        (95% in [0ms, 15ms])           
  Page Faults:             441          (95% in [-146, 1.03K])         
  CPU Time:                3.3s         (95% in [3.12s, 3.47s])        
  GDI Objects:               0          (95% in [0, 0])  

In the latter case, we do a full parse only when the clients are interested in LOCAL_TYPE. This change causes some existing tests to fail. They might have to test the LOCAL_TYPE too. But I guess I will close the defect as the effort may not be worth it.

Srikanth, any idea why a diet parse would be costlier?
Comment 5 Srikanth Sankaran CLA 2010-12-09 07:58:00 EST
(In reply to comment #4)
> Interestingly some of the tests reveal that diet parsing take more system
> resources than a full parsing. For instance resolving type JavaCore in the
> context of JavaModelManager produces the following numbers:

Where are these numbers from ? (How did you collect them ?)

> In the latter case, we do a full parse only when the clients are interested in
> LOCAL_TYPE. This change causes some existing tests to fail. They might have to
> test the LOCAL_TYPE too. But I guess I will close the defect as the effort may
> not be worth it.
> 
> Srikanth, any idea why a diet parse would be costlier?

Signt unseen, no idea. Can you take a profile and see what it shows ?
Comment 6 Jay Arthanareeswaran CLA 2010-12-10 02:10:35 EST
Created attachment 184921 [details]
Performance test used

(In reply to comment #5)
> Where are these numbers from ? (How did you collect them ?)

The numbers are from the attached performance test. The tests was run with the source files as they were and with additional annotations for completeness. Results were similar.

> Signt unseen, no idea. Can you take a profile and see what it shows ?

I will see what happens.
Comment 7 Jay Arthanareeswaran CLA 2010-12-13 08:34:32 EST
(In reply to comment #6)
> > Signt unseen, no idea. Can you take a profile and see what it shows ?
> 
> I will see what happens.

Looks like in most cases, the SourceTypeConverter does most of the work instead of doing a full parse. A regular parse is only called either for a field or when an exception occurs during the process of conversion. So, that explains the diet parse being slower. It is not a comparison of diet parse vs. regular parse but selective conversion vs. diet parsing. So, it is reasonable to say that under most circumstances, the existing code works just fine.
Comment 8 Jay Arthanareeswaran CLA 2010-12-15 05:10:41 EST
Resolving as INVALID.
Comment 9 Olivier Thomann CLA 2011-01-25 11:17:17 EST
Verified.