In general what is the relation between CPU usage and number of threads in a program.
Assumptions:
- Multi-core CPU
- Threads do the exact same job (assume they fetch identical work items from a queue and process them)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends on the nature of the application.
core is a reasonable decision, since you don’t want to spawn too many threads due to overhead, and you want to take advantage of all your cores.
That said, the CPU-usage you are going to get is still dependent on many factors (IO, synchronization, non parallel parts in your program).
If you are interested in the speed the application will take – always remember Amdahl’s law, which gives you a strict bound on the time (speed-up) your application is going to take, even when having infinite number of working cores.