improve layout performance for hyphenated text

VERIFIED FIXED in mozilla28

Status

()

Core
Layout: Text
VERIFIED FIXED
4 years ago
a year ago

People

(Reporter: jfkthame, Assigned: jfkthame)

Tracking

unspecified
mozilla28
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
In profiling John's testcase from bug 941474, I noticed that we're spending an inordinate amount of time (>10% of the reflow time) just measuring the width of the hyphen character that we might want to insert for an automatic-hyphenation linebreak.

The width of the hyphen is supposed to be cached by the PropertyProvider; but unfortunately, that doesn't help much because the PropertyProvider itself is a transient, stack-based object that is created afresh every time we call nsTextFrame::ReflowText.

We can greatly improve this by pushing the caching of the hyphen width down into the gfxFontGroup, so that we don't end up re-measuring it (including creating a temporary text run, etc) every time through ReflowText.
(Assignee)

Comment 1

4 years ago
Created attachment 8336090 [details] [diff] [review]
cache hyphen width in the gfxFontGroup, to improve layout performance for auto-hyphenated text

This patch improves reflow perf on that testcase by over 10% in my initial local testing (with a debug build, but I expect the gain for an opt build to be comparable, given the profile results I saw).
Attachment #8336090 - Flags: review?(roc)
(Assignee)

Comment 2

4 years ago
In the right circumstances, the win may even be much greater than that.

Using http://people.mozilla.org/~jdaggett/textbench/textbenchrun.html?test=complex_multi_column_hyphenation_kerning_and_ligatures_multicolumn_en, and with Nightly configured to use Times New Roman as the default serif font, I see a time of around 630ms; a tryserver build with the patch here (https://tbpl.mozilla.org/?tree=Try&rev=3a1c7ad956c7) cuts that to about 340ms, or a speedup of 45%.

Or to look at it another way, comparing the hyphenated testcase to the unhyphenated one at http://people.mozilla.org/~jdaggett/textbench/textbenchrun.html?test=complex_multi_column_kerning_and_ligatures_multicolumn_en, the text-layout speed penalty for enabling auto-hyphenation is reduced from 340% to 75%.
Comment on attachment 8336090 [details] [diff] [review]
cache hyphen width in the gfxFontGroup, to improve layout performance for auto-hyphenated text

Review of attachment 8336090 [details] [diff] [review]:
-----------------------------------------------------------------

Nice!
Attachment #8336090 - Flags: review?(roc) → review+
https://hg.mozilla.org/mozilla-central/rev/358497b9c713
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED

Updated

4 years ago
Keywords: verifyme

Comment 6

4 years ago
Tested with the benchmarks in comment 2 - compared the 11/21 Nightly with the 02/11 Beta (both Fx28).

Windows 7 32bit:
* hyphenation - nightly average of 563ms, beta average of 234ms;
* no hyphenation - nightly average of 185ms, beta average of 144ms.

Mac OS X 10.8.5:
* hyphenation - nightly average of 273ms, beta 246ms
* no hyphenation - nightly average of 156ms, beta 162ms

Ubuntu 13.04 32bit:
* hyphenation - nightly average of 345ms, beta 267ms
* no hyphenation - nightly average of 198ms, beta 181ms

I'm not seeing such a big drop as specified in above comments, but there's a drop in each hyphenation case.
Status: RESOLVED → VERIFIED
Keywords: verifyme
You need to log in before you can comment on or make changes to this bug.