New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tweak HTML parser yielding #9394
Tweak HTML parser yielding #9394
Conversation
EWS run on previous version of this PR (hash df59f34) |
Seems like a neat idea to me; but I'd like to get Alan or Antti's opinion too. |
@@ -120,6 +120,9 @@ bool HTMLParserScheduler::shouldYieldBeforeExecutingScript(const ScriptElement* | |||
if (UNLIKELY(m_documentHasActiveParserYieldTokens)) | |||
return true; | |||
|
|||
if (document->view() && !document->view()->hasEverPainted() && document->isLayoutPending()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's funny there is a comment above saying:
If we've never painted before and a layout is pending, yield prior to running
scripts to give the page a chance to paint earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :) I should probably move that comment down to the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing!
if (document->view() && !document->view()->hasEverPainted() && document->isLayoutPending()) | ||
return true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should also A/B test moving the "if (scriptElement)" block above this line. Forcing layout just because we parse an async or defer script tag seems wrong. Forcing layout before we execute a short inline script seems like an experimental question.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a good point, I will schedule that A/B test.
Thanks for reviewing!
Does this "page load metrics" include time for first display (when we decide to show content to the user)? Curious if this has any impact on it (since now we may delay that pending layout potentially producing paints at a later time). |
(though also one could argue that processing more content first could lead to a non-empty layout sooner) |
Yes, first meaningful paint is one of these page load metrics. So far, it looks like this change will improve this metric on some of the pages, but I am looking to run more tests. Thanks for reviewing! |
df59f34
to
2e8d963
Compare
EWS run on current version of this PR (hash 2e8d963) |
https://bugs.webkit.org/show_bug.cgi?id=228780 rdar://81517847 Reviewed by Ryosuke Niwa. Tweak html parser yielding to attempt to improve page load performance with respect to certain page load metrics. This patch makes the parser yield if the page has not painted before and meaningful content has been loaded. So far, this looks like a 1-2% improvement in page load times. * Source/WebCore/html/parser/HTMLParserScheduler.cpp: (WebCore::HTMLParserScheduler::shouldYieldBeforeExecutingScript): Canonical link: https://commits.webkit.org/260011@main
2e8d963
to
6ce95a8
Compare
Committed 260011@main (6ce95a8): https://commits.webkit.org/260011@main Reviewed commits have been landed. Closing PR #9394 and removing active labels. |
@pvollan This seems to have caused 60+ test failures on mac tester queues. EWS (unfinished) build on this PR also had failures, see https://ews-build.webkit.org/#/builders/73/builds/27722 Failures on post-commit bots: https://build.webkit.org/#/builders/48 |
6ce95a8
2e8d963
π§ͺ ios-wk2π§ͺ gtk-wk2π§ͺ mac-wk1π§ͺ api-gtkπ§ͺ mac-wk2π§ͺ mac-AS-debug-wk2