containerd / rust-extensions

Rust crates to extend containerd
https://containerd.io
Apache License 2.0
184 stars 73 forks source link

set worker thread nums through env variables #298

Closed mingfukuang closed 3 months ago

mingfukuang commented 3 months ago

The current shim process can run on all cores in the system, which is not suitable for scenarios with high CPU load. Add a shim thread count setting for runtime, the number of shim worker threads can be controlled through environment variables.

mxpv commented 3 months ago

@mingfukuang If I understand this right, Tokio already supports this out of the box via TOKIO_WORKER_THREADS env variable.

The core threads are where all asynchronous code runs, and Tokio will by default spawn one for each CPU core. You can use the environment variable TOKIO_WORKER_THREADS to override the default value.

See https://docs.rs/tokio/latest/tokio/#cpu-bound-tasks-and-blocking-code and https://github.com/tokio-rs/tokio/pull/4250

mxpv commented 3 months ago

Going to close this one, let me know if I missed anything.

mingfukuang commented 3 months ago

@mxpv I learned and agreed , thank for your explanation.