Last Comment Bug 764005 - optimize gfxFontGroup::FindFontForChar for the most common case, and lift array Length() accesses out of other loops in font code
: optimize gfxFontGroup::FindFontForChar for the most common case, and lift arr...
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Graphics: Text (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla16
Assigned To: Jonathan Kew (:jfkthame)
:
:
Mentors:
Depends on: 769475
Blocks: 762710
  Show dependency treegraph
 
Reported: 2012-06-12 09:38 PDT by Jonathan Kew (:jfkthame)
Modified: 2012-06-28 15:17 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
optimize access to the mFonts array in gfxFontGroup (3.97 KB, patch)
2012-06-12 09:38 PDT, Jonathan Kew (:jfkthame)
no flags Details | Diff | Splinter Review
patch, optimize common case in gfxFontGroup::FindFontForChar, and various other loops in font code (15.24 KB, patch)
2012-06-19 14:50 PDT, Jonathan Kew (:jfkthame)
smontagu: review+
Details | Diff | Splinter Review

Description Jonathan Kew (:jfkthame) 2012-06-12 09:38:48 PDT
Created attachment 632294 [details] [diff] [review]
optimize access to the mFonts array in gfxFontGroup

There's no reason for gfxFontGroup::FontListLength to be virtual; and we can reduce the overhead of accessing the mFonts array by getting the Length and Elements pointer into local variables instead of repeatedly using the nsTArray methods and GetFontAt() within loops.
Comment 1 Jonathan Kew (:jfkthame) 2012-06-19 14:50:18 PDT
Created attachment 634600 [details] [diff] [review]
patch, optimize common case in gfxFontGroup::FindFontForChar, and various other loops in font code

Extending this bug to cover more cases where we can optimize by pulling nsTArray::Length() accesses out of loops, etc., and more importantly, optimize gfxFontGroup::FindFontForChar by handling the most common case (a normal character available in the first font of the group) at the beginning of the function.

When reflowing the tinderbox log mentioned in bug 762710 comment 0 on my MBPro, this patch reduces the total time spent in gfxFontGroup::FindFontForChar (as recorded by Instruments) from about 650-700ms to around 260ms.
Comment 3 Ed Morley [:emorley] 2012-06-21 04:05:02 PDT
https://hg.mozilla.org/mozilla-central/rev/5c22222c03a5

Note You need to log in before you can comment on or make changes to this bug.