I have a machine with 64 CPU cores and 256 GB of RAM. I'm trying to figure out how many threads I can effectively run in my programs for smooth operation. If anyone has resources or documentation related to this topic, that would be great!
5 Answers
A good rule of thumb is one thread per core, but it varies based on what each thread does and if other applications are running.
It really depends on your workload! You could have a ton of threads (like 100,000) all waiting for data from the network and not be using any CPU, or you might have 100 threads doing complex calculations and max out the CPU usage.
The number of threads you can run depends on whether your tasks are independent. For example, if you have a million operations but each one relies on the previous one, you might struggle to use more than one or two threads effectively.
What type of CPU do you have? Do you have hyperthreading? And what's the nature of your workload? These factors will influence how many threads you can run concurrently.
Remember, OS threads are different from CPU threads and virtual threads. The hardware will dictate how many can run in parallel. In your case, you can start with at least 64 threads, but more might be possible if hyperthreading is available.

Thanks! Hyperthreading is part of my CPU, so that could help.