-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Versioned dom #8227
Versioned dom #8227
Conversation
The PR in its current state needs squashing, which I'll do if it passes review. |
More comments would be nice. Review status: 0 of 6 files reviewed at latest revision, 7 unresolved discussions, some commit checks failed. components/script/dom/document.rs, line 1214 [r1] (raw file): components/script/dom/document.rs, line 1428 [r1] (raw file): components/script/dom/document.rs, line 1433 [r1] (raw file): components/script/dom/document.rs, line 1452 [r1] (raw file): components/script/dom/htmlcollection.rs, line 30 [r1] (raw file): components/script/dom/htmlcollection.rs, line 171 [r1] (raw file): components/script/dom/htmlcollection.rs, line 282 [r1] (raw file): Comments from the review on Reviewable.io |
Thanks! I'll have a look at your review comments tomorrow. Also get test-tidy to pass, sigh. |
Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. components/script/dom/document.rs, line 1214 [r1] (raw file): components/script/dom/document.rs, line 1428 [r1] (raw file): components/script/dom/htmlcollection.rs, line 30 [r1] (raw file): Comments from the review on Reviewable.io |
Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. components/script/dom/htmlcollection.rs, line 30 [r1] (raw file): Comments from the review on Reviewable.io |
Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. components/script/dom/htmlcollection.rs, line 30 [r1] (raw file): Comments from the review on Reviewable.io |
Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, some commit checks failed. components/script/dom/document.rs, line 1428 [r1] (raw file): Comments from the review on Reviewable.io |
Because of rooting? Hmm... that sounds like we just need to update the whitelist in the lint plugin; |
The problem isn't that Entry needs rooted, it's that the code would end up being something like: self.foo_map.entry(key).or_insert(|| mk_foo().r() ).root() that is, in the case of a cache miss, we build a rooted result, then unroot it, then root it again. This is because the cache is being kept unrooted: should the cache be the rooted versions? Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. Comments from the review on Reviewable.io |
That doesn't seem like a big deal; rooting isn't an expensive operation. If you really want to avoid it, you can do Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. Comments from the review on Reviewable.io |
I believe that @asajeffrey has shown that rooting is expensive. It's certianly showing up in his profiles from what I understand. |
The problem with rooting is that it uses a Vec for roots, so the code includes the case where the vector has to grow, which means problems for code inlining. It's more of a code size and optimization problem than a time problem, since in the common case rooting is just a vector push into a vector which already has enough backing store. I'll update to using HashMap::entry. Review status: 0 of 6 files reviewed at latest revision, 3 unresolved discussions, all commit checks successful. Comments from the review on Reviewable.io |
@bors-servo: try |
1 similar comment
@bors-servo: try |
Versioned dom This PR adds versioning to the DOM. There are now node.get_version and node.get_descendent_version methods that return a counter that is bumped when the node is dirtied. This is used to implement cache invalidation for caching HTMLCollection state. Caching HTMCollections gets a 1000x speedup in the Dromaeo DOM query tests. Addresses #6901, #3381 and #1916. Replaces PR #6927. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8227) <!-- Reviewable:end -->
💔 Test failed - linux-rel |
(Artificial failure) |
☔ The latest upstream changes (presumably #8262) made this pull request unmergeable. Please resolve the merge conflicts. |
89248e8
to
854675e
Compare
I responded to @eefriedman and rebased to builld with master. Anything else? |
@eefriedman Are you doing a full review of this, or just drive-by? Please set the assignee field for the former, so it's clear who's responsible for the next step here. |
I'll try to merge #8315, and then you can rebase. |
Thanks! I'll rebase... Grumble mutter dependent PRs. |
There is now an inclusive_descendants_version field of each node, which increases each time the node, or any of its descendants, is dirtied. This can be used for cache invalidation, by caching a version number and comparting the current version number against the cached version number.
We cache the state of any live HTMLCollection, keeping track of a) the optional cached length of the collection, and b) an optional cursor into the collection (a node in the collection plus its index). The cache is invalidated based on the version number of the node. We use these caches for speeding up random access to the collection. When returning coll[i], we search from the cursor, if it exists, and otherwise search from the front of the collection. In particular, both a forward for-loop and a backward for-loop through the collection will now have each access take O(1) time rather than O(n) time. This gets 1000x speed-up on the relevant Dromaeo DOM query tests.
3e4cc15
to
237ddc3
Compare
@bors-servo r+ |
📌 Commit 237ddc3 has been approved by |
⌛ Testing commit 237ddc3 with merge 9dbd5dd... |
Versioned dom This PR adds versioning to the DOM. There are now node.get_version and node.get_descendent_version methods that return a counter that is bumped when the node is dirtied. This is used to implement cache invalidation for caching HTMLCollection state. Caching HTMCollections gets a 1000x speedup in the Dromaeo DOM query tests. Addresses #6901, #3381 and #1916. Replaces PR #6927. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8227) <!-- Reviewable:end -->
💔 Test failed - gonk |
@bors-servo retry #8416 |
⌛ Testing commit 237ddc3 with merge f39faaf... |
Versioned dom This PR adds versioning to the DOM. There are now node.get_version and node.get_descendent_version methods that return a counter that is bumped when the node is dirtied. This is used to implement cache invalidation for caching HTMLCollection state. Caching HTMCollections gets a 1000x speedup in the Dromaeo DOM query tests. Addresses #6901, #3381 and #1916. Replaces PR #6927. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8227) <!-- Reviewable:end -->
☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt |
This PR adds versioning to the DOM. There are now node.get_version and node.get_descendent_version methods that return a counter that is bumped when the node is dirtied. This is used to implement cache invalidation for caching HTMLCollection state. Caching HTMCollections gets a 1000x speedup in the Dromaeo DOM query tests.
Addresses #6901, #3381 and #1916.
Replaces PR #6927.