public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Con Kolivas <kernel@kolivas.org>
To: Arjan van de Ven <arjan@infradead.org>
Cc: Mateusz Berezecki <mateuszb@gmail.com>, linux-kernel@vger.kernel.org
Subject: Re: Linux 2.6 context switching and posix threads performance question
Date: Sat, 27 Aug 2005 23:09:47 +1000	[thread overview]
Message-ID: <200508272309.48320.kernel@kolivas.org> (raw)
In-Reply-To: <1125147489.7756.10.camel@laptopd505.fenrus.org>

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

  reply	other threads:[~2005-08-27 13:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-08-27 12:11 Linux 2.6 context switching and posix threads performance question Mateusz Berezecki
2005-08-27 12:26 ` Peter Zijlstra
     [not found]   ` <aec8d6fc050827053047b1b667@mail.gmail.com>
2005-08-27 12:38     ` Peter Zijlstra
2005-08-27 12:58 ` Arjan van de Ven
2005-08-27 13:09   ` Con Kolivas [this message]
2005-08-27 14:43 ` Alan Cox
2005-08-28 23:20 ` James Courtier-Dutton
2005-08-30 17:46 ` Christoph Lameter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200508272309.48320.kernel@kolivas.org \
    --to=kernel@kolivas.org \
    --cc=arjan@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mateuszb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox