My Program uses predetermined number of threads that each do independent work. I use i7-2600 CPU but I shut down the hyper-thread module so it runs 4 threads on 4 cores. When I run the program with 1 thread the CPU usage is 25% which is perfect since 1 thread is fully used, but when I run 4 or 3 thread I only get 60% CPU, why?
Like I mentioned before the threads are totally independent (there are no locks and no contentions) also when I run the program 4 times with 1 thread I get 100% CPU usage (ie when its 4 processes of 1 thread for each process I get proper CPU usage)
Any ideas?
some more info:
You may try to shift your program from workstation to server garbage collection mode. Currently you may use just one garbage collection thread.
The setup is explained here .
See this thread for an explanation/further details.
Do not expect 100 % CPU load after the change, but you will get closer to 100% and increase the spead of it.
The concurrency visualizer will help you here. You will see when each thread is executing, and if all threads are not executing you can see exactly why a specific thread is waiting. If you generate a lot of garbage, the GC may keep threads blocked leading to less than linear scaling. But you will only find out by making a real investigation.
I had the same issue while working with .NET Framework v2.0 then i changed the projects target framework to v4.0 it started with 100 % CPU load
Edit: You can watch the CPU usage per threads, simply with
or
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.