Skip to content
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

Add a fast path in Element::SetInnerHTML when the value is small and trivial text #26398

Merged
merged 1 commit into from May 4, 2020

Conversation

@Eijebong
Copy link
Member

Eijebong commented May 3, 2020

Inspired from gecko which has a similar fast path. This makes innerHTML
more than 10 times faster for this case.

Fixes #25892

@highfive
Copy link

highfive commented May 3, 2020

Heads up! This PR modifies the following files:

  • @asajeffrey: components/script/dom/htmltablesectionelement.rs, components/script/dom/htmltablecolelement.rs, components/script/dom/node.rs, components/script/dom/element.rs, components/script/dom/htmltablerowelement.rs and 6 more
  • @KiChjang: components/script/dom/htmltablesectionelement.rs, components/script/dom/htmltablecolelement.rs, components/script/dom/node.rs, components/script/dom/element.rs, components/script/dom/htmltablerowelement.rs and 6 more
@highfive
Copy link

highfive commented May 3, 2020

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

tests/html/test_dom_performance.html
Before:

After:

@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

@bors-servo try=wpt

@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

Trying commit 4fec5d6 with merge 3e00866...

bors-servo added a commit that referenced this pull request May 3, 2020
Add a fast path in Element::SetInnerHTML when the value is small and trivial text

Inspired from gecko which has a similar fast path. This makes innerHTML
more than 10 times faster for this case.

Fixes #25892
@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

💔 Test failed - status-taskcluster

@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

1 unexpected results that are NOT known-intermittents:
  ▶ Unexpected subtest result in /html/syntax/parsing/html5lib_innerHTML_tests_innerHTML_1.html:
  │ FAIL [expected PASS] html5lib_innerHTML_tests_innerHTML_1.html 2555d238e04f3d2853cfbc5f6dd366f82cf0e868
  │   → assert_equals: expected "#document\n| <head>\n| <body>" but got "#document"
  │ 
  │ test_fragment@http://web-platform.test:8000/html/syntax/parsing/test.js:217:16
  │ test_next/</<@http://web-platform.test:8000/html/syntax/parsing/test.js:330:29
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1988:25
  │ test_next/<@http://web-platform.test:8000/html/syntax/parsing/test.js:324:20
  └ step_timeout/<@http://web-platform.test:8000/resources/testharness.js:937:15

I have no idea what this test is even supposed to be. There's a 18391 character long line in there with what looks like sha1sums everywhere... 😕

@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

My guess is that gecko also blacklists HTMLSharedElement but there's no such thing in servo.

https://searchfox.org/mozilla-central/source/dom/html/HTMLSharedElement.h#20

The documentation here is missing so I have no idea what they even are.

@Eijebong Eijebong force-pushed the Eijebong:fast-path-set-inner-html branch from 4fec5d6 to 207c477 May 3, 2020
@highfive highfive removed the S-tests-failed label May 3, 2020
@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

@bors-servo try=wpt

bors-servo added a commit that referenced this pull request May 3, 2020
Add a fast path in Element::SetInnerHTML when the value is small and trivial text

Inspired from gecko which has a similar fast path. This makes innerHTML
more than 10 times faster for this case.

Fixes #25892
@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

Trying commit 207c477 with merge 31ad6e1...

@jdm
Copy link
Member

jdm commented May 3, 2020

Judging by https://searchfox.org/mozilla-central/rev/b9a814e53b3b6f5cb665a78f4777868e7a16bfcd/dom/html/HTMLSharedElement.cpp#273-293, HTMLSharedElement looks like a class that is used as the implementation for a bunch of HTML elements that each have one or two custom behaviours to reduce code duplication.

@jdm
Copy link
Member

jdm commented May 3, 2020

I suspect that you're missing weird parsing mode for the head element, judging by https://searchfox.org/mozilla-central/rev/b9a814e53b3b6f5cb665a78f4777868e7a16bfcd/dom/html/HTMLSharedElement.h#25-27 and the test contents being (pre-decoded) "%23document%0A%7C%20%3Chead%3E%0A%7C%20%3Cbody%3E".

@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

I was actually missing it for HtmlHtmlElement. With my current patch the test seems to be ok. We'll see if something else is broken

@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

💔 Test failed - status-taskcluster

@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

TIMEOUT [expected OK] /_webgl/conformance/glsl/misc/struct-nesting-of-variable-names.html

Hopefully unrelated :p

@jdm
Copy link
Member

jdm commented May 3, 2020

I argue that you are also missing it from HTMLHeadElement given the code that I linked :)

@Eijebong
Copy link
Member Author

Eijebong commented May 3, 2020

Oh wow I somehow missed those lines when I read it... Will add for htmlheadelement

@Eijebong Eijebong force-pushed the Eijebong:fast-path-set-inner-html branch from 207c477 to f01801d May 3, 2020
@highfive highfive removed the S-tests-failed label May 3, 2020
@jdm
Copy link
Member

jdm commented May 3, 2020

@bors-servo r+
Thanks!

@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

📌 Commit f01801d has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

Testing commit f01801d with merge 0a774b7...

bors-servo added a commit that referenced this pull request May 3, 2020
Add a fast path in Element::SetInnerHTML when the value is small and trivial text

Inspired from gecko which has a similar fast path. This makes innerHTML
more than 10 times faster for this case.

Fixes #25892
@bors-servo
Copy link
Contributor

bors-servo commented May 3, 2020

💔 Test failed - status-taskcluster

components/script/dom/element.rs Outdated Show resolved Hide resolved
…trivial text

Inspired from gecko which has a similar fast path. This makes innerHTML
more than 10 times faster for this case.

Fixes #25892
@Eijebong Eijebong force-pushed the Eijebong:fast-path-set-inner-html branch from f01801d to 1b2464b May 4, 2020
@jdm
Copy link
Member

jdm commented May 4, 2020

@bors-servo
Copy link
Contributor

bors-servo commented May 4, 2020

📌 Commit 1b2464b has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented May 4, 2020

Testing commit 1b2464b with merge 271ff16...

@bors-servo
Copy link
Contributor

bors-servo commented May 4, 2020

☀️ Test successful - status-taskcluster
Approved by: jdm
Pushing 271ff16 to master...

@bors-servo bors-servo merged commit 271ff16 into servo:master May 4, 2020
2 checks passed
2 checks passed
Community-TC (pull_request) TaskGroup: success
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

6 participants
You can’t perform that action at this time.