Bug 33950

Summary: Slow performance when changing code in a much referenced project
Product: [Eclipse Project] JDT Reporter: Boris Pruessmann <boris>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.1   
Target Milestone: 2.1 RC3   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Boris Pruessmann CLA 2003-03-06 05:33:37 EST
I2003-02-14

I have a project that is referenced by many other projects (like 
org.eclipse.resource). If I make changes to a class within this project and 
save them, it takes quite a (annoying) long time for Eclipse to compile this 
class. The class itself is only used within the project itself.

Metrics: Saving sourcecode in the specific project results in a lot 
of "Reading resource change information" message. The whole process takes 
11seconds on a 1,7GHz P3. Eclipse is started with -Xmx256M, so it's not GC 
issue (the process has taken only half on the memory). There is no output in 
the log file.
Comment 1 Philipe Mulet CLA 2003-03-06 07:29:18 EST
You may want to enable the Java builder trace to indicate which types got 
recompiled, and why it thought it needed to.

Add the following to your .options file (next to eclipse executable):

org.eclipse.jdt.core/debug=true
org.eclipse.jdt.core/debug/builder=true
Comment 2 Boris Pruessmann CLA 2003-03-06 07:46:52 EST
Doesn't reveal anything useful (imho). A lot of :

  Starting build of <project> @ Thu Mar 06 13:36:40 CET 2003
  About to read state...
  Successfully read state for <project>
  Nothing to build since deltas were empty
  Finished build of <project> @ Thu Mar 06 13:36:41 CET 2003

However, the timestamps indicate that everything took more than 10s. No entry 
takes especially long. Aynthing more I can do?
Comment 3 Kent Johnson CLA 2003-03-06 10:38:40 EST
Yes please run your test twice. The first pass needs to read build states and 
will take some time (if your workspace is large).

The trace from the second pass will show which types/files need to be rebuilt.
Comment 4 Boris Pruessmann CLA 2003-03-06 11:11:25 EST
Same result. Detected one change in first run and one in second run. On first 
run, the build states were loaded. First run took 12s, second run (without 
loading of state) took 10s. There were 48 projects that directly depended on 
the project that was changed. However, the class is not referenced in any of 
those.
Comment 5 Kent Johnson CLA 2003-03-06 11:17:15 EST
From the trace, where is the 10 seconds? Can you add the trace as an attachment?

How large is the source file?
Comment 6 Boris Pruessmann CLA 2003-03-06 12:47:18 EST
Source file has less than 1000 lines, the ten seconds seem to be equally spend on all the dependend projects. That said, 10 seconds for 48 dependent projects means 200ms per project. That doesn't sound too bad...
Comment 7 Kent Johnson CLA 2003-03-06 12:58:51 EST
Actually 200 ms per project when they have nothing to compile is fairly bad.

Is your workspace stored on a network drive? Or is your jdk install stored on a 
network drive?
Comment 8 Boris Pruessmann CLA 2003-03-06 13:03:55 EST
Nope. Both are stored on local NTFS volumes. Workspace is stored outside of the Eclipse installation directory (-data), virus scanner is not active (not even running). 
Comment 9 Kent Johnson CLA 2003-03-06 13:24:21 EST
What's the TaskManager tell you... is your machine maxed out for the entire 10 
seconds? How's the memory consumption?

Anything else running on your machine?
Comment 10 Kent Johnson CLA 2003-03-06 13:57:01 EST
To give you some idea of our 'normal' performance, I have a workspace with all 
of the Eclipse drop from source. That's over 60 projects.

A simple change to a source file in the core.resources plugin (numerous 
dependent projects) takes less than 2 seconds.
Comment 11 Boris Pruessmann CLA 2003-03-07 03:55:46 EST
Making some investigations (filemon) revealed that Eclipse is touching a lot 
of JAR files within the JDK directory. That brought into my mind that I have 
set JDK 1.4.1_02 as default JDK within Eclipse, resulting in 9 files (27MB) 
within its system library path. I cross checked with JDK 1.3.1_07 (3 files, 
17MB) and compiling took .... about 1-2 seconds. Also verified that after 
switching back to JDK 1.4.1 it still takes 10 seconds.

JDK 1.3.1_07 ....... 1-2s
JDK 1.4.1_02 ....... 10s

(timings taken from the debug output)

Comment 12 Kent Johnson CLA 2003-03-07 16:07:36 EST
Submitted fix for consideration in the RC3 build.

While initializing the classpath for each project, we were recomputing 
classpath error markers for referenced projects instead of relying on the fact 
that error markers were already computed for their classpath.
Comment 13 Philipe Mulet CLA 2003-03-07 17:55:36 EST
Good find. This code should never create markers, it is only supposed to get 
output contributions from a prereq project.

One more thing, I think it should be: IClasspathEntry[] prereqClasspathEntries 
= prereqJavaProject.getRawClasspath();

Indeed, outputs are never exported across projects (they belong to each 
project) thus no need for an expanded classpath.
Next, no source folder can be specified through variables/containers, thus a 
source folder can only occur inside a raw classpath (we do similar assumption 
in JavaModel already).

Comment 14 Philipe Mulet CLA 2003-03-07 18:22:01 EST
Kent - please double check the version I just released.
Comment 15 Kent Johnson CLA 2003-03-10 10:52:51 EST
Looks good.
Comment 16 David Audel CLA 2003-03-19 07:44:28 EST
Verified.