Results 1 to 7 of 7
Will there be any performance hit on the running process by spawning many threads?
Somebody please explain about the scheduling policy of a thread....
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-01-2010 #1Just Joined!
- Join Date
- May 2010
- Posts
- 19
Performance hit by creating new thread
Will there be any performance hit on the running process by spawning many threads?
Somebody please explain about the scheduling policy of a thread.
- 12-08-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,233
1. Yes
2. Threads are "light-weight" processes. Not as much context switch information/overhead as in full process context switches.
3. Performance impact depends ENTIRELY on the number of CPU's or cores that the system has. There is a finite amount of CPU time available. Once you hit that wall, performance falls off due to resource contention (CPU cycles available).
As for actual scheduling policy, you need to research this yourself. The answer is "it depends" upon many factors, including kernel version, which scheduler you are using, etc.Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 12-08-2010 #3Just Joined!
- Join Date
- May 2010
- Posts
- 19
- 12-08-2010 #4Just Joined!
- Join Date
- May 2010
- Posts
- 19
@Rubberman
Precisely put, I wanted to know if the time slice allocated to the thread is shared from the time slice of the same process or does it depend on number of process in the run queue of the scheduler?
- 12-08-2010 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,233
Yes to both questions. There is thread scheduling associeted with each process, and there is the process scheduling. The more work a thread is doing (other than waiting for I/O) the more it will impact the process and add to the load the process is making on the system, hence other processes. Multi-core systems are great for reducing this load. For example, I have an 8 core system and often run a program called ffmpeg to transcode video streams from one format into another, such as from AVI to MP4 so I can run the video on my Android phone. Since ffmpeg has an option to specify how many threads it can use to transcode the video (more == faster processing up to a point), I often specify between 4 and 8 threads, depending upon what else I am doing on the system at the time. As a result, each thread can run in pararllel with minimal impact on the rest of the system.
In practical terms, there are other resources that will limit the number of actual threads you can run in a process, but it is not uncommon for application servers that handle a lot of client requests to have dozens or hundreds of threads running. What the limits are depend upon factors mentioned, such as number of core processors, RAM, system configuration, other workloads, etc. The means of determining what that maximum number of threads may be is something of a "black art"...
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 12-09-2010 #6Just Joined!
- Join Date
- May 2010
- Posts
- 19
Thanks Rubberman.
Can you suggest a book or a site where I can get more Information about Linux scheduler.
- 12-09-2010 #7Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,233
I'll see what I can come up with. It will likely be a day or two before I get back to you.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote

