[lkml]   [2005]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Linux 2.6 context switching and posix threads performance question
On Sat, 27 Aug 2005 22:58, Arjan van de Ven wrote:
> > I'm asking for some kind of an authoritative answer
> > quite urgently. What is the optimum thread amount on 2 CPU SMP system
> > running Linux ?
> context switching in linux isn't THAT expensive compared to some other
> operating systems, but it's not free either.
> The optimum is obviously 2 threads, one for each cpu that processes your
> network service in a state machine like way. This is why thttpd beats
> apache by 10x if not more.

On a current model processor (P4 3Ghz) the current 2.6 kernel can do about
700,000 context switches per second with processes if they do nothing but
switch, and perhaps slightly faster with threads. Each context switch,
therefore, is quite cheap to perform. However you're unlikely to perform more
than 10,000 context switches per second with real workloads and the switch
itself contributes a measurable, but not performance limiting, impact. The
more cpu bound your threads are the less context switches you'll perform.
Fork is quite a bit more expensive. I don't have current figures on fork, but
if you only fork once it shouldn't be a problem.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-08-27 15:16    [W:0.045 / U:12.380 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site