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:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
fitzgen requested alexcrichton for a review on PR #11626.
fitzgen requested wasmtime-default-reviewers for a review on PR #11626.
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?
alexcrichton created PR review comment:
How come this has 5 elements? (vs 1 or somesuch)
alexcrichton created PR review comment:
Any particular reason this is split across two instances?
alexcrichton submitted PR review.
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...
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.
fitzgen submitted PR review.
fitzgen created PR review comment:
No real reason, had to choose something shrug
fitzgen submitted PR review.
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.
fitzgen merged PR #11626.
Last updated: Dec 06 2025 at 06:05 UTC