140ms of FontFace::DoLoad when loading Google Doc
Categories
(Core :: Layout: Text and Fonts, enhancement, P3)
Tracking
()
People
(Reporter: mstange, Assigned: heycam)
References
Details
(Keywords: perf:pageload)
Attachments
(5 files)
Comment 1•7 years ago
|
||
Comment 2•7 years ago
|
||
| Reporter | ||
Comment 3•7 years ago
|
||
Comment 4•7 years ago
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 5•7 years ago
|
||
Updated•7 years ago
|
| Assignee | ||
Comment 6•6 years ago
|
||
Coming back to this, I no longer see any time spent under LookupLocalFont, so maybe this is not relying on local() fonts any more.
My comment 5 was talking about making the load() call async, so that script could continue running, but still just deferred to run on the main thread, not on a different thread. I see a total 288 ms under gfxUserFontEntry::LoadPlatformFont, and this work is happening while the main thread is janked for 100 ms at a time, so I think it's still worth thinking about moving this work off to another thread.
| Assignee | ||
Comment 7•6 years ago
|
||
I'm seeing 72% of time under LoadPlatformFont performing the OTS sanitization. That feels like that should be easily movable OMT. The rest is MakePlatformFont -- how well would that work OMT, Jonathan?
Comment 8•6 years ago
|
||
Yeah, this seems like it should be do-able. IIRC, we should be able to do MakePlatformFont from another thread on all the various back-ends. I believe FreeType requires us to protect the FT_Library with a lock while instantiating an FT_Face, but we already have a mutex in gfx::2d::Factory to use for that.
| Assignee | ||
Comment 9•6 years ago
|
||
I have a WIP patch that moves the sanitization work OMT. Here's a profile of that Google docs URL from comment 0 http://bit.ly/2IdeA3e where you can see the work under StartPlatformFontLoadOnWorkerThread on the FontLoader thread.
Mike, do you have any suggestions on how can tell whether this change is worth it? I'm guessing yes since I see other work happening on the main thread while the FontLoader thread is doing its thing, but is that all I should be looking for?
| Assignee | ||
Comment 10•6 years ago
|
||
Comment 11•6 years ago
|
||
I suspect this is the sort of thing that would impact Google Docs page load and responsiveness.
We do, I believe, have Google Docs in the Raptor tp6 suite. You might try running that to see what kind of impact you get? It might also be worth running those Raptor tests on the 2017 reference device in CI (those are the "windows-10-64-ux" machines in try chooser / try fuzzy).
Hey jesup, do you have other suggestions on how heycam might test this patch? Are there other tests that your team has been working on that might be relevant here?
Comment 12•6 years ago
|
||
You might need the "right" kind of doc loaded to trigger that - the doc used in raptor is https://docs.google.com/document/d/1US-07msg12slQtI_xchzYxcKlTs6Fp7WqIc6W5GK5M8/edit (251 pages, with some math, music, images, etc).
Certainly the other things happening while loading the font imply there's a possible win here, though perhaps not much on a low-end machine. Maybe not much on mid-end, but the jank removal should help on both low and mid even so.
Minor note: MOZ_ASSERT(NS_GetCurrentThread() == sFontLoadingThread); won't work, you need to use sFontLoadingThread->IsOnCurrentThread(). :-) and 10s may be a bit long
| Assignee | ||
Comment 13•6 years ago
|
||
One thing I noticed while loading that document is that the majority of the time spent doing this font work is after document load. So it might not help with the actual page load times, but might well help with responsiveness of that work that happens later.
| Assignee | ||
Comment 14•6 years ago
|
||
I'm going to punt the moving of platform font creation OMT to bug 1556728, and just leave the sanitization stuff in this bug.
| Comment hidden (obsolete) |
| Assignee | ||
Comment 16•6 years ago
|
||
Comment 17•6 years ago
|
||
:heycam, I just filed bug 1556991 to remove the pref controlling WOFF2 support, which will get it out of your way here.
| Assignee | ||
Comment 18•6 years ago
|
||
Pushing the patches to try, I don't see any change in the Raptor test results:
There are a few changes in Talos tests, some up some down:
though when I overlay them with m-c historical results it looks like they're all within a normal range.
| Assignee | ||
Comment 19•6 years ago
|
||
From spot checking in profiles, I do so time spent on the main thread doing work while the font load is happening on the FontLoader thread, so I think this should help with responsiveness during those times. But it's not something I've been able to verify.
| Assignee | ||
Comment 20•6 years ago
|
||
| Assignee | ||
Comment 21•6 years ago
|
||
We don't write to it.
| Assignee | ||
Comment 22•6 years ago
|
||
| Assignee | ||
Comment 23•6 years ago
|
||
| Assignee | ||
Comment 24•6 years ago
|
||
Idle thought: should we only send the font off to the FontLoader thread when it is bigger than a certain size?
Comment 25•6 years ago
|
||
(In reply to Cameron McCormack (:heycam) from comment #24)
Idle thought: should we only send the font off to the FontLoader thread when it is bigger than a certain size?
That sounds like it could be sensible, yes. Not sure what a good threshold would be, though -- I suppose we could do some measurement to see how long it takes to sanitize a typical font of 1K, 10K, 100K....
Comment 26•6 years ago
|
||
Comment 27•6 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/478ac1179fa6
https://hg.mozilla.org/mozilla-central/rev/ebecfbeb55c6
https://hg.mozilla.org/mozilla-central/rev/f38b9eb31da7
https://hg.mozilla.org/mozilla-central/rev/1b1a7d2f27c4
Updated•6 years ago
|
Updated•3 years ago
|
Description
•