New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 639699 link

Starred by 5 users

Issue metadata

Status: Duplicate
Merged: issue 623911
Owner:
Last visit > 30 days ago
Closed: Aug 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug



Sign in to add a comment

Performance impacted by the mere presence of @font-face rules?

Project Member Reported by kenjibaheux@chromium.org, Aug 22 2016

Issue description

Originally reported by a team at Google.

It appears that  web font(s) has a strong impact on performance.
In particular, the following repro case

No web font:
 - http://codepen.io/anon/pen/oLRgyp


With @font-face inlined (Roboto):
 - https://codepen.io/anon/pen/grJbKQ
 - Note: the web font is actually not applied


The test cases here are minimum repros. Composition:
 - thousands of elements (to show how the performance impact scales)
 - a style block within the body tag
 - event handler that installs animation keyframes, then accesses .scrollTop

Navigate to these pages, open the Chrome Dev Tools console, then click the button:

 Result: "Without Roboto [any @font-face rules], reflow for 10,000 elements takes about 5 ms. With Roboto [@font-face rules], reflow takes about 30 ms and the entire window is repainted."

 Observation: "Capturing timeline shows 'Recalculate style' appears 2 times for Default, but with Roboto, 'Recalculate style' is slower and each one is followed by an equally slow 'Layout'.


Let me confirm first.
 
Summary: Performance impacted by the mere presence of @font-face rules? (was: Significant impact Web font)
Cc: kenjibaheux@chromium.org drott@chromium.org e...@chromium.org kouhei@chromium.org
Owner: ----
Status: Available (was: Unconfirmed)
There is definitely a difference of performance: about 2-3x slower on my machine.

