Comment 45 for bug 148454

Revision history for this message
Nick Demou (ndemou) wrote : Re: console-kit-deamon spawns too many threads

Vladimir, our difference is not whether I care about wasted resources (I do) but whether I see any worthy evidence of wasted resources (I don't). But I'm afraid that at this point of time you probably wouldn't believe me if I told you that the sky is blue so I had to google for a few minutes in order to show you some quotes you may wish to examine before blaming those 60 sleeping threads for your crawling linux system. They are from IBM's developer works and from Linux Journal and you will find them just after the next paragraph.

Before the data a sincere advice with no empathy whatsoever: an attitude of "come on you incapable programmers -- fix those obvious mistakes in your code" when coupled with vague and disorientated complains about stuff you hardly understand DOESN'T help. Note that I don't pretend to know everything about life, universe and CDK -- I just don't call the developers of CDK incapable until I have some pretty good idea about what's going wrong with their program.

POSIX threads explained -- http://www.ibm.com/developerworks/library/l-posix1.html
<<<
Threads also happen to be extremely nimble. [...] Because of this, you can use a whole bunch of threads and not worry too much about the CPU and memory overhead incurred. You don't have a big CPU hit the way you do with fork().

This means you can generally create threads whenever it makes sense in your program.
>>>

The Linux Process Model -- http://www.linuxjournal.com/article/3814
<<<
threads share the same address space completely. All the threads run in the same address space, so a context switch is basically just a jump from one code location to another
>>>

So: those 60 threads use the same memory as one thread would. Regarding the CPU use ps (with -H of course) and note how they don't use any CPU at all. As for the available threads: we have about 32.000 to spare so again check with ps to see if you are even remotely close to using them all (I've never seen more that 2000 threads and that was on a really heavily loaded web/db/mail server).