Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342425 - High amount of idle work done by StructuredRegionProcessor
Summary: High amount of idle work done by StructuredRegionProcessor
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.sse (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 M7   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2011-04-11 08:17 EDT by Patric Rufflar CLA
Modified: 2011-04-19 17:30 EDT (History)
1 user (show)

See Also:


Attachments
patch (8.05 KB, patch)
2011-04-12 17:55 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Patric Rufflar CLA 2011-04-11 08:17:28 EDT
Build Identifier: 3.2.3

It seems that WTP is doing some work even if the user does nothing.
This can be seen the debug console:

2011-04-11 12:09:06,665 [           Worker-66] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:07,212 [           Worker-50] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:07,759 [           Worker-36] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:08,305 [           Worker-47] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:08,852 [           Worker-68] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:09,399 [          Worker-106] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:09,946 [           Worker-89] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
2011-04-11 12:09:10,493 [           Worker-91] DEBUG      JobStatsManager - ignoring job: org.eclipse.wst.sse.ui.internal.reconcile.StructuredRegionProcessor
...

The situation gets worse for each jsp file which is opened - this will cause a new StructuredRegionProcessor to do some work (even on idle).

As an result - if many jsp editors are open - eclipse has to spawn many worker threads which have to be created, managed and synchronized and may cause additional delays.

And BTW: Please avoid calling Thread.setPriority() for short running tasks (like StructuredRegionProcessor) - it's an expensive operation.
As a consequence that WTP is fighting with the Eclipse Worker Pool which resets the thread priority back to normal so both the jvm and the OS are kept busy with changing thread priorities.
(ca. 10% CPU usage on my machine using the steps below)

Reproducible: Always

Steps to Reproduce:
1. Open 100 different (mid-sized) jsp files simultaneously 
2. Look at debug log, cpu usage, synchronization effort, number of workers
3. Work with eclipse - you see that it's some kind of "handicapped" and slower.

If you have a chance, try this on a single core machine, the situation gets even worse there.
Comment 1 Nick Sandonato CLA 2011-04-12 16:43:20 EDT
Hi Patric,

Thanks again for your continued investigation into Source Editing.

Each of these instances of StructuredRegionProcessor is a reconciler for the opened editor. So the number of threads you see is to be expected. When opening 100 editors all at the same time, each editor performs its initial reconciling of the document to generate things like spelling annotations, as-you-type validation errors, and semantic highlighting. But, we definitely don't want to do work when there's nothing to do be done. So after that initial pass, each reconciling thread needs to check to see if any work has been add to its queue. As long as nothing's been modified in the document, the job is just rescheduled. I believe this is what you see as heavy-weight in this: the constant rescheduling.

So I think we might be able to go at this by trimming some of the fat, and going with a Thread implementation similar to AbstractReconciler's BackgroundThread.

While I understand the aggravation from this, I'm toning down the severity based on the Eclipse bugzilla definition of 'critical'.
Comment 2 Nick Sandonato CLA 2011-04-12 17:55:38 EDT
Created attachment 193100 [details]
patch

Shot at a patch. With the BackgroundThread, I didn't notice any periodic spikes like would occasionally happen with the Job implementation.
Comment 3 Nick Sandonato CLA 2011-04-19 15:36:07 EDT
New Thread-based implementation checked into HEAD.
Comment 4 Patric Rufflar CLA 2011-04-19 15:41:18 EDT
Thank you, Nick.

Will the patch also be part of the upcoming 3.2.4 release?
Comment 5 Nick Sandonato CLA 2011-04-19 17:30:59 EDT
You're quite welcome, Patric.

I had not planned on releasing this to 3.2.4 as I felt the changes might be a little drastic for a maintenance release, especially being fairly late in the development of 3.2.4.