Bug 186144 - [implementation] the source is requested too many times when opening a classfile editor
Summary: [implementation] the source is requested too many times when opening a class...
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2007-05-09 09:24 EDT by Olivier Thomann CLA
Modified: 2007-06-20 10:11 EDT (History)
2 users (show)

See Also:


Attachments
Profiler output with instance count (14.66 KB, image/png)
2007-05-31 05:46 EDT, Dani Megert CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-05-09 09:24:09 EDT
When opening a class file editor on a class file that has no source, the source of the .class file or the source range are requested too many times.
Comment 1 Dani Megert CLA 2007-05-09 09:48:53 EDT
I would expect this to be fast, similar to when there is source in which case we also access it many times.

No plans to work on this for now but if you see a simple fix I'll accept a patch.
Comment 2 Philipe Mulet CLA 2007-05-31 03:42:46 EDT
Even if fast, I think you ask the same question over and over again - I think I remember hundreds of times 
(note that the spec doesn't tell that this operation is free).
Comment 3 Dani Megert CLA 2007-05-31 04:12:07 EDT
>I think I remember hundreds of times
Do we? Do you have data because I don't think so. Maybe at your lowest end it seems 100x but if I call getA and getB and you count it twice, it's not the same. So, concrete data is welcome. This bug is rather vague.
Comment 4 Dani Megert CLA 2007-05-31 04:12:55 EDT
If I find time I can do some measuring but now we're in 3.3 lock down I'm booked out.
Comment 5 Dani Megert CLA 2007-05-31 05:45:13 EDT
I did a quick check

ClassFile.getSource() is called just two times: once for the ClassFileDocumentProvider and once from the folding structure provider.

ClassFile.getSourceRange() is called just four times: two times by the editor and once by some actions that need to set their enablement.

Now, getBuffer() is hit MANY times and that's because the outline needs the categories for each member and the JDT Core code then goes and requests the buffer for each of those calls.

There is nothing I can do about this. Moving to JDT Core to check whether calling getBuffer() is needed to get the categories of binary members that have no source.
Comment 6 Dani Megert CLA 2007-05-31 05:46:37 EDT
Created attachment 69489 [details]
Profiler output with instance count

Interesting how many calls to the zip file(s) are needed to open sun.util.calendar.ZoneInfo.class
Comment 7 Jerome Lanneluc CLA 2007-05-31 13:19:06 EDT
(In reply to comment #6)
> Created an attachment (id=69489) [details]
> Profiler output with instance count
> 
> Interesting how many calls to the zip file(s) are needed to open
> sun.util.calendar.ZoneInfo.class

The profiler output shows that we iterate a list of 32000 zip entries. This is done in memory, we don't access the underlying file, so this has almost no cost. This is done the first time the source mapper for this jar is used. Opening another .class file with no source in the same jar won't go in this code.
Comment 8 Dani Megert CLA 2007-06-01 02:07:02 EDT
>Opening another .class file with no source in the same jar won't go in this
>code
Yes, that's also what I saw.
Comment 9 Jerome Lanneluc CLA 2007-06-20 10:11:01 EDT
The buffer is cached at the JDT/Core level. There is no eveidence that getting the buffer from the cache slows things down. Nothing more can be done.