public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: Mateusz Berezecki <mateuszb@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Linux 2.6 context switching and posix threads performance question
Date: Sat, 27 Aug 2005 15:43:16 +0100	[thread overview]
Message-ID: <1125153796.24593.27.camel@localhost.localdomain> (raw)
In-Reply-To: <20050827121158.GA18406@oepkgtn.mshome.net>

On Sad, 2005-08-27 at 14:11 +0200, Mateusz Berezecki wrote:
> switching contexts ? 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 ?

For doing what ? How often is a given thread woken up, do you need
latency or throughput.

A good rule of thumb is about 1.5 to 2 threads per core. But it is only
that and without context it is hard to assess the real needs. As you add
more threads you generally decrease cache effectiveness and that rather
than switching cost may well be the biggest hurt you experience. The
memory usage may also hurt.

Now if you have 25,000 threads and 24995 of them wake once every few
minutes that will have no real impact but if you are randomly flipping
between 25,000 threads all with different stacks and data areas at high
speed your cache utilisation will go down.

Equally if you have a lot of shared objects being written you avoid that
but can get into contention of cached memory. That however is more a
problem of number of processors than threads - ie a 25000 thread app
with a lot of shared objects may run *horribly* on a 64 CPU system and
really well on a dual.

So in essence you are asking "how long is a piece of string". Linux
2.6.x with NPTL will handle large numbers of threads. 25,000 is
excessive for most situations but how it behaves is more a question of
the application than the OS here.


  parent reply	other threads:[~2005-08-27 14:15 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
2005-08-27 14:43 ` Alan Cox [this message]
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=1125153796.24593.27.camel@localhost.localdomain \
    --to=alan@lxorguk.ukuu.org.uk \
    --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