Closed Bug 1365776 Opened 3 years ago Closed 3 years ago
DWrite Font::Measure Glyph Width() can be really slow
STR: 1. Load wwww.youtube.com 2. In the search field, enter mozilla 3. Press enter In the page load that follows, this function can take 30ms. https://perfht.ml/2rgFYXU This is a bug on the Quantum Release Criteria. Milan, can you please find an owner? Thanks!
Can you get better dwrite symbols? If they're not on the symbol server talk to :ted
There are a couple of things I think we could try here. First, newer versions of dwrite have an extended interface IDWriteFontFace1 that adds, among other things, GetDesignGlyphAdvances and GetGdiCompatibleGlyphAdvances methods. These are presumably cheaper to call than the Get*Metrics APIs we're using at the moment. We'd have to include a runtime check for the availability of this interface, though, as the original Win7 (and earlier) versions didn't have it. Second, we currently get the advance for a single glyph at a time; we could investigate whether getting advances for a whole range of glyphs in a single call would be significantly cheaper. Depends what the per-call overhead is, compared to the per-glyph cost. Probably worth doing some low-level instrumentation around the dwrite calls to find out what the perf characteristics are really like, and then choosing a strategy based on that.
Jonathan, are you the right person to look at this? Any other qf:p1 competing for your attention?
Component: Graphics → Graphics: Text
Flags: needinfo?(milan) → needinfo?(jfkthame)
Whiteboard: [qf:p1] → [qf:p1][gfx-noted]
Well... yes, I've got some ongoing investigations of qf:p1 layout stuff as well, but I could probably look into this tomorrow... at least to figure out which direction(s) we should pursue. If the final answer is that "dwrite can be slow", there may be a limit to what we can do here, but I'm hopeful that one or both of the ideas in comment 2 will provide at least some mitigation.
Assignee: nobody → jfkthame
(In reply to Jeff Muizelaar [:jrmuizel] from comment #1) > Can you get better dwrite symbols? If they're not on the symbol server talk > to :ted Filed bug 1366166. I'd appreciate if someone else can follow up on it please. I lag on responding to bugzilla and have a work week coming up next week which isn't helpful in expediting things!
In my testing, I haven't seen times anywhere near as large as Ehsan's 30ms from comment 0, so it's unclear to me how frequently this can occur. Nevertheless, instrumenting around the DWrite calls confirms that the IDWriteFontFace1 APIs that only get glyph advance (instead of all the glyph metrics) typically take about half as long, so I think it's worth switching to the newer API when available. We're talking about timings in the region of a microsecond per glyph, though, so the difference will be completely lost in the noise in higher-level profiles.
Attachment #8869802 - Flags: review?(jmuizelaar)
(In reply to Jonathan Kew (:jfkthame) from comment #6) > Created attachment 8869802 [details] [diff] [review] > Use the IDWriteFontFace1 interface if available to get glyph advances from > DirectWrite more cheaply > > In my testing, I haven't seen times anywhere near as large as Ehsan's 30ms > from comment 0... I imagine Ehsan may have been working on the reference machine?
Jeff: review ping?
Attachment #8869802 - Flags: review?(jmuizelaar) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/699ca92b32489325344a644f8081200276c50611 Bug 1365776 - Use the IDWriteFontFace1 interface if available to get glyph advances from DirectWrite more cheaply. r=jrmuizel
You need to log in before you can comment on or make changes to this bug.