|
|
Chromium Code Reviews|
Created:
4 years, 4 months ago by Ilya Kulshin Modified:
4 years, 4 months ago CC:
ajuma+watch_chromium.org, blink-reviews, blink-reviews-platform-graphics_chromium.org, brucedawson, Bret, Rik, chromium-reviews, danakj+watch_chromium.org, darin-cc_chromium.org, dshwang, drott+blinkwatch_chromium.org, krit, eae, f(malita), jam, jbroman, Justin Novosad, pdr+graphicswatchlist_chromium.org, rwlbuis, Stephen Chennney, stanisc Base URL:
https://chromium.googlesource.com/chromium/src.git@master Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionRemove unnecessary font loading when loading font fallbacks.
Previously, we were going through all possible fallback fonts and
testing each for existence as soon as something asked for any fallback
font. Due to how isFontPresent is implemented, it actually loads the
font. This change defers testing font existence (and loading them) until
a font for that script is actually needed. I expect this will result in
a perf gain, since I expect most pages will need only a few fallback
fonts.
In my very limited and not very rigorous testing, I observed about a 5%
improvement in warm startup (Startup.FirstWebContents.NonEmptyPaint2)
when navigating to emojipedia.org.
BUG=631258
Committed: https://crrev.com/3f489f6b953f464a1a0b5996bc79e468ba9e35e1
Cr-Commit-Position: refs/heads/master@{#410729}
Patch Set 1 #Patch Set 2 : Remove extra file #Patch Set 3 : Remove the separate latin/greek/cyrillic font map and add those fonts to the main map #
Total comments: 6
Patch Set 4 : Refactor based on codereview feedback #
Total comments: 2
Patch Set 5 : Remove scriptMonospaceFontMap #Messages
Total messages: 35 (24 generated)
kulshin@chromium.org changed reviewers: + kojii@chromium.org
ptal, especially the Han fallback logic, since you've been working recently in that area.
The CQ bit was checked by kulshin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: win_clang on master.tryserver.chromium.win (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.win/builders/win_clang/builds/...)
The CQ bit was checked by kulshin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Thank you for working on this. I was a little concerned about this too, but when I measured, this function only took 10ms on my z620, and I wasn't sure if that buys additional check of "attemptedLoad" on every lookup. z620 is probably too fast to measure on, and if you see actual improvements, that's superb. I'm concerned that looping as many times as the number of requested scripts. While I agree that only very few will be used, 2 is possible, 3 may be. Please see comments inline below:
https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp (right): https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:73: bool attemptedLoad; How about adding: const UChar** candidateFamilyNames; so that we only need to loop once, but still can lazily resolve the first available font? https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:307: if (script != hanScript) { With the CL a few days ago, scriptForHan() will never return USCRIPT_HAN, so you can replace this with DCHECK(). There's some unknown I need to understand better for Korean, but this is the current assumption. https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:309: initializeScriptFontMapping(hanScript, hanMapping, fontManager); Assuming this function is given "scriptFontMap" to resolve the loop issue mentioned above, we need to do this only when !scriptFontMap[hanScript].attemptedLoad. But since this code runs only when !scriptFontMap[USCRIPT_HAN].attemptedLoad, I can't imagine the case when !scriptFontMap[hanScript].attemptedLoad. Maybe DCHECK should be fine.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
ptal. I refactored the code as you suggested, so that now it will loop once to find the candidate families (without loading anything) and then loop through the candidates as-needed when the script is requested. I ran a few more tests and confirmed my observations that this improves performance when fallback is needed. I'm not sure when you did your testing, but if it was before M52 you may have been running the font cache code. In that case, there would be a penalty at startup to load *all* fonts, but subsequent font loading would be very fast because they would already be loaded. https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp (right): https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:73: bool attemptedLoad; On 2016/08/04 06:02:03, kojii wrote: > How about adding: > const UChar** candidateFamilyNames; > so that we only need to loop once, but still can lazily resolve the first > available font? Done. https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:307: if (script != hanScript) { On 2016/08/04 06:02:03, kojii wrote: > With the CL a few days ago, scriptForHan() will never return USCRIPT_HAN, so you > can replace this with DCHECK(). There's some unknown I need to understand better > for Korean, but this is the current assumption. Acknowledged. https://codereview.chromium.org/2215543002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:309: initializeScriptFontMapping(hanScript, hanMapping, fontManager); On 2016/08/04 06:02:03, kojii wrote: > Assuming this function is given "scriptFontMap" to resolve the loop issue > mentioned above, we need to do this only when > !scriptFontMap[hanScript].attemptedLoad. > > But since this code runs only when !scriptFontMap[USCRIPT_HAN].attemptedLoad, I > can't imagine the case when !scriptFontMap[hanScript].attemptedLoad. Maybe > DCHECK should be fine. Acknowledged.
The CQ bit was checked by kulshin@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
kojii@chromium.org changed reviewers: + drott@chromium.org, eae@chromium.org
Non-owner lgtm with nit. drott/eae, PTAL. > I ran a few more tests and confirmed my observations that this improves performance when fallback is needed. I tested a couple of weeks ago, but only measured the init function in warm condition, so you tested this trade off giving a total win is great, thank you. https://codereview.chromium.org/2215543002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp (right): https://codereview.chromium.org/2215543002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:447: if (!scriptMonospaceFontMap[script].familyName) { Isn't this supposed to be: if (scriptMonospaceFontMap[script].candidateFamilyNames) { In case the first attempt ended with no figure for the script?
LGTM once you've addressed kojiis comment.
The CQ bit was checked by kulshin@chromium.org to run a CQ dry run
https://codereview.chromium.org/2215543002/diff/60001/third_party/WebKit/Sour... File third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp (right): https://codereview.chromium.org/2215543002/diff/60001/third_party/WebKit/Sour... third_party/WebKit/Source/platform/fonts/win/FontFallbackWin.cpp:447: if (!scriptMonospaceFontMap[script].familyName) { On 2016/08/06 09:33:13, kojii wrote: > Isn't this supposed to be: > if (scriptMonospaceFontMap[script].candidateFamilyNames) { > In case the first attempt ended with no figure for the script? Since there's only two monospace overrides and they do not check for existence of the font, I think it's better to just go through the monospace list each time. That also means we can save the memory that would otherwise be used by |scriptMonospaceFontMap|. Except that I forgot to actually finish that refactor and remove |scriptMonospaceFontMap|. Thanks for pointing it out.
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was checked by kulshin@chromium.org to run a CQ dry run
Patchset #5 (id:80001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
lgtm
The CQ bit was checked by kulshin@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from eae@chromium.org Link to the patchset: https://codereview.chromium.org/2215543002/#ps100001 (title: "Remove scriptMonospaceFontMap")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Committed patchset #5 (id:100001)
Message was sent while issue was closed.
Description was changed from ========== Remove unnecessary font loading when loading font fallbacks. Previously, we were going through all possible fallback fonts and testing each for existence as soon as something asked for any fallback font. Due to how isFontPresent is implemented, it actually loads the font. This change defers testing font existence (and loading them) until a font for that script is actually needed. I expect this will result in a perf gain, since I expect most pages will need only a few fallback fonts. In my very limited and not very rigorous testing, I observed about a 5% improvement in warm startup (Startup.FirstWebContents.NonEmptyPaint2) when navigating to emojipedia.org. BUG=631258 ========== to ========== Remove unnecessary font loading when loading font fallbacks. Previously, we were going through all possible fallback fonts and testing each for existence as soon as something asked for any fallback font. Due to how isFontPresent is implemented, it actually loads the font. This change defers testing font existence (and loading them) until a font for that script is actually needed. I expect this will result in a perf gain, since I expect most pages will need only a few fallback fonts. In my very limited and not very rigorous testing, I observed about a 5% improvement in warm startup (Startup.FirstWebContents.NonEmptyPaint2) when navigating to emojipedia.org. BUG=631258 Committed: https://crrev.com/3f489f6b953f464a1a0b5996bc79e468ba9e35e1 Cr-Commit-Position: refs/heads/master@{#410729} ==========
Message was sent while issue was closed.
Patchset 5 (id:??) landed as https://crrev.com/3f489f6b953f464a1a0b5996bc79e468ba9e35e1 Cr-Commit-Position: refs/heads/master@{#410729} |
