Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 347973

Summary: Setting build path took 8 minutes
Product: [WebTools] WTP Webservices Reporter: Patric Rufflar <patric>
Component: jst.ws.jaxwsAssignee: Danail Branekov <danail.branekov>
Status: RESOLVED FIXED QA Contact: Shane Clarke <shane_clarke>
Severity: critical    
Priority: P3 CC: danail.branekov, keith.chong.ca, thatnitind
Version: unspecified   
Target Milestone: 3.4 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
thread dump
none
Profiling results which proves the problem
none
Test project with 500K LOC none

Description Patric Rufflar CLA 2011-06-01 12:05:34 EDT
Build Identifier: 3.2.4

I changed jdk version and server web runtime at once, clicked at OK.
Now Eclipse consumed 100% at one logical cpu and finished after 8 minutes.

I am not using webservices within my project, however, when looking at the thread dump, it seems that the AbstractModelSynchronizer is guilty for this.

Reproducible: Didn't try
Comment 1 Patric Rufflar CLA 2011-06-01 12:05:52 EDT
Created attachment 197110 [details]
thread dump
Comment 2 Patric Rufflar CLA 2011-06-01 12:23:56 EDT
Created attachment 197114 [details]
Profiling results which proves the problem
Comment 3 Keith Chong CLA 2011-06-02 13:56:45 EDT
This appears to be in jax-ws code:

org.eclipse.jst.ws.jaxws.dom.runtime.persistence.sync.AbstractModelSynchronizer.processCompilationUnit(AbstractModelSynchronizer.java:106)
Comment 4 Keith Chong CLA 2011-06-02 13:59:45 EDT
Patric, what jdk are you using?

Could you please provide more detailed steps on how to reproduce the problem?

You clicked OK in which dialog?
Comment 5 Patric Rufflar CLA 2011-06-02 16:37:48 EDT
Keith,

I am using the most recent JDK 6 Update 25 for running eclipse.
I openend the project properties in a dynamic web project, Java build path, changed to the libraries tab, and changed jdk from version 5 to jdk 6 and I changed the application server runtime from tomcat 5.5 to tomcat 6 and clicked at "OK".
Comment 6 Danail Branekov CLA 2011-06-03 05:00:33 EDT
Patric,

Is it possible to provide a sample project via which the issue can be reproduced? Do you have other projects in the workspace?

Thanks!

Regards, Danail
Comment 7 Nick Sandonato CLA 2011-06-09 14:04:14 EDT
*** Bug 347966 has been marked as a duplicate of this bug. ***
Comment 8 Keith Chong CLA 2011-06-09 18:03:10 EDT
Hi Patric, if possible, could you please attach your project or perhaps a reduced test case?
Comment 9 Keith Chong CLA 2011-06-15 18:21:00 EDT
Hi Danail/Shane, any updates on this?  From the profile results, could you figure out what is holding the workspace lock?
Comment 10 Danail Branekov CLA 2011-06-16 02:28:55 EDT
Hi Keith,
I was unable to reproduce the issue locally and that's why I asked for a sample project to play with
Looking and the thread dump and profiling results I would say that JAX-WS model updater spends quite some time building the syntax tree (AST) of compilation units. With regards to this I could assume that there are lots (like tens of thousands) of java classes in the workspace, or there are classes with huge content.
Or, alternatively, there might be some dramatic performance degradation in the AST parser but I don't think that this is the case

Regards, Danail
Comment 11 Keith Chong CLA 2011-06-16 14:23:31 EDT
Thanks Danail.   

Patric, could you please attach your project or workspace?
Comment 12 Keith Chong CLA 2011-07-14 16:09:13 EDT
Hi Patric,

Could you please tell us how many classes you have in your project and also if they are huge?  Danail, could you try creating one class and then copy/duplicate it many times to see if you can reproduce the problem?
Comment 13 Patric Rufflar CLA 2011-07-14 16:48:38 EDT
Hi Keith,

