Stream: git-wasmtime

Topic: wasmtime / PR #11626 Add a micro-benchmark for `call_indi...


view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 17:55):

fitzgen opened PR #11626 from fitzgen:call-indirect-micro-benches to bytecodealliance:main:

Compares lazy versus strict table initialization, as well as calling the same callee repeatedly versus a different callee each time.

Results on my machine, for what its worth:

call-indirect/same-callee/table-init-lazy/65536-calls
                        time:   [143.37 µs 144.78 µs 146.31 µs]
                        thrpt:  [447.93 Melem/s 452.67 Melem/s 457.11 Melem/s]
Found 3 outliers among 100 measurements (3.00%)
  1 (1.00%) high mild
  2 (2.00%) high severe
call-indirect/different-callees/table-init-lazy/65536-calls
                        time:   [2.3910 ms 2.4159 ms 2.4430 ms]
                        thrpt:  [26.826 Melem/s 27.127 Melem/s 27.410 Melem/s]
Found 14 outliers among 100 measurements (14.00%)
  12 (12.00%) high mild
  2 (2.00%) high severe
call-indirect/same-callee/table-init-strict/65536-calls
                        time:   [130.12 µs 131.28 µs 132.59 µs]
                        thrpt:  [494.27 Melem/s 499.21 Melem/s 503.65 Melem/s]
Found 9 outliers among 100 measurements (9.00%)
  4 (4.00%) high mild
  5 (5.00%) high severe
call-indirect/different-callees/table-init-strict/65536-calls
                        time:   [178.40 µs 180.80 µs 183.30 µs]
                        thrpt:  [357.53 Melem/s 362.47 Melem/s 367.36 Melem/s]
Found 2 outliers among 100 measurements (2.00%)
  2 (2.00%) high mild

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 17:55):

fitzgen requested alexcrichton for a review on PR #11626.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 17:55):

fitzgen requested wasmtime-default-reviewers for a review on PR #11626.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:20):

alexcrichton submitted PR review:

Wow so if I'm reading those numbers right lazy initialization is ~15x more expensive than not? Or put another way if you use < 1/15th of your table lazy is worth it but otherwise it's a net loss?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:20):

alexcrichton created PR review comment:

How come this has 5 elements? (vs 1 or somesuch)

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:20):

alexcrichton created PR review comment:

Any particular reason this is split across two instances?

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:21):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:26):

cfallin commented on PR #11626:

Wow so if I'm reading those numbers right lazy initialization is ~15x more expensive than not? Or put another way if you use < 1/15th of your table lazy is worth it but otherwise it's a net loss?

At least as far as post-instantiation performance -- any performance tradeoff decision would want to consider that, as well. For example the early benchmarking that led to implementing all of this did look at the end-to-end (instantiation, execution, teardown) throughput and "very sparse" usage does tend to be the case for large modules (e.g. SpiderMonkey) with instance-per-request semantics. If we don't already it'd be great to have more docs on the tradeoffs here...

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:31):

fitzgen commented on PR #11626:

Wow so if I'm reading those numbers right lazy initialization is ~15x more expensive than not? Or put another way if you use < 1/15th of your table lazy is worth it but otherwise it's a net loss?

From a purely Wasm-execution-throughput point of view, yes.

But lazy table initialization is a pretty big win for instantiation of large modules.

And then there is the usage pattern aspect as well, that Chris mentions.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:32):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:32):

fitzgen created PR review comment:

No real reason, had to choose something shrug

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:33):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 18:33):

fitzgen created PR review comment:

To defeat potential Wasm-to-CLIF frontend bounds-checking optimizations and such. Same reason we pass the callee index in as a parameter, rather than have it be a constant. Probably overkill, but not too hard to do, so why not.

view this post on Zulip Wasmtime GitHub notifications bot (Sep 05 2025 at 20:37):

fitzgen merged PR #11626.


Last updated: Dec 06 2025 at 06:05 UTC