Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 121692 - Resource change takes ~1 min
Summary: Resource change takes ~1 min
Status: CLOSED FIXED
Alias: None
Product: WTP ServerTools
Classification: WebTools
Component: jst.server (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows XP
: P2 blocker with 7 votes (vote)
Target Milestone: 1.0.1 M101   Edit
Assignee: Tim deBoer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 121484 121603 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-12-21 02:00 EST by Igor Fedorenko CLA
Modified: 2017-10-11 15:56 EDT (History)
21 users (show)

See Also:


Attachments
suggested improvement for J2EEFlexProjDeployable (4.57 KB, patch)
2005-12-22 15:14 EST, Igor Fedorenko CLA
no flags Details | Diff
suggested improvement for ComponentDeployable (2.36 KB, patch)
2005-12-22 15:20 EST, Igor Fedorenko CLA
no flags Details | Diff
suggested improvements for VirtualContainer and VirtualFile (9.55 KB, patch)
2005-12-22 15:43 EST, Igor Fedorenko CLA
no flags Details | Diff
Performance improvements (4.34 KB, patch)
2005-12-22 15:58 EST, Chuck Bridgham CLA
no flags Details | Diff
Revised patch for ComponentDeployable (2.35 KB, patch)
2005-12-22 16:33 EST, Igor Fedorenko CLA
no flags Details | Diff
sample projects (154.77 KB, application/octet-stream)
2005-12-27 04:47 EST, Igor Fedorenko CLA
no flags Details
Revised patch for ResourceTreeNode (4.32 KB, patch)
2005-12-27 04:58 EST, Igor Fedorenko CLA
no flags Details | Diff
Suggested improvements for ServerPublishInfo#save() (1.64 KB, patch)
2005-12-27 05:08 EST, Igor Fedorenko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Fedorenko CLA 2005-12-21 02:00:05 EST
Steps to reproduce: fresh workspace, disable validation, create Tomcat 5.5 runtime and server config, disable autopublish (otherwise bug 121603), import "war" attached to bug 119146, fix "war" project build path problem ;-) and add the project to the tomcat server. Create "test.txt" file in war/WebContent directory. Problem: UI completely frezzes for about a minute on my T42 with CPU 100%. Same freeze happens if when I edit/save test.txt file.

WTP 1.0RC5, WinXP SP2, IBM JDK 1.4.2.

I did not have much time to look at this problem tonight, but J2EEFlexProjDeployable#members invoked during ServerPublishInfo#hasDelta seems to be causing the delay.

RC4 did not have this problem and I can't think of a workaround even from my server plugin, hence "Blocker"
Comment 1 Neil Anderson CLA 2005-12-21 05:00:29 EST
I am experiencing this problem with RC5 also. With the target server as Tomcat (4.1 and 5.0) my PC hangs with javaw.exe taking 100% of CPU. This occurs after tomcat server has been started and any code is changed. The build process hangs on the Invoking Validation task.

My environment is WTP 1.0RC5, Win XP SP2 and sun JDK 1.4.2_10.

I would regard this as a show stopper as development is impossible with tomcat as the target server. Note I did not see the problem with OC4J as my target server.
Comment 2 Tim deBoer CLA 2005-12-21 09:12:30 EST
Moving bug since this appears to be a performance regression in J2EEFlexProjDeployable.members()
Comment 3 Arthur Ryman CLA 2005-12-21 14:36:27 EST
Added to Hot List at the request of Tim deBoer and set priority to P2. Targetting to 1.0.1.
Comment 4 Igor Fedorenko CLA 2005-12-21 16:20:57 EST
The problem is caused by O^2 algorithm in ...common.componentcore...VirtualContainer#members, so I guess there are more scenarios that are broken for large workspaces.
Comment 5 Igor Fedorenko CLA 2005-12-22 12:23:32 EST
Looked some more. I am now 99% sure that the problem was triggered by the fix for bug 120562 which added IVirtualFolder#members() call to J2EEFlexProjDeployable#members(). IVirtualFolder#members has few (i.e. more than two) places with extremely inefficient nested iterations over list of files in a folder. Will try to speed it up.
Comment 6 Igor Fedorenko CLA 2005-12-22 15:14:50 EST
Created attachment 32156 [details]
suggested improvement for J2EEFlexProjDeployable

Very expensive J2EEProjectUtilities.getSourceContainers(IProject) was called for every file in J2EEFlexProjDeployable during execution of J2EEFlexProjDeployable#members(). Fix is to cache java source folder paths for duration of J2EEFlexProjDeployable#members().
Comment 7 Igor Fedorenko CLA 2005-12-22 15:20:11 EST
Created attachment 32157 [details]
suggested improvement for ComponentDeployable

