Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wasix Control Plane - Thread Limit + Cleanup #3498

Merged
merged 1 commit into from
Jan 20, 2023
Merged

Conversation

theduke
Copy link
Contributor

@theduke theduke commented Jan 18, 2023

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:

  • Simplify WasiControlPlane

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.

  • TaskJoinHandle

Adds a new TaskJoinHandle handle that is used by both processes and threads to track termination.

Replaces a complex, cryptic type.

  • Simplify Thread state and make it private

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

@theduke theduke requested a review from john-sharratt January 18, 2023 22:45
@theduke theduke changed the title Wasix Control Plane Improvements Wasix Control Plane - Thread Limit + Cleanup Jan 18, 2023
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:

* Simplify WasiControlPlane

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.

* TaskJoinHandle

Adds a new TaskJoinHandle handle that is used by both processes and threads
to track termination.

Replaces a complex, cryptic type.

* Simplify Thread state and make it private

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
@theduke theduke force-pushed the wasix-control-plane branch from c161b6a to e037ae3 Compare January 19, 2023 12:31
@syrusakbary
Copy link
Member

Can the control plane be attached to the WasiEnv? And if so, can we customize the threads num via the WasiEnv builder?

@theduke
Copy link
Contributor Author

theduke commented Jan 19, 2023

It already is attached through the WasiProcess, which is stored in the env.

Currently Deploy always goes through Console (though that should change soon), which constructs the control plane, so we just need to add a config option there.

Just need to add an option to the console to make it configurable.

@theduke theduke merged commit e970704 into wasix Jan 20, 2023
@theduke theduke deleted the wasix-control-plane branch January 20, 2023 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants