Is MacroQuad using too many threads?

I have noticed that my app that is using MacroQuad, Is using up to 13 threads:
Screen Shot 2022-05-31 at 1.43.25 PM
But the average number of cores on a computer is 4. And I feel like MacroQuad is using too many. It runs fine on my QuadCore computer, But it has an i7.

1 Like

There are probably already hundreds of threads currently running on your machine.

The “number of threads = number of cores” principle is about efficiently distributing CPU-intensive workloads. It does not apply when the threads are idle. It's entirely normal for programs to have threads dedicated to various purposes (e.g. multiple thread pools, or waiting for various types of events) that aren't currently doing anything. They're taking up a little bit of memory, but have no effect on CPU utilization.

For example, if a program used both rayon (for large parallel computation tasks) and tokio (for handling IO) while running on a 4-core machine, then it might already have 9 threads: one "main" thread that it started with on which the program's main() function runs, 4 threads for the rayon thread pool, and 4 threads for the tokio thread pool.

I think you posted a screenshot from macOS — in that case, in the same Activity Monitor app, you can run “Sample Process” (look in the menu button that looks like image or the View menu in the menu bar) which will capture a report of all threads in the program and what functions are on their call-stacks over a few seconds. That will show you (by thread name and/or function names) what created each thread and likely what purpose it serves. It's also a handy performance profiling tool!


Your are right, I was using MacOS

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.