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 29004

Summary: Unnecessary parsing of templates in Java module
Product: java Reporter: _ tboudreau <tboudreau>
Component: UnsupportedAssignee: Svata Dedic <sdedic>
Status: VERIFIED FIXED    
Severity: blocker CC: raccah, tpavek
Priority: P3 Keywords: PERFORMANCE
Version: -S1S-   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 34165    
Attachments: Patches for Java module. Note also needed is patch for 29001.

Description _ tboudreau 2002-11-25 20:09:07 UTC
When a node is created for a Template, a
SourceCookie is requested as part of
checkUpToDate().  This forces a lot of
classloading if the Java module's classes are not
already loaded.  The attached patch eliminates
this, on the assumption that the up-to-date check
is not useful for templates.  Note this disables
icon badging for template DataObjects as well. 
Probably not a bad idea.
Comment 1 _ tboudreau 2002-11-25 20:10:00 UTC
Setting component correctly to Java module.
Comment 2 Svata Dedic 2002-11-26 05:46:16 UTC
Could you please attach those patches for JavaDataObject / JavaNode ?
Comment 3 Svata Dedic 2002-11-26 06:19:42 UTC
Tim, I did not see checkUpToDate() in stacktraces when I checked where
the parser is requested from. Maybe it is hidden by the other issues
(eager instantiation of cookies et al) - could you attach the
stacktrace, please ? SourceCookie should not be queried for at all
during checkUpToDate() [IMHO].

These classes are loaded apparently as a part of parsing subsystem
initialization (upon SourceCookie request):

[Loaded org.netbeans.modules.java.parser.JavaParser$Env]
[Loaded org.netbeans.modules.java.codegen.DocumentBinding$Env]
[Loaded org.netbeans.modules.java.model.LangModel$Env]
[Loaded org.netbeans.modules.java.JavaParserGlue]
[Loaded java.io.CharArrayReader from
/usr/lib/java/jdk1.3.1/jre/lib/rt.jar]
[Loaded org.netbeans.modules.java.model.BindingFactory]
[Loaded org.netbeans.modules.java.codegen.DocumentBinding]
[Loaded org.netbeans.modules.java.model.ElementCreator]
[Loaded org.netbeans.modules.java.model.LangModel]
[Loaded org.netbeans.modules.java.model.LangModel$Updater]
[Loaded org.netbeans.modules.java.codegen.SourceText]
[Loaded org.openide.src.SourceException$Protection]
[Loaded org.openide.src.SourceException$IO]
[Loaded org.netbeans.modules.java.model.Binding]
[Loaded org.netbeans.modules.java.model.Binding$Source]
[Loaded org.netbeans.modules.java.model.Binding$Import]
[Loaded org.netbeans.modules.java.model.Binding$Body]
[Loaded org.netbeans.modules.java.model.Binding$Initializer]
[Loaded org.netbeans.modules.java.model.Binding$Member]
[Loaded org.netbeans.modules.java.model.Binding$Container]
[Loaded org.netbeans.modules.java.model.Binding$Class]
[Loaded org.netbeans.modules.java.model.Binding$Method]
[Loaded org.netbeans.modules.java.model.Binding$Field]
[Loaded org.netbeans.modules.java.parser.LangEnvImpl]
[Loaded org.netbeans.modules.java.model.WrapperFactory]
[Loaded org.netbeans.modules.java.parser.DefaultWrapper]
[Loaded org.netbeans.modules.java.model.DefaultLangModel]
[Loaded org.openide.src.Element$Impl2]
[Loaded org.netbeans.modules.java.model.ElementEvents]
[Loaded org.netbeans.modules.java.model.ElementImpl]
[Loaded org.netbeans.modules.java.model.MemberElementImpl]
[Loaded org.netbeans.modules.java.model.ElementOrder]
[Loaded org.netbeans.modules.java.model.ClassElementImpl]
[Loaded org.netbeans.modules.java.model.SourceElementImpl]
[Loaded org.netbeans.modules.java.model.ImportElement$Impl]
[Loaded org.netbeans.modules.java.model.ImportImpl]
[Loaded org.openide.src.InitializerElement$Impl]
[Loaded org.netbeans.modules.java.model.InitializerElementImpl]
[Loaded org.openide.src.ConstructorElement$Impl]
[Loaded org.netbeans.modules.java.model.CallableImpl]
[Loaded org.netbeans.modules.java.model.ConstructorElementImpl]
[Loaded org.openide.src.MethodElement$Impl]
[Loaded org.netbeans.modules.java.model.MethodElementImpl]
[Loaded org.openide.src.FieldElement$Impl]
[Loaded org.netbeans.modules.java.model.FieldElementImpl]
[Loaded org.netbeans.modules.java.model.Positioner]
[Loaded org.netbeans.modules.java.model.DefaultInsertStrategy]
[Loaded org.netbeans.modules.java.model.EventQueue]
[Loaded org.netbeans.modules.java.parser.ParsingSupport]
[Loaded org.netbeans.modules.java.parser.ParsingSupport$FinishedTask]
[Loaded org.netbeans.modules.java.parser.ParsingSupport$1]
[Loaded org.netbeans.modules.java.ParserEngine]
[Loaded org.netbeans.modules.java.gj.JavaParserEngine]
[Loaded org.netbeans.lib.javac.v8.code.ClassReader$SourceCompleter]
[Loaded org.netbeans.modules.java.gj.V8EngineBase]
[Loaded org.netbeans.lib.javac.v8.code.ClazzCompleter]
[Loaded org.netbeans.modules.java.gj.ParserEngine]
[Loaded org.netbeans.modules.java.gj.DeepParserEngine]

