Stream: git-wasmtime

Topic: wasmtime / PR #12483 Implement branch hinting proposal su...


view this post on Zulip Wasmtime GitHub notifications bot (Jan 31 2026 at 09:44):

gfx opened PR #12483 from wado-lang:gfx/branch_hinting to bytecodealliance:main:

This PR adds support for the WebAssembly branch hinting proposal by parsing the metadata.code.branch_hint custom section and using the hints to mark cold blocks during Cranelift code generation.

Implementation details:

Branch hints are always parsed and applied when present in a module; no configuration flag is required.

A disassembly test is included to verify cold block annotations, but official WebAssembly spec tests for this proposal are not yet available.

Closes #9463

<!--
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 (Jan 31 2026 at 09:44):

gfx requested wasmtime-compiler-reviewers for a review on PR #12483.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 31 2026 at 09:44):

gfx requested fitzgen for a review on PR #12483.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 31 2026 at 09:44):

gfx requested wasmtime-core-reviewers for a review on PR #12483.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 31 2026 at 09:44):

gfx requested wasmtime-default-reviewers for a review on PR #12483.

view this post on Zulip Wasmtime GitHub notifications bot (Jan 31 2026 at 10:07):

gfx edited PR #12483:

This PR adds support for the WebAssembly branch hinting proposal by parsing the metadata.code.branch_hint custom section and using the hints to mark cold blocks during Cranelift code generation.

Implementation details:

Branch hints are always parsed and applied when present in a module; no configuration flag is required.

A disassembly test is included to verify cold block annotations, but official WebAssembly spec tests for this proposal are not yet available.

Closes #9463

Question: should I add a knob to enable/disable this feature? Currently, this is automatically turned on. I'm not sure I should add an option for it.

<!--
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 (Jan 31 2026 at 11:46):

github-actions[bot] added the label wasmtime:docs on PR #12483.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2026 at 04:22):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2026 at 04:22):

alexcrichton created PR review comment:

This loop I think might be good to optimize in terms of translation will only lookup branch hints (I think?) in increasing order of offsets. That means that currently this code is an $O(n^2)$ loop as-implemented. That could be optimized by using a binary search here, but I think this could go one step further and, ideally, store a reference to the raw buffer of input wasm data (in theory) here. For example this could be a .peekable() iterator over the raw wasm itself. Looking up via get_branch_hint would advance the iterator if it's at the matching position.

Regardless I think it'll be needed to remove the quadratic behavior here, and I think ideally it'd be via an iterator-like approach to avoid the logarithmic nature of a binary search.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2026 at 18:25):

fitzgen submitted PR review:

Question: should I add a knob to enable/disable this feature? Currently, this is automatically turned on. I'm not sure I should add an option for it.

Yes, I think we should have a config knob for this.

And to follow our rules by the letter, we we shouldn't enable it by default until it is fuzzed (and has been fuzzed for a couple weeks). This would most likely involve adding support to wasm-smith for emitting branch hints.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 02 2026 at 18:26):

fitzgen submitted PR review:

Question: should I add a knob to enable/disable this feature? Currently, this is automatically turned on. I'm not sure I should add an option for it.

Yes, I think we should have a config knob for this.

And to follow our rules by the letter, we we shouldn't enable it by default until it is fuzzed (and has been fuzzed for a couple weeks). This would most likely involve adding support to wasm-smith for emitting branch hints.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2026 at 00:18):

gfx updated PR #12483.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2026 at 00:19):

gfx submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2026 at 00:19):

gfx created PR review comment:

Ah, you are right.

How about bc62088d6f7b31712badb427fd37e18c3c410a95 for O(n) complexity?

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2026 at 00:40):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2026 at 00:40):

cfallin created PR review comment:

What Alex is getting at, i think, is that the spec states that the hints are given in PC order. So why not traverse hints in order, taking them when they match as we visit increasing PC offsets? We should be able to that in O(n) time with O(1) space overhead, i.e., not building a HashMap at all.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2026 at 00:40):

cfallin edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 10 2026 at 11:49):

AlbertMarashi commented on PR #12483:

How nice, I was just going to start using this - great to see it's being worked on!


Last updated: Feb 24 2026 at 04:36 UTC