[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Maximum number of threads

On Wed, 19 Feb 2003, Hrvoje Niksic wrote:

> >Did you change /proc/sys/kernel/threads-max?

> Yes, that would be the one I missed; the default was something like 6140
> or so.  Interestingly enough, different installations of the same kernel
> have different defaults for that parameter; perhaps the default is set
> to a "reasonable" value computed from the amount of physical memory?

yes, we chose the following calculation for the default value of

        max_threads = mempages / (THREAD_SIZE/PAGE_SIZE) / 8;
         * we need to allow at least 20 threads to boot a system
        if (max_threads < 20)
                max_threads = 20;

ie. if you have 384M RAM, then that's roughly 98304 pages, resulting in a
max_threads value of ~6144. This calculation assumes that 64K RAM per
thread is needed - which is a good ballpark figure.

> The pid_max setting is also a good parameter to bump for the people who
> need truly gigantic numbers of threads.  Thanks for the pointers.

yes. The pid_max defaults to 32K, to have binary-compatibility with some
really ancient SysV APIs [not used by any recent glibc]. I'd suggest to up
it to roughly 10 times the expected number of threads, to keep the
PID-space big enough. There's some additional (limited) overhead in
creating new threads if the PID space is squeezed too much.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]