Possibly the ParserGlue/ParsingSupport could be split somehow (?) so
they do not initialize so much junk until parse request is posted.

Still I think there's something terribly fishy. It seems that classes
are aggressively linked when loaded - it did not seem the case with
HotSpot previously (e.g. code was incrementally linked along the
execution path)
Comment 4 _ tboudreau 2002-11-26 09:24:12 UTC
Created attachment 8051 [details]
Patches for Java module.  Note also needed is patch for 29001.
Comment 5 _ tboudreau 2002-11-26 09:29:15 UTC
Sorry, patches attached now.  You'll want the patch for issue 29001 as
well.  The result of these patches is that if isTemplate() is true,
the only cookies ever asked for on the JDO are DataObject or
JavaDataObject (eliminate the parser stuff, compiler stuff, etc.).

I left some commented code in PrimaryListener for generating
stack traces.  If you run with 
-J-Dorg.openide.util.RequestProcessor.Item.SLOW=true 
you can see what is firing events.

Mainly you'll see it called by changes in PROP_FILES.  If you also
apply the patches to MultiDataObject, PROP_FILES is no longer fired
during DataObject creation, but only if the files actually change later.
Comment 6 Tomas Pavek 2003-01-29 17:07:52 UTC
Isn't this useless if we are going to impelement issue 28623 (lazy
templates)?
Comment 7 Svata Dedic 2003-01-30 09:04:01 UTC
 I don't think it is totally useless; for templates  
it is indeed ridiculous to check for up-to-date  
state. Tim, did you run the testsuites to verify  
that the lazy attachment of SourceElement to  
SourceChildren does not break something ?  
Comment 8 _ tboudreau 2003-01-30 09:38:25 UTC
Svata, no I didn't run the test suites - if you can tell me where
to find it and what to run, I'll be happy to.
Comment 9 Svata Dedic 2003-01-30 11:19:06 UTC
Fixed; there may be some sideeffects, while normal  
operations are all OK, the node may not report  
changes to its contnents until parsed for the first  
time (since it does not hook to the parser during  
init). 
 
Fixed in trunk -- 
/cvs/java/src/org/netbeans/modules/java/JavaDataObject.java,v  
<--  JavaDataObject.java 
new revision: 1.166; previous revision: 1.165 
/cvs/java/src/org/netbeans/modules/java/JavaNode.java,v  
<--  JavaNode.java 
new revision: 1.93; previous revision: 1.92 
 
Comment 10 Jan Becicka 2003-03-10 15:26:58 UTC
Tim, could you verify it? Thanks
Comment 11 Jan Becicka 2003-04-16 16:36:16 UTC
VERIFIED