Replaced nested loops with HashSet when adding ModuleResources to ModuleFolder
Comment 8 Igor Fedorenko CLA 2005-12-22 15:43:03 EST
Created attachment 32158 [details]
suggested improvements for VirtualContainer and VirtualFile

Reworked VirtualContainer#members(int) to avoid use of nested loops for filtering of non-unique children. Note that new implementation may behave somewhat different for "fuzzily" matching components (i.e. component with /a/b/c/d runtimePath in /a virtual folder) as I did not completely understand intent of original code.

Changed VirtualFile to cache underlying IFile.
Comment 9 Chuck Bridgham CLA 2005-12-22 15:54:57 EST
Comment on attachment 32156 [details]
suggested improvement for J2EEFlexProjDeployable

Removing this patch - this caching is not needed with my new patch.
Comment 10 Chuck Bridgham CLA 2005-12-22 15:58:31 EST
Created attachment 32160 [details]
Performance improvements

This patch in addition to patch https://bugs.eclipse.org/bugs/attachment.cgi?id=32157&action=edit

Will greatly improve this scenario - these patches will be dropped to R101 stream soon after more testing
Comment 11 Igor Fedorenko CLA 2005-12-22 16:33:23 EST
Created attachment 32162 [details]
Revised patch for ComponentDeployable

Original patch did not always set ModuleFolder members, which resulted in this exception later on

!ENTRY org.eclipse.wst.server.core 4 0 2005-12-22 16:27:35.030
!MESSAGE Could not publish to the server.
!STACK 0
java.lang.NullPointerException
	at java.util.Arrays$ArrayList.<init>(Arrays.java:2356)
	at java.util.Arrays.asList(Arrays.java:2342)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getExistingModuleResource(ComponentDeployable.java:187)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getExistingModuleResource(ComponentDeployable.java:187)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getExistingModuleResource(ComponentDeployable.java:187)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getExistingModuleResource(ComponentDeployable.java:187)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getExistingModuleResource(ComponentDeployable.java:187)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getExistingModuleResource(ComponentDeployable.java:187)
	at org.eclipse.wst.web.internal.deployables.ComponentDeployable.getMembers(ComponentDeployable.java:129)
	at org.eclipse.jst.j2ee.internal.deployables.J2EEFlexProjDeployable.members(J2EEFlexProjDeployable.java:135)
	at org.eclipse.wst.server.core.internal.ServerPublishInfo.fill(ServerPublishInfo.java:232)
	at org.eclipse.wst.server.core.internal.Server$5.visit(Server.java:805)
	at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2173)
	at org.eclipse.wst.server.core.internal.Server.visitModule(Server.java:2184)
	at org.eclipse.wst.server.core.internal.Server.visit(Server.java:2157)
	at org.eclipse.wst.server.core.internal.Server.doPublish(Server.java:802)
	at org.eclipse.wst.server.core.internal.Server.publish(Server.java:788)
	at org.eclipse.wst.server.core.internal.PublishServerJob.run(PublishServerJob.java:145)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Comment 12 Igor Fedorenko CLA 2005-12-22 17:52:34 EST
I ran few tests to measure time spent filling ServerPublishInfo in Server#doPublish (I have special tomcat plugin that deploys webapps by reference, nothing is ever copied anywhere so filling server publish info is the only operation that takes noticable time. I verified that these results generally apply to regular tomcat plugin as well but obviously I was getting much bigger numbers).

(In reply to comment #9)
> (From update of attachment 32156 [details] [edit])
> Removing this patch - this caching is not needed with my new patch.
> 
This patch is important for my real workspace. Fill ServerPublishInfo in Server#doPublish takes ~15 seconds with this patch and ~45 seconds without it.


(In reply to comment #10)
> Created an attachment (id=32160) [edit]
> Performance improvements
With this patch, performance degrades grately with each publish. On my real workspace, it takes ~15 seconds to fill ServerPublishInfo for the first time, ~45 for the second time and I did not have enough patience to wait for the third execution to finish. This patch negates all performance gains for regular tomcat plugin -- second publish never completes.

Having all this said, ~15 seconds to fill ServerPublishInfo is way too much. I will try to create sample project(s) that better reflect performance problems that I see in my workspace. I will also try to see how to fix these problems.
Comment 13 Igor Fedorenko CLA 2005-12-27 04:47:23 EST
Created attachment 32256 [details]
sample projects

This set of projects has structure similar to my real workspace and shows same performance problems. Things to note: 

1) util0/src/.../pkg0 has 5000 classes.
2) .../src and .../gen have same packages (this triggers performance degradation I mention in comment #12)
3) many dependent "utiliy jar" projects
Comment 14 Igor Fedorenko CLA 2005-12-27 04:58:08 EST
Created attachment 32257 [details]
Revised patch for ResourceTreeNode

This is revised version of attachement #32160 (Performance improvements) which plugs ComponentResource leaks for projects that have multiple component resources with same runtimePath but different srcPath (multiple java source folders, for example).

There are however other problems with original patch that I could not solve so far:

Cached "transient" ComponentResources get persisted in .settings/.component. To
reproduce: publish "war" to tomcat, change java build path of util12 project and
remove "gen" java source folder. This has to be fixed 1.0.1 in my opinion.


I saw some weird behaviour that could be explained by stale ComponentResource. 
How does the cache get refreshed when new folders get added/removed? In any case, this has simple workaround -- restart WTP.

VirtualFile#getUnderlyingResource can return wrong IFile if two component 
resources have same runtimePath but different srcPath. One of my 0.7 migrated util jar projects has the following layout
	util/
	  src/ (java source folder, runtimePath: /)
	     foo.properties
	  test/ (NOT a java source folder, runtimePath: /)
For this project, J2EEFlexProjDeployable#members() sometimes return
/util/test/foo.properties. Note however, that this project layout is migration error and I do not know if there are legitimate layouts that will have the same problem.
Comment 15 Igor Fedorenko CLA 2005-12-27 05:08:56 EST
Created attachment 32258 [details]
Suggested improvements for ServerPublishInfo#save()

ServerPublishInfo#save() was called several times during Server#doPublish (once for each published module). This was taking noticable time for publishing 12k files in 23 modules.
Comment 16 Andreas Schildbach CLA 2006-01-03 04:56:58 EST
Is there any workaround for 1.0 users, other than downgrading to RC3? For now, WTP is rather unusable because of this bug. There should be a way to work around this bug before 1.01, which is more than a month away.
Comment 17 Neale Upstone CLA 2006-01-03 09:44:50 EST
Hi Andreas,

You have two choices here.  One is to downgrade to RC3 as you suggest, the other is to apply Igor and Chuck's patches.

I'd suggest RC3 is the least risky option, as we do know that it passes the existing unit test suite.

The other option is to apply the patches.  Igor sent me the compiled JARs, which I've tried on RC3 briefly, but did get resource deployment failures.  I haven't tried those JARs on a 1.0 build yet.

If you want the JARs, do email me, and I'll forward them on.
Comment 18 Chuck Bridgham CLA 2006-01-03 10:31:50 EST
*** Bug 121603 has been marked as a duplicate of this bug. ***
Comment 19 John Lanuti CLA 2006-01-04 11:46:24 EST
Ok, I have investigated the patchs provided here and made sure the obsolete ones were obsoleted in the defect.  From J2EE tooling, there are three patchs now attached to this defect.  After applying these patchs and running through functional tests, the members method on the deploy still functions properly.  Also, after running through profiling tools, the performance is exponentially better.  Thanks to Igor for the help in driving this defect towards resolution.  

The J2EE parts of this defect are released and will be committed for the next committers 1.0.1 WTP driver tonight on 1/04/06.

Tim, I will reassign to you for investigation into the ServerPublishInfo piece.

Once Tim's work is complete, for clarity sake, I propose any additional nuances or problems be opened as a new defect.
Comment 20 Tim deBoer CLA 2006-01-04 15:26:07 EST
Patch to ServerPublishInfo is technically unrelated to this performance regression and just a smart optimization to improve on the previous performance. Igor's patch is good and I've checked it into HEAD. Will tag for 1.0.1 shortly.
Comment 21 Tim deBoer CLA 2006-01-04 18:08:23 EST
Released for next 1.0.1 build.
Comment 22 Jerry W. CLA 2006-01-10 21:25:10 EST
Thanks and Thanks,

I have been very patient with the this slow performance of Eclipse where I have to wait 'Publishing to Tomcat' takes much longer than 0.7.1.

My machine is AMD 64 3500+ with 1GB RAM, fedora core 4 x86_64. Every time I open Eclipse, it takes more than 1 minute to finish publishing.

I almost change to Netbeans since I can't stand with this slow performance. But I still like Eclipse.
Comment 23 Chuck Bridgham CLA 2006-01-11 09:15:24 EST
Hi Jerry,

just to make sure - have you confirmed this issue is fixed with a recent M driver?

http://download.eclipse.org/webtools/committers/drops/M-M200601102004-200601102004/ 

If you are still seeing issues let us know.
Comment 24 John Lanuti CLA 2006-01-11 09:26:19 EST
*** Bug 121484 has been marked as a duplicate of this bug. ***
Comment 25 David Sanders CLA 2006-02-13 11:40:08 EST
Does this fix also speed up ear exports such as those targeting Weblogic 8.1?
Comment 26 Igor Fedorenko CLA 2006-06-26 22:55:09 EDT
verified
Comment 27 Tim deBoer CLA 2006-06-27 16:58:48 EDT
Closing.
Comment 28 Eclipse Genie CLA 2017-10-11 15:56:08 EDT
New Gerrit change created: https://git.eclipse.org/r/107648