Attaching traces from:
 - Google Chrome 54.0.2832.2 (Official Build) canary (64-bit)
 - Revision	 373f6bdd42a605a49fa170b2bcdbae3fbd015acc-refs/branch-heads/2832@{#3}
 - Mac OS X

+hotlist-loading (not limited to loading per se but relevant to project Caminito) +kouhei as an fyi
Labels: Hotlist-Loading
Oops, wrongs traces... Fixing.
trace_default (1).json.gz
691 KB Download
trace_roboto (1).json.gz
895 KB Download

Comment 6 by suzyh@chromium.org, Aug 22 2016

To what extent do you think the use of animation keyframes is key to the performance issue you're seeing? From your investigation, have you seen any indications that the issue is in animations code? I haven't spotted anything in the traces.
Components: -Blink>Animation
Good question. From what I can tell, it seems unlikely that the keyframes can be blamed. The cost appears to be in layout (maybe paint as well?). Removing for now.

Thanks for the comment!

Comment 8 by jeffy...@google.com, Aug 22 2016

Installing keyframes do impact reflow time, though it may be independent of having a Web font loaded.

If you change the click handler to just install an empty CSS rule, e.g. '.empty {}' instead of keyframes, the reflow time is fractions of a millisecond for both the default and Roboto cases.

With keyframes, default reflow takes 10x or more longer and Roboto reflow takes ~40x or more longer.

The multipliers may depend on the machine, but adding keyframes increases reflow time by an order of magnitude over a simple style rule and doing either with Roboto loaded seems to increase by ~4x.

Comment 9 by jeste...@google.com, Aug 22 2016

Has anyone confirmed whether this is Roboto specific, or any web font?
Also, is it Google Fonts specific? or any web font served from any old
location?
Actually, it can be reduced all the way down to this:

@font-face {
  font-family: 'Anything';
  src: local('Anything');
}
Performance of this test differs quite a lot between stable and canary. On my MacBook Air:

52.0.2743.82, no web font => 7ms
52.0.2743.82, with Roboto => 30ms

54.0.2835.0, no web font => 0.2ms
54.0.2835.0, with Roboto => 0.6ms

I'm not sure if we should worry about this 0.6ms.


> Observation: "Capturing timeline shows 'Recalculate style' appears 2 times for Default, but with Roboto, 'Recalculate style' is slower and each one is followed by an equally slow 'Layout'.

I see this in stable but not in canary.

Owner: kenjibaheux@chromium.org
Status: Assigned (was: Available)
Interesting.

Given that the performance on Canary for both cases now beat the best case on Stable, I'm thinking that the Google team that raised this issue should be happy.

And agreed that given the significantly smaller order of magnitude, we might consider the case closed.

I'll circle back.

Comment 14 by e...@chromium.org, Aug 23 2016

Components: -Blink>Layout
We are in a much better place and the original reporter is happy.

It would be nice to determine which change lead to this win and find out if we have the right test in place to catch any regression. I'll try to do a bisect.
Labels: Needs-Bisect
Owner: rnimmagadda@chromium.org
Adding needs-bisect (try to do one myself but the tool is not working anymore :( )

rnimmagadda@, could you help us?

We want to find the CL that lead to a massive improvement between Chrome 52 and 53 (or 54).

Test case: https://codepen.io/anon/pen/grJbKQ
steps: 
 0. start a bisect
 1. open the URL above
 2. open devtools => console
 3. click on the button a bunch of times
 4. look at the durations logged in the console
 5. at one point the performance should be much much better (see comment #12 for an example on a particular machine).


Thanks in advance!
Cc: alancutter@chromium.org rnimmagadda@chromium.org dstockwell@chromium.org
Labels: -Type-Bug -Pri-3 -Needs-Bisect M-52 Pri-2 Type-Bug-Regression
Owner: r...@opera.com
====================================

Good Build:

53.0.2785.0    Base Position: 403382


Bad Build:

53.0.2763.0    Base Position: 398752

=====================================

Able to repro this issue on Windows 7, MAC (10.11.6) & Ubuntu Trusty (14.04) for the Google Chrome Stable Version - 52.0.2743.116

This is a regression issue broken in M53, below mentioned is the bisect info:

CHANGELOG URL: https://chromium.googlesource.com/chromium/src/+log/11d33ea93b80c9f1f6f37514b5beb633ec644c09..adfc5e3c37b1a155af7b2a0f29b52dc8b4dfd0b3

Suspecting Commit: 9c88a15f059aec65af294b8789a27cc377363da6

Review URL: https://codereview.chromium.org/2105743002

@rune: Could you please look into the issue, and if it has nothing to do with your changes and if possible please do assign it to the concerned owner.

Thank you.

Note: Issue got fixed in the Latest Canary Version - 54.0.2839.0 [In fact, as mentioned above this issue got fixed after the version - 53.0.2785.0 (which covers the latest Chrome Beta Version as well). Needs to be fixed on Chrome Stable Version only]

Comment 18 by r...@opera.com, Aug 25 2016

The @keyframes performance improvement is my commit, yes.

The fixed issue is 623911, so if it needs to be back-ported, that issue should get the merge request.

What should happen with this issue? Mark as duplicate, or should it be kept open to investigate the slower-layout-in-the-presence-of-webfonts issue?

Comment 19 by r...@opera.com, Aug 25 2016

Don't know why this is marked as a regression, though.

Labels: -Pri-2 -Type-Bug-Regression Pri-3 Type-Bug
Owner: kenjibaheux@chromium.org
Assigning back to Kenji (although I guess we can just close this).
Mergedinto: 623911
Status: Duplicate (was: Assigned)
rnimmagadda@ that was really fast! Thanks a lot.

Rune@: I wanted to find out why things go so much faster. Now that we know: congratulations on such a massive improvement. I'm hoping that we have tests/etc. so that we don't regress from there on, up to you :)
Rune's CL (https://crrev.com/9c88a15f05) has a layout test, so we already have test coverage on this :)
Hurray!
@kenjibaheux: My pleasure.

Thank you.

Sign in to add a comment