sorry that it took a while to answer.
Unfortunately I cannot provide the project on which I saw this issue.

It's a relativly large project, it consists of about 4000 classes with approx. 1 million lines of code. Some classes maybe larger (let's say up to 10000 source lines) but most of them should be around 200-2000 lines.
Comment 14 Shane Clarke CLA 2011-07-26 18:02:12 EDT
Created attachment 200403 [details]
Test project with 500K LOC

Attaching test project with 500K LOC (there's a limit on attachment sizes) to help reproduce the problem.

Can copy and paste the packages in the project to increase LOC.
Comment 15 Shane Clarke CLA 2011-07-28 14:19:20 EDT
Following the WTP Weekly status call i'm updating the target milestone and assignee for this. Assigning to you Danail.
Comment 16 Danail Branekov CLA 2011-08-01 11:56:50 EDT
Thanks for the sample project, Shane!

I have played around with a profiler and found out some interesting facts:
 1. The WS model load takes the same amount of time as pure java build. IMO this  indicates that model loading is in a good shape with regards to performance. After all, the load process needs to parse all compilation units in order to find whether there are web services
 2. The WS model is a memory one and therefore upon Eclipse start it needs to be loaded. This is implemented as a workspace job with workspace root as a scheduling rule in order to guarantee model consistency. Effectively, this means that upon startup the user has to wait as much time as it would take to perform a workspace clean build. BTW, Shane, this is the cause of the increased startup time you mentioned in a mail a couple of days ago
 3. The JDK change fires a project opened event which results in project compilation units being completely re-parsed. This is the root cause of the issue reported here

As a solution to (1), (2) and indirectly to (3) we could take the model load process out of a workspace job thus preventing the user from waiting in both eclipse start and JDK change use cases. Such a change however requires some time to implement.

Regarding (3) it is interesting to find out why JDK change fires "open project" event given that no projects are closed or opened.
Comment 17 Danail Branekov CLA 2011-08-16 11:22:53 EDT
I have updated the WS DOM load behaviour in HEAD and released the change as v201108161458

The new things are:
1. WS DOM is not loaded on eclipse startup
2. The model load is performed when requested for the first time via expanding the "JAX-WS Web Services" node in the project explorer. The very load process is performed in a background job which can be interrupted by the user
3. If the model load is interrupted, the load routine would be restarted when the user expands "JAX-WS Web Services" node again

Impact from users' pojnt of view:
 - The solution above provides that the Eclipse startup time is not increased by the model load
 - If the model is not loaded, changes in the projects are not handled by the WS model listener. As a result, changing the build path as Patric described would happen faster as WS model load will not take place

However, if the model is loaded (i.e. tracks changes in projects), changing the project classpath (via e.g. changing project JDK) would still cause the model reload. The reason for this is that a classpath change brings new project dependencies which invalidates the current model state and therefore model reload is required. A model reload takes approximately same amount of time as the one needed for a full project rebuild. 

Regarding point (3) of my previous comment - setting build path does not fire project-open event. The implementation of the resource change tracker in the DOM model enforces model reload via simulating project closed and then opened. 

Patric, do you think that this solution is OK for you? You can test it once a new WTP 3.4 integration build is available or you can simply checkout webtools/webservices code and test in a runtime workbench

Thanks!

Danail
Comment 18 Keith Chong CLA 2011-08-25 15:42:24 EDT
Hi Patric,

Could you please try out Danail's fix?
Comment 19 Shane Clarke CLA 2011-09-02 13:30:38 EDT
Marking as resolved. Fix released to HEAD and available in 3.4.0 builds.

http://download.eclipse.org/webtools/downloads/

Patrick if you're happy with the solution in the 3.4.0 build and need the fix in the 3.3.1 maintenance build could you please open a separate bugzilla for that?

Please do that soon if needed as we will need PMC approval to apply the fix in 3.3.1.