Tokio isn't starting tasks on all available cores

Hi all,

I have a two CPU socket server where both CPUs have 22 cores each (44 with HT). However, Tokio is only using 22 of the cores. Is there something special I need to set in Tokio to get it to use all the cores?


Have you tried manually setting the number of worker threads?

I haven't. Tokio's docs say that by default Tokio will start one core thread for each CPU core. That's why I'm wondering if there's something special about having a two CPU setup that Tokio can't handle by default.

I believe tokio still uses num_cpus. [1] You could check with that crate; perhaps it gets it wrong for your hardware. [2]

  1. As opposed to available_parallelism. ↩︎

  2. And/or perhaps available_parallelism does too. ↩︎

num_cpus works fine, both get and get_physical return the proper count.

Looking at this, the next things I'd check are the environment variables and the exact versions of tokio and num_cpus in your project.


What is the processor affinity of your process? Is it possible that it's just bound to a single socket?

CentOS 7 is the operating system.

This shows my lack of lower level understanding of things. Talking with my co-worker it does sound like its bound to a single socket. Now I need to figure out if letting the app run on all cpus will hurt or help.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.