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 #9925
Tweak HTML parser yielding #9925
Conversation
EWS run on previous version of this PR (hash b6c01b2) |
// Only yield if there has been progress since last yield. | ||
if (session.processedTokens > session.processedTokensOnLastYield) { | ||
session.processedTokensOnLastYield = session.processedTokens; | ||
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.
Can you think of any case where this check would be false, and we would want to yield anyway? If not, then I think this check belongs inside shouldYieldBeforeExecutingScript. Because our observation is that you should not yield if you haven't made any progress yet.
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.
Also session.processedTokensOnLastYield is not a great name since this is only updated on a before-script yield yet there is another yield path too (shouldYieldBeforeToken()
).
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.
Can you think of any case where this check would be false, and we would want to yield anyway? If not, then I think this check belongs inside shouldYieldBeforeExecutingScript. Because our observation is that you should not yield if you haven't made any progress yet.
That is a good point. I cannot think of such a case, and moved the check inside shouldYieldBeforeExecutingScript.
Thanks for reviewing!
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.
Also session.processedTokensOnLastYield is not a great name since this is only updated on a before-script yield yet there is another yield path too (
shouldYieldBeforeToken()
).
Ah, yes, that is a good point. In the latest patch I have updated the name, which is hopefully more accurate.
Thanks for reviewing!
b6c01b2
to
f8f930e
Compare
EWS run on current version of this PR (hash f8f930e) |
f8f930e
to
0c0f933
Compare
static bool parsingProgressedSinceLastYield(PumpSession& session) | ||
{ | ||
// Only yield if there has been progress since last yield. | ||
if (session.processedTokens > session.processedTokensOnLastYieldBeforeScript) { | ||
session.processedTokensOnLastYieldBeforeScript = session.processedTokens; |
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.
The name of the variable session.processedTokensOnLastYieldBeforeScript
is not super accurate since we only update it if we get here.
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.
Ah, yes, that is a good point. Since the name is already quite long, I wonder if we should look into calling this function in the other places where we yield before executing a script, since we should not yield if there hasn't been any progress on parsing. I will look into that in a follow-up patch.
Thanks for reviewing!
0c0f933
to
6f5ee38
Compare
https://bugs.webkit.org/show_bug.cgi?id=228780 rdar://81517847 Reviewed by Antti Koivisto. 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. Also make sure that the parser only yields before executing scripts if there has been parsing progress since the last yield. Measurements show that this is a 1-2% improvement in page load times. This change also revealed a race condition in a test, where a call to notifyDone() in an inline script was racing with a call to waitForDone() in a script with SRC attribute. This race was resolved by starting the test in the onload handler. * LayoutTests/fast/forms/focus-option-control-on-page.html: * Source/WebCore/html/parser/HTMLParserScheduler.cpp: (WebCore::HTMLParserScheduler::shouldYieldBeforeExecutingScript): * Source/WebCore/html/parser/HTMLParserScheduler.h: Canonical link: https://commits.webkit.org/261705@main
6f5ee38
to
f17bb5a
Compare
Committed 261705@main (f17bb5a): https://commits.webkit.org/261705@main Reviewed commits have been landed. Closing PR #9925 and removing active labels. |
f17bb5a
0c0f933