Repository navigation
Limit alias regions in Wasm-to-CLIF translation to 256 - #14253
Conversation
|
This fixes the problem I reported in #14210. I used the generator script from that issue and ran
Time roughly doubles when N doubles, out to N=8000. The blowup is gone and my FYI, the RPO worklist from #14211 is still 3-5x faster on top of this PR One request: if this misses the 49.0.0 branch on the 5th, could it be |
cfallin
left a comment
There was a problem hiding this comment.
Review on the last commit only (the lattice commit still has work in progress as I understand it from our discussion yesterday, re: scoped hashmap and such).
My main concern with the machinery here is the description-string complexity. Seeing the "reverse map" that keeps original identities around, and especially the string-joining machinery, inside Cranelift itself, both (i) raises serious efficiency concerns for me (we may be at a net speedup by preventing alias-analysis state blowup, but we are still introducing a lot of string munging to produce strings that most compilations will never need), and (ii) seems more complex than it needs to be.
I wonder if we could simply drop the descriptions, and instead emit log::trace lines for mapping of alias-region keys to Cranelift region numbers, and let that suffice for debugging? It seems that all the same information would be there, but we wouldn't be eagerly computing then throwing it away on every compilation...
b6f8585 to
50502ed
Compare
|
(There's a clippy failure on a |
Instead of bitpacking the `AliasRegionKey` into a `u32`, hash it and then `xor`-fold the hash down to one byte. Fixes bytecodealliance#14221
4deeb9b to
5e00554
Compare
* Use one alias region per runtime-data array With copy-on-write memory initialization disabled (or when a module's data segments can't be made into a static image), the module startup function initializes every data segment, loading each segment's base and length out of the `VMContext`. Each of those loads got an alias region keyed by its own `VMContext` offset, so a module with more than ~32k data segments needs more distinct `MemFlags` than a Cranelift function can hold and compilation panics with `MemFlagsSetOverflow`. Modules compiled by Go routinely have tens of thousands of data segments. Key the region on the start of the `runtime_data_bases` and `runtime_data_lengths` arrays instead, giving each array a single region. This is only ever coarser than before. On `main` this is covered by #14253, which bounds the number of alias regions in general. Claude-Session: https://claude.ai/code/session_01EHmbaDcapmSnyJtjfAGMtR * Remove the now-unused `vmctx_store` helper Its only caller was `store_vmctx_runtime_data_length`, which now picks its alias region from the start of the runtime-data lengths array. Claude-Session: https://claude.ai/code/session_01EHmbaDcapmSnyJtjfAGMtR
Instead of bitpacking the
AliasRegionKeyinto au32, hash it and thenxor-fold the hash down to one byte.Fixes #14221
Depends on #14230