[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 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.

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 16:20    [W:0.042 / U:4.456 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site