This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 104776 - Contention between "switch to branch" and java source model updates causes excessive delay
Summary: Contention between "switch to branch" and java source model updates causes ex...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Unsupported (show other bugs)
Version: 6.x
Hardware: Sun All
: P2 blocker (vote)
Assignee: Tomas Zezula
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2007-05-24 22:59 UTC by _ pcw
Modified: 2009-06-30 18:01 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dump 1/2 way through (33.40 KB, text/plain)
2007-05-24 23:01 UTC, _ pcw
Details
threaddump 3/4 way through. (21.76 KB, text/plain)
2007-05-24 23:01 UTC, _ pcw
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ pcw 2007-05-24 22:59:00 UTC
I had a netbeans module w/ uncommitted changes on branch A.  I used CVS | Switch
to Branch to switch over to branch B (while keeping my changes of course).

Had I used command line CVS, this would have taken about 1-2 minutes.  Switching
back to the IDE and waiting for it to resync the java model would have taken a
few seconds at most.

But inside the IDE, this action took about 1.5 hours.  It appears to be resource
contention of some kind between the cvs update code and the java source model
update code.  It may even be worse (e.g. full java source model update performed
after each updated file).

Regardless, it renders this IDE action utterly unusable.
Comment 1 _ pcw 2007-05-24 23:01:13 UTC
Created attachment 42755 [details]
thread dump 1/2 way through
Comment 2 _ pcw 2007-05-24 23:01:50 UTC
Created attachment 42756 [details]
threaddump 3/4 way through.
Comment 3 _ pcw 2007-05-24 23:04:01 UTC
I happened to grab a couple of thread dumps while this action was running. 
Maybe the will help in fixing it.

Also, I would assume that many other block CVS operations might suffer from
this, in particular Merge Changes, but possibly Update and others.
Comment 4 _ rkubacki 2007-05-25 07:22:56 UTC
Marking with keyword.
Comment 5 Maros Sandor 2007-05-25 09:14:13 UTC
I can see from your stack traces that in both cases CVS is updating (merging)
changes to affected files and java/source and java/project modules are listening
for changes in those files. In CVS there is little to improve since the files
just have to be changed. Reassigning to java for evaluation.
Comment 6 rmatous 2007-05-25 09:35:33 UTC
/cvs/autoupdate/ui/src/org/netbeans/modules/autoupdate/ui/Bundle.properties,v 
new revision: 1.17; previous revision: 1.16

/cvs/autoupdate/ui/src/org/netbeans/modules/autoupdate/ui/UnitTab.form,v  <-- 
new revision: 1.9; previous revision: 1.8

/cvs/autoupdate/ui/src/org/netbeans/modules/autoupdate/ui/UnitTable.java,v  <--
 new revision: 1.7; previous revision: 1.6

/cvs/autoupdate/ui/src/org/netbeans/modules/autoupdate/ui/UnitTab.java,v  <-- 
new revision: 1.20; previous revision: 1.19
Comment 7 rmatous 2007-05-25 10:20:07 UTC
Sorry, my commit mentioned in my last comment wasn't intended to fix this issue.
So, reopening again.
Comment 8 Jan Lahoda 2007-06-18 16:42:16 UTC
Maybe CVS writes file by file and Java tries to parse them one-by-one (incl. dependencies)? Would be probably better if
we could process the files once after the checkout finishes.
Comment 9 Tomas Zezula 2007-06-18 19:04:13 UTC
The problem is that CVS fires change file by file, java module cannot expect that CVS will change another file in some
reasonable time frame. To make this issue fixable on the java side the CVS has to do the update inside the atomic
action. Change the update to use an  atomic action and reassign it back I will do the rest. Thanks.
Comment 10 Maros Sandor 2007-07-19 09:13:38 UTC
Citing from AtomicAction javadoc "the action should not take a significant amount of time, and should finish as soon as
possible". CVS Updates can take *huge* amount of time and there may be lot of file operations involved. However, I
experimented running CVS actions inside an AtomicAtion wrapper but this is causing trouble because we selectively turn
filesystem event handling on and off during the update operation and this approach cannot be applied if all events
should come at once. I suggest you just schedule the compiler so that it does not react to change events as they happen.
Comment 11 Tomas Zezula 2007-07-19 09:46:09 UTC
The compiler has to react to events. The only one who knows about the update (producing successive events) is versioning
module. The compiler cannot be started when the versioning finished since it apparently doesn't know it. Event sliding
task doesn't work for versioning since there is no deterministic delay. Everyone causing events is responsible for the
granularity of them.
Comment 12 Maros Sandor 2007-07-19 10:24:39 UTC
Are you saying that any module that may be modifying "more than expected" number of java files has to wrap all its code
into FileSystem.AtomicAction just to make java parser usable? 
Responsibility is on the listener side, event producers have no idea who may be listening and what listeners do in
response. If you are unable to process events on the fly then do NOT listen to them or stack them for later processing.
We may continue offline if you still think CVS is to blame.
Comment 13 Tomas Zezula 2007-07-19 12:27:26 UTC
This is exactly what the java parser is doing, it do update in another thread after some timeout. The problem with CVS
update is unpredictability of the events. The only one who knows about the start and end of the CVS update is cvs
module, right? So, it either has to delay the events and fire them after the update or it should provide API to notify
about the cvs end.
The general comments about the events production: It is responsibility of the event producer to produce the reasonable
number of events since there may be clients which cannot be performed asynchronously.
Comment 14 Maros Sandor 2007-07-23 14:31:51 UTC
Reassigning back.
What can be done in CVS is to stop using FileObject for all file operations during CVS actions - this could lead to
problems if some modules rely on filesystem notifications.
Comment 15 Petr Hrebejk 2007-07-27 17:09:43 UTC
I support Tomas Z. It is complete nonsense that this can be hanled on the side of java parser. If there is a branch
switch in a module lot other modules depend on and when the CVS operation is firing after arbitrary time one event after
other the parser will have to update all the dependent projects all the time. If java gets no info from CVS then it
hardly can do anything about it. And even if there would be some ugly way how to workaround this issue then it would
have  to be done not only in Java but in all modules which need to update something after a file change. The mechanism
should obviouy rather be implemented in one place (CV, FileSystems) rather than in every listener.
Comment 16 Tomas Zezula 2007-07-30 10:38:38 UTC
We agreed with Maros to track this issue on the java side.
Comment 17 Jan Lahoda 2007-08-29 12:48:53 UTC
I have implemented events coalescing into the RepositoryUpdater (see issue #110171), which should ensure that if many
files are changed fast, they will be compiled using one instance of the parser (per source root, of course). This should
lead into much better performance in this case too. Could someone test it? Thanks.
Comment 18 Tomas Zezula 2009-06-30 18:01:29 UTC
As far as I remember Jarda had promised an API to signal a start and an end of related events like VCS update.