script: Replace raw pointer comparison with == for DOM identity comparison - #46718
Merged
Conversation
kkoyung
approved these changes
Jul 22, 2026
pull Bot
pushed a commit
to xtqqczze/servo-servo
that referenced
this pull request
Jul 27, 2026
Unlike claimed in servo#46678 (comment) and servo#46718, the result from benchmark is counter-intuitive. `std::ptr::eq` is actually 15% slower than https://github.com/servo/servo/blob/fc340087b7411d5d736ad8705581baf16b567b1c/components/dom_struct/lib.rs#L154-L156. The benchmark mimics the one used in servo#35323. Testing: `.\mach exec cargo bench -p servo-script-bindings` ``` Running benches.rs (target\release\deps\dom_partial_eq-8ef5af22310fd8f7.exe) ptr_eq_same time: [598.35 ps 602.22 ps 606.18 ps] Found 4 outliers among 100 measurements (4.00%) 1 (1.00%) low mild 1 (1.00%) high mild 2 (2.00%) high severe ptr_eq_different time: [615.17 ps 619.21 ps 623.09 ps] Found 3 outliers among 100 measurements (3.00%) 1 (1.00%) high mild 2 (2.00%) high severe dom_eq_same time: [514.00 ps 519.76 ps 525.78 ps] Found 5 outliers among 100 measurements (5.00%) 3 (3.00%) high mild 2 (2.00%) high severe dom_eq_different time: [514.45 ps 520.22 ps 526.39 ps] Found 6 outliers among 100 measurements (6.00%) 1 (1.00%) low mild 4 (4.00%) high mild 1 (1.00%) high severe ``` Also, production profile `.\mach exec cargo bench --profile production -p servo-script-bindings` is always slower than default. --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As mentioned in #46678 (comment), we should rely on
PartialEqfor all cases, so that we just need to optimize a single point.Testing: This would be slightly slower because of
servo/components/dom_struct/lib.rs
Lines 154 to 156 in fc34008
Part of #34464