Skip to content

perf: remove pointer-dereference using owned version of visit_operator - #2638

Closed
dishmaker wants to merge 1 commit into
bytecodealliance:mainfrom
dishmaker:dishmaker/perf_wasmparser_skip_operators
Closed

perf: remove pointer-dereference using owned version of visit_operator#2638
dishmaker wants to merge 1 commit into
bytecodealliance:mainfrom
dishmaker:dishmaker/perf_wasmparser_skip_operators

Conversation

@dishmaker

@dishmaker dishmaker commented Sep 6, 2026

Copy link
Copy Markdown

This changes Visitor from &mut V to V, in order to reduce pointer dereferences.

I did also optimize skip_const_expr, which showed up in flamegraph of:
wasmtime compile foo.wasm from bytecodealliance/wasmtime#14260

image
     Running benches/benchmark.rs
parse/tests             time:   [7.4698 ms 7.4766 ms 7.4874 ms]
                        change: [−2.7403% −2.5706% −2.4035%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  2 (2.00%) high mild
  1 (1.00%) high severe

validate/tests          time:   [43.371 ms 43.406 ms 43.441 ms]
                        change: [−0.6950% −0.5781% −0.4792%] (p = 0.00 < 0.05)
                        Change within noise threshold.

@dishmaker
dishmaker marked this pull request as ready for review September 6, 2026 19:01
@dishmaker
dishmaker requested a review from a team as a code owner September 6, 2026 19:01
@dishmaker
dishmaker requested review from alexcrichton and removed request for a team September 6, 2026 19:01
@alexcrichton

Copy link
Copy Markdown
Member

Thanks! Would you be ok splitting out the skip-const-expr change?

Otherwise for the change here I'm less sure. From an ergonomics/design point of view it seems worse to me to use T instead of &mut T (e.g. impls on &mut T or similar) and the performance gain here seems pretty modest (insofar as validation is the main bottleneck I'd imagine to optimize as opposed to pure parsing). Do you have other changes/improvements that depend on this though?

@dishmaker

Copy link
Copy Markdown
Author

Ok, I will split the changes.

And no, I don't have other improvements.

@dishmaker
dishmaker force-pushed the dishmaker/perf_wasmparser_skip_operators branch from 925fd23 to 7e2ce16 Compare September 8, 2026 21:06
@dishmaker

Copy link
Copy Markdown
Author

Looks like performance didn't change, so I will close this.

parse/tests             time:   [7.7166 ms 7.7221 ms 7.7306 ms]
                        change: [−0.1755% −0.0743% +0.0518%] (p = 0.22 > 0.05)
                        No change in performance detected.
parse/tests             time:   [7.6719 ms 7.6761 ms 7.6818 ms]
                        change: [−1.6105% −1.4575% −1.3167%] (p = 0.00 < 0.05)
                        Performance has improved.
parse/tests             time:   [7.6793 ms 7.6863 ms 7.6951 ms]
                        change: [−1.1005% −0.9505% −0.8061%] (p = 0.00 < 0.05)
                        Change within noise threshold.
parse/tests             time:   [7.7045 ms 7.7109 ms 7.7184 ms]
                        change: [−0.6210% −0.4954% −0.3695%] (p = 0.00 < 0.05)
                        Change within noise threshold.
parse/tests             time:   [7.7282 ms 7.7378 ms 7.7499 ms]
                        change: [+0.0477% +0.2031% +0.3622%] (p = 0.01 < 0.05)
                        Change within noise threshold.

validate/tests          time:   [44.517 ms 44.549 ms 44.584 ms]
                        change: [+0.9563% +1.0937% +1.2295%] (p = 0.00 < 0.05)
                        Change within noise threshold.
validate/tests          time:   [44.146 ms 44.189 ms 44.239 ms]
                        change: [−0.4287% −0.3231% −0.2004%] (p = 0.00 < 0.05)
                        Change within noise threshold.
validate/tests          time:   [44.129 ms 44.175 ms 44.223 ms]
                        change: [+0.5087% +0.6453% +0.7659%] (p = 0.00 < 0.05)
                        Change within noise threshold.
validate/tests          time:   [44.397 ms 44.432 ms 44.469 ms]
                        change: [+0.6127% +0.7145% +0.8122%] (p = 0.00 < 0.05)
                        Change within noise threshold.
validate/tests          time:   [44.170 ms 44.202 ms 44.236 ms]
                        change: [−0.0238% +0.1051% +0.2291%] (p = 0.11 > 0.05)
                        No change in performance detected.

@dishmaker dishmaker closed this Sep 8, 2026
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.

2 participants