Skip to content

Avoid codegen layout noise by building Wasmtime with one CGU - #348

Merged
cfallin merged 1 commit into
bytecodealliance:mainfrom
fitzgen:build-wasmtime-with-one-cgu
Oct 23, 2026
Merged

cfallin merged 1 commit into
bytecodealliance:mainfrom
fitzgen:build-wasmtime-with-one-cgu

Conversation

@fitzgen

@fitzgen fitzgen commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Building Wasmtime with one codegen unit helps us avoid codegen layout noise across commits due to functions "randomly" being inlined or not across builds of different Wasmtime commits based on whether they are in the same CGU or not.

We do not also enable LTO (or, equivalently, use Wasmtime's --profile fastest-runtime) because this would enable more "random" (across different Wasmtime commits) inlining noise between crates. With CGUs=1 and LTO disabled, the inlining boundary is very clear and related directly to the code we write and not our dependencies: anything within a crate is a candidate for inlining into function in that same crate, unless the function is marked #[inline] (or, in some cases, is generic) in which case it can be inlined across crates.

Minimizing codegen layout noise across builds of mostly-the-same Wasmtime commits is important so that when we compare the performance of, say, the latest HEAD to HEAD^, we are not, as much as possible, measuring changes due to LLVM's heuristics that could just as easily happen with any commit on top of HEAD^ and isn't actually related to what HEAD itself is doing.

r? @cfallin

Building Wasmtime with one codegen unit helps us avoid codegen layout noise
across commits due to functions "randomly" being inlined or not across builds of
different Wasmtime commits based on whether they are in the same CGU or not.

We do *not* also enable LTO (or, equivalently, use Wasmtime's `--profile
fastest-runtime`) because this would enable more "random" (across different
Wasmtime commits): inlining noise between crates. With CGUs=1 and LTO disabled,
the inlining boundary is very clear and related directly to the code we write
and not our dependencies: anything within a crate is a candidate for inlining
into function in that same crate, unless the function is marked `#[inline]` (or,
in some cases, is generic) in which case it can be inlined across crates.

Minimizing codegen layout noise across builds of mostly-the-same Wasmtime
commits is important so that when we compare the performance of, say, the latest
`HEAD` to `HEAD^`, we are not, as much as possible, measuring changes due to
LLVM's heuristics that could just as easily happen with *any* commit on top of
`HEAD^` and isn't actually related to what `HEAD` itself is doing.
@fitzgen
fitzgen requested a review from cfallin October 22, 2026 15:37
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-bytecodealliance__wasmtime that referenced this pull request Oct 22, 2026
…slicing (bytecodealliance#14940)

Otherwise, changing CGU slicing can change whether these do or don't get inlined
in practice, which makes for regressions on host-heavy
benchmarks (e.g. benchmarks that spend a bunch of time in GC).

Fixes bytecodealliance/are-we-fast-yet#8

See also bytecodealliance/sightglass#348
@cfallin
cfallin merged commit f5e20a0 into bytecodealliance:main Oct 23, 2026
11 checks passed
@fitzgen
fitzgen deleted the build-wasmtime-with-one-cgu branch October 23, 2026 19:44
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