Closed Bug 817543 Opened 13 years ago Closed 13 years ago

[toolbox] is slow to start

Categories

(DevTools :: Framework, defect, P1)

x86
All
defect

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 20

People

(Reporter: paul, Assigned: paul)

References

Details

Attachments

(3 files, 5 obsolete files)

Starting the inspector in a pre-toolbox build is pretty fast. In a post-toolbox, it takes several seconds. This can be explained by bug 796006. But I have the feeling that it's not the only reason. We need to have some real measurements, and understand where the regression lies (toolbox? inspector? both? are the other tools affected?).
Also curious to know if the regression happens once the first time the tools are loaded or if it's repeatable. I think it's the latter, but need data.
After observing a little, I also think its the latter.
Starting an empty tool (about:blank): first time: ~350ms second time: ~160ms By "starting" I mean: from the XUL command to the "ready" event from the toolbox (fired once all the toolbox DOM operations are done). So it doesn't include loading the tool itself. Once "ready" is fired, the toolbox is built, the iframe that will hold the default tool is built too, but the tool is still loading. In the case of the empty tool, the tool is loaded 50ms after the "ready" event. More data about that will come later. One important thing: opening the toolbox feels jumpy because we first show a grey box, that then gets filled with the toolbox content. This happens because we first load "about:blank" in the host. Avoiding that and loading toolbox.xul directly will probably improve the performance and avoid this grey screen. But apparently, we need to load about:blank for some docshell swapping reasons that I don't understand yet.
The "first time" value can go up to 500ms.
All the Tilt code was loaded while opening the toolbox. Lazy loading makes us win ~50ms. Not loading about:blank doesn't change much.
First startup: 270ms is spent loading gcli.jsm.
(In reply to Paul Rouget [:paul] from comment #6) > First startup: 270ms is spent loading gcli.jsm. holy moley
Most of the time is spent in: 220ms in this.gcli = require('gcli/index'); 60ms between Toolbox._host.open() and Toolbox._host.once("ready") 40ms to "just" load (DOM loaded) toolbox.xul 25ms in Toolbox._buildTabs() 130ms in Toolbox._buildButtons() (gcli buttons) 15ms in Toolbox.selectTool() Gcli is seriously slowing us down (220ms + 130ms). I think the first 60ms can be avoided.
The above numbers represents 83% of the time spent between clicking on a the menuitem and the final "ready" event (589ms).
When the gcli start, we read and sort all the preferences in gcli/settings.startup. This takes 160ms (27% of total time). We can probably do that in a lazy way. http://mxr.mozilla.org/mozilla-central/source/browser/devtools/commandline/gcli.jsm#4694
These 3 lines, combined, take 30 extra milliseconds: > canon.addCommand(prefShowCmdSpec); > canon.addCommand(prefSetCmdSpec); > canon.addCommand(prefResetCmdSpec);
15% spent in: > let toolbarSpec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec");
Reaching the pref doesn't take time. But loading the DeveloperToolbar.jsm does.
This: Cu.import("resource:///modules/devtools/CmdAddon.jsm"); Cu.import("resource:///modules/devtools/CmdBreak.jsm"); Cu.import("resource:///modules/devtools/CmdCalllog.jsm"); Cu.import("resource:///modules/devtools/CmdCalllogChrome.jsm"); Cu.import("resource:///modules/devtools/CmdConsole.jsm"); Cu.import("resource:///modules/devtools/CmdCookie.jsm"); Cu.import("resource:///modules/devtools/CmdDbg.jsm"); Cu.import("resource:///modules/devtools/CmdEcho.jsm"); Cu.import("resource:///modules/devtools/CmdEdit.jsm"); Cu.import("resource:///modules/devtools/CmdExport.jsm"); Cu.import("resource:///modules/devtools/CmdInspect.jsm"); Cu.import("resource:///modules/devtools/CmdJsb.jsm"); Cu.import("resource:///modules/devtools/CmdPagemod.jsm"); Cu.import("resource:///modules/devtools/CmdResize.jsm"); Cu.import("resource:///modules/devtools/CmdRestart.jsm"); Cu.import("resource:///modules/devtools/CmdScreenshot.jsm"); Cu.import("resource:///modules/devtools/CmdTilt.jsm"); Cu.import("resource:///modules/devtools/CmdScratchpad.jsm"); Is killing us. This is called because: Commands.jsm is loaded because: DeveloperToolbar is loaded because: CommandUtils is needed to build the buttons in the toolbox. We should move CommandUtils into Toolbox.jsm (or at least the functions, not the exported symbol).
Apparently, we need to load all of these to know if the command-button is a known command or not. So moving commandUtils code into Toolbox.jsm won't help.
To summarize my current research: For an basic tool: 220ms in this.gcli = require('gcli/index'); Because we read and then sort all the preferences (gcli/settings).startup(). (comment 10). 130ms in Toolbox._buildButtons() (gcli buttons); Because to build the buttons, we need to know if the commands exist, so we have to load all the commands (comment 14 and comment 15). There are other places where we can improve the code, but these are the 2 most obvious things we need to fix.
Loading about:blank in the host doesn't have any significant impact.
(In reply to Paul Rouget [:paul] from comment #17) > Loading about:blank in the host doesn't have any significant impact. We actually need it (to have something to swap in the devtools window).
Using "visibility:collapse" on the iframe and switching it to "visibility:visible" prevents the empty pane. Less flickering, but the box shows up a little later. But it feels better.
Conclusion: - lazy load Tilt - don't show the host iframe until ready (not the tool iframe) - fix gcli loading (the pref thing and the multiple JSMs loading) For the Gcli, we can: - move this big chunk of JSMs into one JSM - postpone the creation of the buttons (timeout 500ms?) - not require to read all the commands, and assume they exist, and load all the commands only when the button is pressed For the pref thing, I don't know. I need Joe here.
Joe - can you take a look at comment 16 and comment 20 and tell me what you think.
Flags: needinfo?(jwalker)
Priority: -- → P1
Flags: needinfo?(jwalker)
Attachment #691784 - Flags: review?(paul)
Comment on attachment 691784 [details] [diff] [review] This should solve the gcli/settings/prefs part of the puzzle The preferences are still read and sorted as soon as gcli.jsm is loaded.
Attachment #691784 - Flags: review?(paul) → review-
Work in progress (see PR here: https://github.com/paulrouget/mozilla-central/pull/1). Starting the WebConsole: - without this patch: ~750ms - with this patch: ~450ms Lazy pref loading will probably bring us to a 50% improvement.
Attached patch v2 (obsolete) — Splinter Review
Assignee: nobody → jwalker
Attachment #691784 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #692980 - Flags: review?(paul)
Attached patch v3 (obsolete) — Splinter Review
Just noticed a stray 'console.trace' in the patch. Removed.
Attachment #692980 - Attachment is obsolete: true
Attachment #692980 - Flags: review?(paul)
Attachment #693283 - Flags: review?(paul)
Attached patch patch v1 (obsolete) — Splinter Review
~40% improvements + better cold-startup experience.
Assignee: jwalker → paul
Attachment #693283 - Attachment is obsolete: true
Attachment #693283 - Flags: review?(paul)
Summary: [toolbox] or [inspector] is slow to start → [toolbox] is slow to start
Attachment #693357 - Flags: review?(jwalker) → review+
Whiteboard: to land once try is green
Not green: - (NS_ERROR_FILE_NOT_FOUND)" location: "JS frame :: chrome://mochitests/content/browser/browser/devtools/commandline/test/browser_cmd_addon.js - TEST-UNEXPECTED-FAIL | chrome://mochitests/content/browser/browser/devtools/markupview/test/browser_inspector_markup_edit.js | Test timed out (not intermittent as in bug 816953)
Not being able to find a test file really is bizarre. I re-triggered the Linux platform to see if there might be a build error that a clobber might help. Maybe makefile commenting could have cause it?
Not, it's normal. It's because we use CmdAddons.jsm and not BuiltinCommands.jsm in the test.
Attached patch addendum (obsolete) — Splinter Review
I'm still working actively on this. This patch fixes most of the problems, but I need to find something smarter than visibility:collapse because this has an effect on our focus mechanism.
Attachment #693357 - Attachment is obsolete: true
Attachment #693357 - Attachment is obsolete: false
Attachment #694483 - Attachment description: patch v2 → addendum
Attachment #694483 - Attachment is patch: true
Component: Developer Tools → Developer Tools: Framework
Whiteboard: to land once try is green
Attached patch addendumSplinter Review
This patches fixes the different test failures. Also, I removed the `show` mechanism, because hiding the toolbox before it's loaded causes problems in the tests that I didn't manage to fix (focus problems), and I want to get the remaining optimizations in Firefox 20.
Attachment #694483 - Attachment is obsolete: true
Attachment #697409 - Flags: review?(jwalker)
Comment on attachment 697409 [details] [diff] [review] addendum Review of attachment 697409 [details] [diff] [review]: ----------------------------------------------------------------- ::: browser/devtools/styleinspector/CssHtmlTree.jsm @@ +61,5 @@ > * Schedule a new batch on the main loop. > */ > schedule: function UP_schedule() > { > + if (this.canceled) { I think 'canceled' is US English, 'cancelled' is UK/Ca/Au English (to the extent that English can be tied down at all). I'm ok with the change but I'm not sure that the 'll' version is actually wrong.
Attachment #697409 - Flags: review?(jwalker) → review+
still some oranges.
Attached patch final patchSplinter Review
I failed my push to try (pushed some old code). https://tbpl.mozilla.org/?tree=Try&rev=6f9243cbba48
green.
Whiteboard: [land-in-fx-team]
Whiteboard: [land-in-fx-team] → [fixed-in-fx-team]
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 20
Depends on: 829460
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: