Stream: git-wasmtime

Topic: wasmtime / issue #9352 Avoid locks for subtyping checks i...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2024 at 19:27):

fitzgen added the cranelift:goal:optimize-speed label to Issue #9352.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2024 at 19:27):

fitzgen added the wasmtime:ref-types label to Issue #9352.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2024 at 19:27):

fitzgen added the performance label to Issue #9352.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 01 2024 at 19:27):

fitzgen opened issue #9352:

Currently the TypeRegistry::is_subtype method requires taking a read lock to access the supertypes arrays that allow for O(1) subtype checking. At the time of writing, this doesn't power the ref.{test,cast} instructions because I haven't gotten around to implementing them yet, but it is expected that it will for the very first MVP implementation of them. It is also used in the id-to-funcref conversion for the funcrefs side table (see https://github.com/bytecodealliance/wasmtime/pull/9341).

Acquiring a lock during Wasm execution is, of course, not ideal for horizontal scaling within a process.

We can avoid locks for most cases by creating a shared lock-free arena of supertype indices (potentially built on top of a linear memory) where the arena's free list and mapping of type id to pointer-to-supertype-array are behind a lock, but accessing already-allocated supertypes arrays doesn't require any locking. (The supertypes arrays are immutable for as long as they exist, which makes accessing them without locking safe.)

(Actually, as I write this out, this is basically what we are doing in TypeRegistry today already, except we're allocating supertypes arrays via the global allocator and they aren't all in the same shared arena. But there is no reason why we couldn't start exposing the pointers to the supertypes arrays to Wasm today, modulo some #[repr(C)] sprinkling and a few little things like that).

Our various operations would then proceed as follows:

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2024 at 17:34):

xpbowler commented on issue #9352:

Hi @fitzgen, I want to give a shot at this! are there any pointers you would give to get started (I'm a newbie, haha)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2024 at 22:33):

fitzgen commented on issue #9352:

Hi @xpbowler,

I don't really have anything on top of what I wrote in the OP, but I must warn you that this is probably not the best task to take on as a first contribution as it is pretty involved. It also isn't clear that this is the lowest hanging fruit for wasm gc perf right now.

Something that might be a little bit more straight forward, but could then blossom out into lots of different and interesting paths, would be to

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2024 at 22:33):

fitzgen edited a comment on issue #9352:

Hi @xpbowler,

I don't really have anything on top of what I wrote in the OP, but I must warn you that this is probably not the best task to take on as a first contribution as it is pretty involved. It also isn't clear that this is the lowest hanging fruit for wasm gc perf right now.

Something that might be a little bit more straight forward, but could then blossom out into lots of different and interesting paths, would be to

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2024 at 22:35):

xpbowler commented on issue #9352:

Thanks, I'll take a look at those instead to get started!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2024 at 23:10):

xpbowler deleted a comment on issue #9352:

Thanks, I'll take a look at those instead to get started!


Last updated: Dec 23 2024 at 12:05 UTC