alexcrichton opened PR #13843 from alexcrichton:no-ensure-trace-info to bytecodealliance:main:
This commit removes all
ensure_trace_infomethods from all GC
collectors, the GC store, etc. The goal of this commit is to accelerate
instantiation of modules that use GC by avoiding using the read-write
lock on theTypeRegistrystored within the engine. As shown in https://github.com/bytecodealliance/wasmtime/pull/13822
even in read-only situations this comes with a significant performance
penalty.The strategy taken in this commit is to take an alternative route of
handling trace information, empowered by the previous commit. Notably
trace information is now all available atModule-creation time, for
example, and need not be re-calculated for each store. The main
difficulty is then looking up this trace information at runtime when a
GC is performed. This commit implements functionality whereTraceInfos
is repurposed as a cache rather than a storage table. The cache stores
where the trace information is located, and then trace information is
looked up where it lies at-rest within aModuleorRegisteredType.This means that the first time a type is traced within a store it
requires a search to determine where the trace information is located.
Right now this involves two locations:
If a store's
gc_host_alloc_typesmaps contains the type index, then
that's where the trace information is located.Otherwise a module previously inserted into a store's
ModuleRegistry
must have trace information. The entire registry is searched and each
module is consulted to determine if it has trace information for the
type index in question.The
TraceInfoscache is intended to amortize this cost of a lookup.
This lookup is additionally mitigated in the copying collector where
this is only required for "big structs" where their tracing information
can't be stored inline in the object header itself. Overall it's
expected that for the copying collector this change has little effect on
typical GC performance itself.Additionally overall, however, this eliminates usage of the read/write
lock in theTypeRegistryentirely during instantiation. Eliminating
this lock acquisition was the goal of this commit, and this is expected
to help improve parallel instantiation performance of GC-using modules.Note: this is currently built on #13842
alexcrichton requested fitzgen for a review on PR #13843.
alexcrichton requested wasmtime-core-reviewers for a review on PR #13843.
alexcrichton updated PR #13843.
alexcrichton updated PR #13843.
alexcrichton requested wasmtime-default-reviewers for a review on PR #13843.
alexcrichton updated PR #13843.
alexcrichton updated PR #13843.
alexcrichton updated PR #13843.
github-actions[bot] added the label wasmtime:api on PR #13843.
github-actions[bot] added the label wasmtime:ref-types on PR #13843.
github-actions[bot] commented on PR #13843:
Subscribe to Label Action
cc @fitzgen
<details>
This 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:
- fitzgen: wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
alexcrichton updated PR #13843.
alexcrichton edited PR #13843:
This commit removes all
ensure_trace_infomethods from all GC
collectors, the GC store, etc. The goal of this commit is to accelerate
instantiation of modules that use GC by avoiding using the read-write
lock on theTypeRegistrystored within the engine. As shown in https://github.com/bytecodealliance/wasmtime/pull/13822
even in read-only situations this comes with a significant performance
penalty.The strategy taken in this commit is to take an alternative route of
handling trace information, empowered by the previous commit. Notably
trace information is now all available atModule-creation time, for
example, and need not be re-calculated for each store. The main
difficulty is then looking up this trace information at runtime when a
GC is performed. This commit implements functionality whereTraceInfos
is repurposed as a cache rather than a storage table. The cache stores
where the trace information is located, and then trace information is
looked up where it lies at-rest within aModuleorRegisteredType.This means that the first time a type is traced within a store it
requires a search to determine where the trace information is located.
Right now this involves two locations:
If a store's
gc_host_alloc_typesmaps contains the type index, then
that's where the trace information is located.Otherwise a module previously inserted into a store's
ModuleRegistry
must have trace information. The entire registry is searched and each
module is consulted to determine if it has trace information for the
type index in question.The
TraceInfoscache is intended to amortize this cost of a lookup.
This lookup is additionally mitigated in the copying collector where
this is only required for "big structs" where their tracing information
can't be stored inline in the object header itself. Overall it's
expected that for the copying collector this change has little effect on
typical GC performance itself.Additionally overall, however, this eliminates usage of the read/write
lock in theTypeRegistryentirely during instantiation. Eliminating
this lock acquisition was the goal of this commit, and this is expected
to help improve parallel instantiation performance of GC-using modules.
:thumbs_up: fitzgen submitted PR review:
Thanks!
:speech_balloon: fitzgen created PR review comment:
Can we put this stuff in
GcStore? It is already intended to be the store-specific GC data.
alexcrichton added PR #13843 Remove ensure_trace_info methods to the merge queue.
:memo: alexcrichton submitted PR review.
:speech_balloon: alexcrichton created PR review comment:
I'll look into that as a follow-up, yeah. I agree we should probably be able to though
:check: alexcrichton merged PR #13843.
alexcrichton removed PR #13843 Remove ensure_trace_info methods from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC