Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually I got some 1000 individual processes to be executed independently. Each process will take 2 to 3 mins to complete. I want to execute all the process in Thread mode. My question is how many Threads can I use. In other words, how can I compute an optimum combination of no. of Threads and memory management to execute all these 1000 processes in a minimal time?
Posted

For the overall throughput, practically, it makes little sense to use more threads then CPU cores. Let's assume your all your other process are in the wait mode and don't take CPU resources. All correctly designed UI applications are like that. It means that your threads take all the time. Now the question is: do they use 1) each other, 2) external resources, such as network or external devices? If some of the above is correct, threading can really help, because, for example, the communication can be a bottleneck and then you can use several channels. In other works, parallel computing can help only if your have resources which can be used in parallel. Also, (case #1), the threading is dictated by the poor logic; for example, the UI should remain responsive anytime.

If you don't have anything like that, then number of threads should be the same as the number of cores. If number of cores is low (and apparently, if you have only 1 core), executing such independent tasks in more then one thread can even slow down the overall execution. Why? Because threading has some performance overhead.

—SA
 
Share this answer
 
The number of threads is limited by the runtime or in the case of ASP, IIS. Finding a balance of concurrent execution versus wait times is a matter of academics, and finding what works best for you is designing a framework that you can easily change the number of concurrent threads and increase that value until you see a performance drop. This depends heavily on the processor architecture and other overhead on the system at any given time, so it's really not as simple as giving a number.
 
Share this answer
 
Comments
chenthil28 10-May-13 15:41pm    
I do have experience in writing Thread based coding. If each process executes for a few secs then it'll be ok but in this case, i've a problem like the thread executes for a little long time of 2 mins...

anyway thanks for your reply...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900