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 154324

Summary: Do not initialize Profiler until it is first used
Product: profiler Reporter: Jaroslav Tulach <jtulach>
Component: BaseAssignee: J Bachorik <yardus>
Status: RESOLVED FIXED    
Severity: blocker CC: issues, johnjullion
Priority: P3 Keywords: PERFORMANCE
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Attachments: Raw patch deferring initialization till an action is invoked
Modified JAR to let Alexander and Oleg measure potential gain of this change
Loaded Classes diff for 1st NetBeans startup
Loaded Classes diff for NetBeans startup with LimeWire

Description Jaroslav Tulach 2008-12-02 10:29:21 UTC
Currently ProfilerModule.restore() initializes the whole profiler infrastructure including various checks, spawning 
new threads, loading classes, etc. This was OK when profiler was just an add-on plugin, but since it is part of the 
standard distribution and because it is not used by majority of users (less than 30%, is my guess) and not all the 
time. It is desirable to defer such initialization till user clearly indicates an interest in the profiler itself.
Comment 1 Jaroslav Tulach 2008-12-02 10:30:54 UTC
Created attachment 74387 [details]
Raw patch deferring initialization till an action is invoked
Comment 2 Jaroslav Tulach 2008-12-02 10:34:31 UTC
Created attachment 74388 [details]
Modified JAR to let Alexander and Oleg measure potential gain of this change
Comment 3 Alexander Kouznetsov 2008-12-02 15:18:16 UTC
Whitelist violators report:

1st and 2nd startup:

Removed:
org.netbeans.modules.profiler.ProfilerControlPanel2Support



Startup with LimeWire project:

Removed:
org.netbeans.modules.maven.profiler.MavenProjectTypeProfiler
org.netbeans.modules.profiler.ProfilerControlPanel2Support

http://www.netbeans.org/issues/show_bug.cgi?id=153383:
org.netbeans.modules.profiler.AbstractProjectTypeProfiler
org.netbeans.modules.profiler.freeform.FreeFormProjectTypeProfiler
org.netbeans.modules.profiler.j2ee.J2EEProjectTypeProfiler
org.netbeans.modules.profiler.j2se.J2SEProjectTypeProfiler
org.netbeans.modules.profiler.nbmodule.NbModuleProjectTypeProfiler
org.netbeans.modules.profiler.utils.ProjectUtilities
Total: 8 class(es)



Total number of loaded classes is less by 52 in 1st and 2nd startup, by 58 in startup with LimeWire project.
Comment 4 Alexander Kouznetsov 2008-12-02 15:20:25 UTC
Created attachment 74423 [details]
Loaded Classes diff for 1st NetBeans startup
Comment 5 Alexander Kouznetsov 2008-12-02 15:21:56 UTC
Created attachment 74424 [details]
Loaded Classes diff for NetBeans startup with LimeWire
Comment 6 Alexander Kouznetsov 2008-12-02 15:30:34 UTC
Loaded Classes diff for 2nd NetBeans startup doesn't differ from Loaded Classes diff for 1st startup in the number of
loaded profiler classes.
Comment 7 J Bachorik 2009-04-27 15:20:33 UTC
Won't fix for 6.7

I have tested the patch but unfortunately the whole profiler infrastructure is initialized as soon as the "Profile" menu
is opened:

INFO [org.netbeans.lib.profiler.common.Profiler]: profiler is here org.netbeans.modules.profiler.NetBeansProfiler@3015b303
java.lang.Exception: stacktrace
        at org.netbeans.lib.profiler.common.Profiler.getDefault(Profiler.java:137)
        at org.netbeans.modules.profiler.actions.ModifyProfilingAction.isEnabled(ModifyProfilingAction.java:70)
        at org.openide.awt.Actions$MenuBridge.updateState(Actions.java:952)
        at org.openide.awt.Actions.connect(Actions.java:198)
        at org.openide.awt.Actions.connect(Actions.java:165)
        at org.openide.awt.Actions$MenuItem.<init>(Actions.java:1285)
        at org.netbeans.modules.openide.awt.DefaultAWTBridge.createMenuPresenter(DefaultAWTBridge.java:68)
        at org.openide.util.actions.CallableSystemAction.getMenuPresenter(CallableSystemAction.java:79)
        at org.openide.awt.DynaMenuModel.loadSubmenu(DynaMenuModel.java:90)
        at org.openide.awt.MenuBar$LazyMenu$MenuFolder.createInstance(MenuBar.java:684)
        at org.openide.loaders.FolderInstance.defaultProcessObjectsFinal(FolderInstance.java:857)
        at org.openide.loaders.FolderInstance$1R.run(FolderInstance.java:722)
        at org.openide.util.Task.run(Task.java:249)
        at org.netbeans.modules.openide.loaders.AWTTask.run(AWTTask.java:70)
        at org.netbeans.modules.openide.loaders.AWTTask$Processor.run(AWTTask.java:111)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Comment 8 Jaroslav Tulach 2009-06-19 09:05:38 UTC
Test to verify profiler starts no threads on start is here: ergonomics#417c64acf417
Comment 9 Quality Engineering 2009-06-20 08:09:40 UTC
Integrated into 'main-golden', will be available in build *200906200201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/417c64acf417
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #154324: Allowing profiler to start its test for now. As soon as #154324 is fixed, revert this commit
Comment 10 J Bachorik 2011-10-04 09:06:42 UTC
Profiler is being initialize lazily.

The test is updated to reflect the change http://hg.netbeans.org/profiler-main/rev/5ec2cabbc8b3
Comment 11 Quality Engineering 2011-10-07 14:41:05 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/5ec2cabbc8b3
User: Jaroslav Bachorik <yardus@netbeans.org>
Log: #154324: Profiler thread is not being started prematurely