Skip to content

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

Merged
bors-servo merged 1 commit into
servo:masterfrom
Eijebong:fast-path-set-inner-html
May 4, 2020
Merged

bors-servo merged 1 commit into
servo:masterfrom
Eijebong:fast-path-set-inner-html

Conversation

@Eijebong

@Eijebong Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor

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

Fixes #25892

@highfive

highfive commented May 3, 2020

Copy link
Copy Markdown

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

highfive commented May 3, 2020

Copy link
Copy Markdown

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 3, 2020
@Eijebong

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

tests/html/test_dom_performance.html
Before:

After:

@Eijebong

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

@bors-servo try=wpt

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ 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
Copy Markdown
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label May 3, 2020
@Eijebong

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author
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

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

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 fast-path-set-inner-html branch from 4fec5d6 to 207c477 Compare May 3, 2020 15:42
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label May 3, 2020
@Eijebong

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
Contributor

⌛ Trying commit 207c477 with merge 31ad6e1...

@jdm

jdm commented May 3, 2020

Copy link
Copy Markdown
Member

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

jdm commented May 3, 2020

Copy link
Copy Markdown
Member

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

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label May 3, 2020
@Eijebong

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

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

Hopefully unrelated :p

@jdm

jdm commented May 3, 2020

Copy link
Copy Markdown
Member

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

@Eijebong

Eijebong commented May 3, 2020

Copy link
Copy Markdown
Contributor Author

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

@Eijebong
Eijebong force-pushed the fast-path-set-inner-html branch from 207c477 to f01801d Compare May 3, 2020 17:58
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label May 3, 2020
@jdm

jdm commented May 3, 2020

Copy link
Copy Markdown
Member

@bors-servo r+
Thanks!

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit f01801d has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 3, 2020
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ 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
Copy Markdown
Contributor

💔 Test failed - status-taskcluster

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels May 3, 2020
Comment thread components/script/dom/element.rs Resolved
…trivial text

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

Fixes servo#25892
@Eijebong
Eijebong force-pushed the fast-path-set-inner-html branch from f01801d to 1b2464b Compare May 4, 2020 16:12
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels May 4, 2020
@jdm

jdm commented May 4, 2020

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 1b2464b has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 4, 2020
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 1b2464b with merge 271ff16...

@bors-servo

Copy link
Copy Markdown
Contributor

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

@bors-servo
bors-servo merged commit 271ff16 into servo:master May 4, 2020
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling innerHTML setter with text-only data is inefficient

6 participants