lkml.org 
[lkml]   [2005]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: Linux 2.6 context switching and posix threads performance question
Date
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.

Cheers,
Con
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-08-27 15:16    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site