Wasix Control Plane - Thread Limit + Cleanup #3498
Merged
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.
This commit adds a total task (aka thread) limit for a WasiControlPlane.
The limit is configured at startup, and is checked whenever a new process or a new thread is created.
The major breaking change is that the new_process and new_thread methods are now fallible and return an error.
Also adds two tests that validate the limits are repsected.
Along with this feature the commit also does some cleanup and reafactoring:
It was using multiple Arcs with locks and atomics with no real justification. The state is only locked for very short periods, so the complicated setup doesn't yield any benefits.
The mutable state is consolidated behind a single RwLock, which holds the process id seed and the process map, and the whole type is behind a single Arc.
The reservations are removed, since they are not really useful if the state is only locked for very short periods.
Also adds todo notes for handling pid exhaustion and process de-registration.
Adds a new TaskJoinHandle handle that is used by both processes and threads to track termination.
Replaces a complex, cryptic type.
Make internal thread state private to better encapsulate the code. Also restructures the type to be behind a single Arc instead of multiple redundant Arcs.
NOTE: should also be done for WasiProcess
Description