improve layout performance for hyphenated text

VERIFIED FIXED in mozilla28



Layout: Text
4 years ago
a year ago


(Reporter: jfkthame, Assigned: jfkthame)



Firefox Tracking Flags

(Not tracked)



(1 attachment)



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.

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)

Comment 2

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

Using, 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 ( 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, 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]:

Attachment #8336090 - Flags: review?(roc) → review+
Last Resolved: 4 years ago
Resolution: --- → FIXED


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.
Keywords: verifyme
You need to log in before you can comment on or make changes to this bug.