Stream: git-wasmtime

Topic: wasmtime / PR #14706 Track live resources and preflight c...


view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 17:08):

macovedj opened PR #14706 from macovedj:component-async-table-capacity to bytecodealliance:main:

Component stream and future construction inserts a shared state and two endpoint handles into the resource table. If only one or two slots remain, construction can return ResourceTableError::Full after inserting entries that the caller receives no handles to clean up. Failed construction therefore continues consuming table capacity.

This PR checks the complete entry requirement before starting these allocations. It applies equivalent checks to guest tasks, explicit threads, and deferred host tasks, placing them before relevant task or task-group reference changes. Insufficient capacity then rejects the checked allocation batch before it creates partial entries.

It also adds constant-time ResourceTable::len() and makes the existing is_empty() constant-time using centralized live-entry accounting. This supports repeated occupancy checks without scanning the backing table.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 17:08):

macovedj requested pchickey for a review on PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 17:08):

macovedj requested wasmtime-core-reviewers for a review on PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 17:53):

pchickey unassigned pchickey from PR #14706 Track live resources and preflight component async table allocations.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 17:53):

pchickey requested dicej for a review on PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:19):

alexcrichton requested alexcrichton for a review on PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:19):

alexcrichton unassigned dicej from PR #14706 Track live resources and preflight component async table allocations.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

Personally I think this is too brittle to test for and isn't worth a test. I know LLMs are great at writing tests but I'd recommend still reviewing all tests and ruling subjectively whether it makes sense to include or not.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

Similar to above -- how critical is this? This is a pretty complicated condition for a precise reservation, and in general once errors/traps happen the store is not really in a recoverable state.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

Similar to above, I think this is too specific to have a unit test for here

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

Can these tests be rewritten to be independent of precise constants like this? This is quite brittle and will likely be annoying to change over time

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

How required is this? This seems like a pretty brittle check to have anything in front of and this seems like it would be quite easy to get out of sync in the future. For example the 2 here seems to clearly relate to at least one push below, but the other one I'm not sure whether it's in new_exlpcit or add_guest_thread_to_instance_table.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

This is a pretty huge test file for a pretty minor change -- are all of these tests necessary?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

Instead of a loop here, could this be done with self.entries.len() - self.live? That in theory should give the number of free slots somewhere in the linked list.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

How come this is needed to reserve capacity for 1? Isn't that similar to a normal push?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 19:23):

:speech_balloon: alexcrichton created PR review comment:

It's ok to drop these, remember we don't test with features disabled

view this post on Zulip Wasmtime GitHub notifications bot (Oct 13 2026 at 22:44):

github-actions[bot] added the label wasmtime:api on PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 16:09):

macovedj updated PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 16:11):

:memo: macovedj submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 16:11):

:speech_balloon: macovedj created PR review comment:

If I'm not mistaken, entries.len() - live would count debug tombstones as free, since they’re excluded from live but aren’t available for reuse. I replaced the loop with free_count, which is updated when slots enter or leave the free list. Please let me know if this doesn't feel any nicer or if you have other thoughts about a simpler approach.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 16:11):

:memo: macovedj submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 16:11):

:speech_balloon: macovedj created PR review comment:

Sorry about that. Won't happen again!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 14 2026 at 16:12):

macovedj commented on PR #14706:

Thanks for the review! Removed a lot of the unnecessary checks/tests, and changed the while loop in ensure_capacity. Apologies for the unneeded tests. I was in a hurry and should have been more judicious with them. I will be more mindful of this in future contributions!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:speech_balloon: alexcrichton created PR review comment:

This might be more naturally modeled as checked_sub rather than saturating_sub

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:speech_balloon: alexcrichton created PR review comment:

I think it's ok to drop the last sentence of "No table mutations..." here as that's pretty much implied. I also think it's ok to drop the "Debug tombstone..." comment since that's just an implementation detail

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:speech_balloon: alexcrichton created PR review comment:

I'm a bit confused by this -- why have both live and free_count if tombstones remain in the live count?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:speech_balloon: alexcrichton created PR review comment:

The .saturating_sub here I think should be unnecessary, right?

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:speech_balloon: alexcrichton created PR review comment:

This is only checking for 32-bit overflow, right? I think it's ok to skip that because in theory max_capacity is where that limiting should happen if anywhere (and this is pretty niche)

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 14:50):

:speech_balloon: alexcrichton created PR review comment:

Oh, also, mind moving this to tests/all/*.rs? We don't typically put tests here in the wasmtime crate itself

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:16):

macovedj updated PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:17):

:memo: macovedj submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:17):

:speech_balloon: macovedj created PR review comment:

Good call. Thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:19):

:memo: macovedj submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:19):

:speech_balloon: macovedj created PR review comment:

I think the collapsed diff/naming makes it hard to follow. entry is the value that was just removed, so if a removed value is being replaced with a tombstone, it doesn't remain in the live count. The negative case here should only happen when attempting to remove an entry that is already a tombstone. I renamed to try and make this clearer.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:20):

:memo: macovedj submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:20):

:speech_balloon: macovedj created PR review comment:

Yep sorry this won't happen again either.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:23):

:memo: macovedj submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 16:23):

:speech_balloon: macovedj created PR review comment:

I think with current behavior, if max_capacity is set below the number of slots available, the free slots remain usable. So I think we should need it? Unless I"m missing something.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 20:49):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 20:49):

:speech_balloon: alexcrichton created PR review comment:

Ah good point!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 20:49):

:memo: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 20:49):

:speech_balloon: alexcrichton created PR review comment:

Ah makes sense, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 20:49):

:thumbs_up: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 20:49):

alexcrichton added PR #14706 Track live resources and preflight component async table allocations to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 21:31):

:check: alexcrichton merged PR #14706.

view this post on Zulip Wasmtime GitHub notifications bot (Oct 15 2026 at 21:31):

alexcrichton removed PR #14706 Track live resources and preflight component async table allocations from the merge queue.


Last updated: Oct 31 2026 at 23:03 UTC