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

Bound tokio worker thread count #686

Open
leftwo opened this issue Apr 24, 2024 · 5 comments · May be fixed by #699
Open

Bound tokio worker thread count #686

leftwo opened this issue Apr 24, 2024 · 5 comments · May be fixed by #699
Assignees

Comments

@leftwo
Copy link
Contributor

leftwo commented Apr 24, 2024

No description provided.

@pfmooney pfmooney changed the title Make fewer tokio threads (that crucible will use some of) Bound tokio worker thread count Apr 26, 2024
@pfmooney
Copy link
Collaborator

By default, the multi-thread tokio runtime will spawn a number of worker threads equal to the number of CPUs observed on the system. On a gimlet, that means north of 256 threads (128 CPUs * 2 runtimes), which is woefully excessive. The one runtime is used to run dropshot (and its associated bits), and can probably be limited to 4 workers. Determining the worker count for the propolis-specific runtime will require a bit more care, as it probably does need to be scaled with the performance expectations of the instance (more disks will drive more IOPS will require more workers).

@jclulow
Copy link
Contributor

jclulow commented Apr 29, 2024

It would be good if we could also provide thread names for the tokio runtimes that get created so that we can tell them apart in, say, prstat. Short names would be best; e.g., rt-http and rt-vm.

@pfmooney pfmooney self-assigned this Apr 29, 2024
@pfmooney
Copy link
Collaborator

CC: @leftwo @mkeeter

Is there any further input on where we should start in terms of minimums/maximums on the number of worker threads we spawn for an instance? I was going to start with a minimum of 8, scaling to a max of however many vCPUs an instance has. This is obviously not perfect as processing needs for Crucible presumably scale with the disk count (and workload), not the number of guest CPUs.

@mkeeter
Copy link
Contributor

mkeeter commented Apr 29, 2024

I don't have a strong opinion on this; 8 + vCPU count seems like a reasonable starting point.

However, be aware that heavy Crucible work (encryption / decryption) is actually done in the Rayon thread pool, not Tokio! The Rayon thread pool can be configured with ThreadPoolBuilder::build_global, so I think we should do this as well.

@pfmooney
Copy link
Collaborator

Because the global pool is somewhat challenging to initialize safely, I've filed oxidecomputer/crucible#1285 to cover that part of the problem. It will still be propolis' responsibility to bound the size of the tokio thread pool.

pfmooney added a commit to pfmooney/propolis that referenced this issue May 3, 2024
Rather than letting Tokio go wild with its default of spawning worker
threads equal to the number of visible host CPUs, we constrain that
number to the number of guest vCPUs (down to a minimum of 8).

Fixes oxidecomputer#686
@pfmooney pfmooney linked a pull request May 3, 2024 that will close this issue
pfmooney added a commit to pfmooney/propolis that referenced this issue May 8, 2024
Rather than letting Tokio go wild with its default of spawning worker
threads equal to the number of visible host CPUs, we constrain that
number to the number of guest vCPUs (down to a minimum of 8).

Fixes oxidecomputer#686
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 a pull request may close this issue.

4 participants