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 40214 - Excessive parsing when swittching between editors
Summary: Excessive parsing when swittching between editors
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Editor (show other bugs)
Version: 3.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jan Pokorsky
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2004-02-18 12:39 UTC by _ rkubacki
Modified: 2004-03-02 14:43 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ rkubacki 2004-02-18 12:39:15 UTC
This is what Mila found when he was debugging editor:
Reparsing upon Alt+Right/Left

Having several files openend in the IDE I was
wondering why repetitive Alt+Right/Left "hangs"
for a while especially for large files such as
JTable or JComponent. I was suspect that there is
some parsing in the background going on and
surprisingly there really is. It's in
JavaEditor.JavaEditorComponent.componentActivated()

Although there is some additional condition for
initiating of the parsing reqeust, in my setup it
was parsing after each Alt+Right/Left even when
there were no apparent annotations present in the
file. When I removed the call to parseSource() the
Alt+Right/Left switching was noticeably smoother.

I can understand why the reparsing is being
requested there - e.g. if I reference a
non-existent method of some class C in my source
then the parser will create an error annotation in
my source. If I switch to class C and add that
non-existent method and then return back to my 
original source I wish the error annotation to be
removed even if I do not do any additional typing.
Still I think the parsing is relatively expensive
task to be done when changing the focus only so
IMHO there should be at least some more
sophisticated logic for initiating of the 
reparse (e.g. starting reparse once the user
spends at least second or two in the given source).

-Mila
Comment 1 Antonin Nebuzelsky 2004-02-18 17:24:14 UTC
Changing to P2. P-team decided to keep track of all significant
performance regressions as P2s.
Comment 2 Jan Pokorsky 2004-02-19 16:54:40 UTC
I'll investigate it.
Comment 3 Jan Pokorsky 2004-02-23 11:01:54 UTC
Here is what I have found out:

1. The issue relates to overriden annotations.

2. JavaEditor.JavaEditorComponent.componentActivated() - true, it can
invoke the parsing several times in case of large sources and
switching between editors. This can slowdown ide but not to block it
because the parser runs in background thread. I can solve this easily
with improved check in componentActivated() that will count on just
the 'hasAnnotation' property.

3. code handling overriden annotations is not properly synchronized so
some inconsistences may occur.

Since issues filed against this code become frequent I have decided to
rewrite it.
Comment 4 _ rkubacki 2004-02-23 12:28:29 UTC
Thanks. 

Ad threading: it is OK that runs in background but we know that even
if the process has low priority in Java it can occupy the processor
for a long time and cause bad perception. So if you can reduce the
amount of work it will be an improvement.
Comment 5 Jan Pokorsky 2004-02-24 21:34:26 UTC
Done.

1. Further editor component activations do not trigger parsing any more.
2. Introduced threading model.
3. I tried to minimize recreating of class elements by keeping them
via hard references. The editor releases all references on its close.
4. plus some minor fixes.

Despite all these changes computing of overriden annotations for newly
open files remains pretty expensive. It needs to create class elements
of all superclasses and interfaces which means to run the parser on a
lot of files. I am afraid that without some lightweight parser there
is not much place for futher improvements.

/cvs/java/src/org/netbeans/modules/java/JavaEditor.java,v1.151
/cvs/java/src/org/netbeans/modules/java/OverrideAnnotation.java,v1.3
/cvs/java/src/org/netbeans/modules/java/OverrideAnnotationSupport.java,v1.1


Comment 6 ehucka 2004-03-02 14:43:32 UTC
Could someone from performance team verified this issue?