Bug 247986 - [batch][compiler] Option to have Batch Compiler cache jar files
Summary: [batch][compiler] Option to have Batch Compiler cache jar files
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2008-09-19 11:28 EDT by Eliot CLA
Modified: 2011-03-29 09:15 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 Eliot CLA 2008-09-19 11:28:50 EDT
We're using the batch compiler and would like an option to cache jar files.

We know that during the running of our system, the relevant jar files do not change at all, but take a considerable amount of the compilation time.

Is there an option for caching them?  If not, how hard would it be to add and where might it go?
Comment 1 Philipe Mulet CLA 2008-09-19 14:50:30 EDT
Are you running several instances of the compiler in a row with the same JVM ? Are you customizing any of the compiler (internal) API, such as the name environment ?
Comment 2 Eliot CLA 2008-09-19 15:04:38 EDT
Yes.

We create 1 Main object and call compile over and over in the same JVM.

We haven't done any customization yet.


Comment 3 Philipe Mulet CLA 2008-10-06 13:10:34 EDT
Would be good if we could come up with a strategy benefitting also the Java builder scenario (could be unrelated).
Comment 4 Kent Johnson CLA 2008-10-07 14:01:34 EDT
How did you measure the amount of time to read the jar files ?

How many files are passed to the batch compiler each time its called ?

Are any the files repeated in another call later or are they only compiled once ?
Comment 5 Eliot CLA 2008-10-07 15:08:20 EDT
The measurement came from a rough profiler we have.

We only pass 1 file at a time to the compiler.

Once a file is compiled, its never compiled again.

Comment 6 Kent Johnson CLA 2008-10-07 15:21:19 EDT
I'm curious now... why only 1 file at a time?

What percentage of the compile time did reading the jar files take?


Reading the same jar files would not be much of an issue if you passed 100-1000 files to the batch compiler at a time.

Is there a reason that you only pass 1 file at a time?
Comment 7 Eliot CLA 2008-10-07 15:49:44 EDT
Its 1 file at a time because the compilation is kind of iterative.
We don't know what files we're going to need next until we compile the first one.

jar reading is about 40% of the total compilation time.

It might be theoretically possible to re-architect so we could compile more than 1 file at once, but I'm not sure.
Comment 8 Kent Johnson CLA 2008-10-07 16:46:50 EDT
> Its 1 file at a time because the compilation is kind of iterative.
> We don't know what files we're going to need next until we compile the first
> one.

But if the first file references 10 other classes, then we must compile all of their files at the same time, so there is no point recompiling those 10 files. And if those 10 additional files need 50 other classes... and so on.

The batch compiler notices when a requested type's source file has been changed more recently than its .class file & recompiles the source file. In other words, we do not use old .class files when the source file has been updated.

How many .class files are created when you compile your first type?

If your first type is a major type with references to numerous other types, then its possible that most files were compiled when the first source file was given to the batch compiler.
Comment 9 Kent Johnson CLA 2008-10-10 12:36:20 EDT
So how many .class files are created when you compile your first type ?

Can you please explain why you need to compile each file individually ?
Comment 10 Kent Johnson CLA 2008-10-17 14:10:57 EDT
So do you still need to compile each file individually ?

Or can we close this since you're now compiling more files at once ?
Comment 11 Eliot CLA 2008-10-17 14:43:39 EDT
We still often need to compile files individually.
For example if a single file changes (which happens often) we need to just compile that one file and would like it to be as fast as possible.
Comment 12 Kent Johnson CLA 2008-10-17 14:50:25 EDT
But changing & compiling 1 file will not benefit from a jar cache, unless you're going to keep the batch compiler instance around forever.

And that is definitely not recommended since it can hold onto quite a bit of memory.
Comment 13 Eliot CLA 2008-10-17 14:52:27 EDT
right - we understand that.

for our application its better for us to use that memory to save compilation time. 
Comment 14 Mike Wilson CLA 2009-05-05 10:55:03 EDT
Changing Version tag to something more believable. Note that this is not a statement about when the enhancement request will be addressed (the Target Milestone field is used for that); the Version tag should be set to the version of Eclipse you were using when you saw the need for the enhancement.