Copying collector: Store most tracing info inline in the object header#13495
Open
fitzgen wants to merge 1 commit into
Open
Copying collector: Store most tracing info inline in the object header#13495fitzgen wants to merge 1 commit into
fitzgen wants to merge 1 commit into
Conversation
We have a number of available bits inside the `VMGcHeader`. This commit uses
them to bitpack the following type:
```rust
pub enum InlineTraceInfo {
/// The trace info is not encoded inline. Look it up from `TraceInfos`.
OutOfLine,
/// Inline trace info for an array type.
Array {
/// Whether the array's elements are GC references that need tracing.
elems_are_gc_refs: bool,
},
/// Inline trace info for a struct, exception, or externref type.
Struct {
/// A bitmap where the `i`th bit is set iff the `i`th `u32` in the
/// object's data (after the header) is a `VMGcRef` that needs
/// tracing. Only the lower 23 bits are meaningful.
gc_ref_bitmap: u32,
},
}
```
This allows us to encode the majority of objects' GC edges inline in the GC
object header, avoiding the need to perform expensive hash map lookups in the
common case.
This results in a 7-8% speed up on `splay.wasm` in Sightglass:
```
execution :: cycles :: benchmarks/splay/splay.wasm
Δ = 5858240.88 ± 445613.91 (confidence = 99%)
inline-trace-info.dylib (-Ccollector=copying -Wgc,function-references) is 1.07x to 1.08x faster than main.dylib (-Ccollector=copying -Wgc,function-references)!
[77193983 79604574.70 88386948] inline-trace-info.dylib (-Ccollector=copying -Wgc,function-references)
[83057364 85462815.58 92545612] main.dylib (-Ccollector=copying -Wgc,function-references)
```
490258c to
f078ef9
Compare
alexcrichton
approved these changes
May 27, 2026
Subscribe to Label Actioncc @fitzgen DetailsThis issue or pull request has been labeled: "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have a number of available bits inside the
VMGcHeader. This commit uses them to bitpack the following type:This allows us to encode the majority of objects' GC edges inline in the GC object header, avoiding the need to perform expensive hash map lookups in the common case.
This results in a 7-8% speed up on
splay.wasmin Sightglass: