Closed
Bug 734015
Opened 14 years ago
Closed 14 years ago
Slow down parsing of web pages in background tabs.
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
FIXED
People
(Reporter: jst, Assigned: smaug)
References
(Blocks 2 open bugs)
Details
(Keywords: perf, Whiteboard: [Snappy:p1])
Attachments
(4 files, 3 obsolete files)
|
7.01 KB,
patch
|
Details | Diff | Splinter Review | |
|
7.48 KB,
patch
|
hsivonen
:
review+
|
Details | Diff | Splinter Review |
|
7.65 KB,
patch
|
Details | Diff | Splinter Review | |
|
7.65 KB,
patch
|
Details | Diff | Splinter Review |
We already slow down firing of timeouts in background tabs, and we're working on improving that, and timeout firing in general in bug 715376. But there's plenty of things that we do in background tabs to slow down execution. Some ideas that have been floated are:
- Slow down parsing, i.e. delay feeding data from the parser to the main thread
- Slow down async reflows
- Slow down script evaluation, i.e. delay invocation of external scripts
There's probably more, but that seems like a good start. Feel free to propose additional things we could look into here. And this should probably act as a meta bug for this work, with specific bugs for the various items we'll end up working on here.
Comment 1•14 years ago
|
||
> - Slow down parsing, i.e. delay feeding data from the parser to the main thread
That effectively means fewer longer main-thread events instead of more shorter ones, right?
> - Slow down async reflows
We already do; background tab refresh drivers are throttled.
> - Slow down script evaluation, i.e. delay invocation of external scripts
This is an interesting one...
| Reporter | ||
Comment 2•14 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #1)
> > - Slow down parsing, i.e. delay feeding data from the parser to the main thread
>
> That effectively means fewer longer main-thread events instead of more
> shorter ones, right?
I think this would need to mean more short main-thread events. We want to keep the building of the DOM and layout thereof in background tabs from interfering with foreground tabs, at the expense of pageload times for background tabs being longer. Whether that means the parser feeds the main thread slower, or the main thread taking smaller bites off of the incoming data from the parser I dont't know, but one of the two. Speculative loading should probably continue to happen at the same pace though.
Updated•14 years ago
|
Whiteboard: [Snappy] → [Snappy:p1]
| Assignee | ||
Comment 3•14 years ago
|
||
I started to hack something, just to try out various things.
This patch doesn't feel right. My guess is that we end up interrupting
parser way too often, and that leads to tons of memmoves in parser and also
way too many runnables.
Perhaps parser should use a timer, not runnable when handling a parsing interrupt.
Comment 4•14 years ago
|
||
Whoa. Those tiny tasks are *really* tiny. No wonder there are lots of memmoves and runnables.
| Assignee | ||
Comment 5•14 years ago
|
||
Still just testing various things... based on about:jank it is
often reflow which takes times.
Attachment #609758 -
Attachment is obsolete: true
Comment 6•14 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #5)
> Still just testing various things... based on about:jank it is
> often reflow which takes times.
Sorry I forgot to mention that. (A couple of years ago at least painting was also terribly expensive on Mac. In the frontmost tab at least but that's not a concern here.)
Now that incremental reflow exists, I wonder if reflows in background tabs could be inhibited altogether (when JS isn't forcing a synchronous reflow).
Comment 7•14 years ago
|
||
> I wonder if reflows in background tabs could be inhibited altogether (when JS isn't
> forcing a synchronous reflow).
It'd take some hacking.
Right not reflows in a background tab are throttled (when not being forced from JS) to an initial delay of 1000ms, then doubling every time the refresh timer fires.
Could this slow down be applied with multiple logins/fast switching.
With several users on a Mac several copies of firefox can be active.
I often see these background copies of firefox dominating the cpu usage-
leading to overheating (fans) and general slowness for all users
Comment 9•14 years ago
|
||
Please file a separate bug on that? When the user account changes, if we can detect that we should set all our stuff as inactive....
Comment 10•14 years ago
|
||
(In reply to AM from comment #8)
> Could this slow down be applied with multiple logins/fast switching.
> With several users on a Mac several copies of firefox can be active.
>
> I often see these background copies of firefox dominating the cpu usage-
> leading to overheating (fans) and general slowness for all users
That's an interesting use-case and we should fix it. But I agree with Boris, this bug is about the multi-tab and not about the multi-instance problem.
Comment 11•14 years ago
|
||
I filed a new bug on the user switching : no 750785
https://bugzilla.mozilla.org/show_bug.cgi?id=750785
| Assignee | ||
Comment 12•14 years ago
|
||
This is simpler, hard to say how much this helps.
This machine is too fast for testing.
Attachment #609823 -
Attachment is obsolete: true
| Assignee | ||
Comment 13•14 years ago
|
||
| Assignee | ||
Comment 14•14 years ago
|
||
| Assignee | ||
Comment 15•14 years ago
|
||
Comment on attachment 625966 [details] [diff] [review]
single flush timer for background tabs
This seems to help in certain cases. A bad, artificial case where this helps quite
a lot is loading http://mxr.mozilla.org/mozilla-central/source/layout/base/nsCSSFrameConstructor.cpp in several bg tabs.
But in general the effect isn't anything dramatic, at least not on this machine.
!NS_IsMainThread() check isn't needed in ContinueInterruptedParsingAsync.
The number 50 is magic. Not too high, not too low. Could be tweaked.
50 works still well with huge pages like HTML spec. The page loading doesn't get
really slow.
This is something where we need feedback. Does it really help with responsiveness?
Is it annoying to slow down bg tab loading?
Attachment #625966 -
Flags: review?(hsivonen)
| Assignee | ||
Comment 16•14 years ago
|
||
(I need to try the patch on a slow Windows laptop)
Comment 17•14 years ago
|
||
(In reply to Olli Pettay [:smaug] from comment #15)
> This is something where we need feedback. Does it really help with
> responsiveness?
> Is it annoying to slow down bg tab loading?
Hopefully bug 710935 will land soonish to help us test magic constants like this.
| Assignee | ||
Comment 18•14 years ago
|
||
Reuse gBackgroundFlushList more often.
Attachment #625966 -
Attachment is obsolete: true
Attachment #625966 -
Flags: review?(hsivonen)
Attachment #626344 -
Flags: review?(hsivonen)
Comment 19•14 years ago
|
||
Comment on attachment 626344 [details] [diff] [review]
patch
r+ if you add a comment explaining the magic number 50 to spare ourselves or people who come after us from Bugzilla and version control archaeology to figure out why the magic number is what it is.
Thank you for working on this.
I'm slightly curious, though: Why do background executors get inserted to the linked list only from ContinueInterruptedParsing and not also from nsHtml5StreamParser-queued nsHtml5ExecutorFlusher::Run? Also, is it intentional that an executor doesn't get removed from the linked list if it switches back to the foreground tab?
Attachment #626344 -
Flags: review?(hsivonen) → review+
| Assignee | ||
Comment 20•14 years ago
|
||
(In reply to Henri Sivonen (:hsivonen) from comment #19)
> I'm slightly curious, though: Why do background executors get inserted to
> the linked list only from ContinueInterruptedParsing and not also from
> nsHtml5StreamParser-queued nsHtml5ExecutorFlusher::Run?
That flusher runs already usually based on a timer tick, and I didn't bother to change the behavior,
except to check if the executor will be run anyway.
I basically wanted to focus on the case where constructing DOM may block main-thread too long.
> Also, is it
> intentional that an executor doesn't get removed from the linked list if it
> switches back to the foreground tab?
That is intentional. No need to complicate the code. The executor will be removed from the list
soon enough anyway.
| Assignee | ||
Comment 21•14 years ago
|
||
Changing the summary, and I'll file followups for other parts of this bug.
Summary: Slow down background tabs. → Slow down parsing of web pages in background tabs.
| Assignee | ||
Comment 22•14 years ago
|
||
| Assignee | ||
Updated•14 years ago
|
Assignee: anygregor → bugs
| Assignee | ||
Comment 23•14 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/8cf563a575fd
Feedback welcome. The patch shouldn't do miracles, only slow down background processing a tiny bit.
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Comment 24•14 years ago
|
||
Unfortunately, this had to be backed out due to causing random mochitest-other orange.
https://hg.mozilla.org/mozilla-central/rev/d499dc65cdab
https://tbpl.mozilla.org/php/getParsedLog.php?id=11998664&tree=Firefox
https://tbpl.mozilla.org/php/getParsedLog.php?id=11990720&tree=Firefox
https://tbpl.mozilla.org/php/getParsedLog.php?id=12000852&tree=Firefox
https://tbpl.mozilla.org/php/getParsedLog.php?id=12002778&tree=Firefox
https://tbpl.mozilla.org/php/getParsedLog.php?id=11998674&tree=Firefox
https://tbpl.mozilla.org/php/getParsedLog.php?id=12002315&tree=Firefox
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
| Assignee | ||
Comment 25•14 years ago
|
||
Huh. I had pushed the patch several times to try.
Comment 26•14 years ago
|
||
Chances are that those tests where already flaky and introducing slack in the timing just made it more probable that they fail.
| Assignee | ||
Comment 27•14 years ago
|
||
Yeah, that is what I've planned to investigate.
| Assignee | ||
Comment 28•14 years ago
|
||
browser_tab_dragdrop.js is certainly buggy.
| Assignee | ||
Comment 29•14 years ago
|
||
I *think* the editor/libeditor/base/tests/test_selection_move_commands.xul failure isn't related.
There are existing similar bugs open.
Still investigating browser_tabfocus.js
Updated•14 years ago
|
Status: REOPENED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
| Assignee | ||
Updated•14 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
| Assignee | ||
Comment 30•14 years ago
|
||
I think I finally found the bug in browser_tabfocus.js.
It is racy.
| Assignee | ||
Comment 31•14 years ago
|
||
| Assignee | ||
Comment 32•14 years ago
|
||
Status: REOPENED → RESOLVED
Closed: 14 years ago → 14 years ago
Resolution: --- → FIXED
Comment 33•14 years ago
|
||
Android S1/S2 testing *may* be showing a regression in startup time caused by this patch. Infrastructure problems have severely reduced S1/S2 capacity, so all I have to go on is data from one phone, but that appears to show a 52 ms increase in startup time with this check-in. It's not a big regression, and very limited evidence, but I thought I would mention it.
Updated•7 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•