Max number of threads with NPTL

2004-02-04 Thread Daniel Malmkvist
Hi

I was making som tests to see the maximum number of threads i could create
with the new linux thread library (NPTL). I had heard foks having up to
100 000 threads at the same time so i wanted to try for my self.

I used the 2.6.1 kernel with glibc with NPTL support, I used Sun JVM
v1.4.2 wich should have support for NPTL (I will make a try with the
newest blackdown JVM to night)

To my supprise i could not have more then ~3500 threads at the same time.
I got a OutOfMemoryException, but there was plenty of system memory left
(the JVM only ha about 10% of system physical memory).

I was wondering if someone had any experience in this field, perhaps know
som build in limits of any kind (OS or JVM) that could be tweeked.

Best regards
Daniel


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Max number of threads with NPTL

2004-02-04 Thread Nathan Bryant
Daniel Malmkvist wrote:

To my supprise i could not have more then ~3500 threads at the same time.
I got a OutOfMemoryException, but there was plenty of system memory left
(the JVM only ha about 10% of system physical memory).
 

Address space might be a limiting factor in a 32-bit machine. Assuming a 
3gig/1gig VM split, you have less than a megabyte per thread stack at 
3500 threads, even assuming there is no other memory overhead, and there 
is a lot of other overhead... Did you try using the Thread constructor 
that specifies a stack size? Try specifying a single page - 4K.

You might also need to increase the maximum size of the Java heap. (Or 
decrease it to make room for more stack?) I have found that it can't 
grow beyond 1.5gig on x86.

If you are allocating the default stack size which is probably fairly 
large, the system won't appear to be using the memory because the stack 
pages won't have corresponding physical pages allocated by the VM until 
they are used - the stacks grow down. But they are still allocated 
virtual address space within the process.

--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


Re: Max number of threads with NPTL

2004-02-04 Thread Hui Huang
Nathan Bryant wrote:
Daniel Malmkvist wrote:

To my supprise i could not have more then ~3500 threads at the same time.
I got a OutOfMemoryException, but there was plenty of system memory left
(the JVM only ha about 10% of system physical memory).
 

Address space might be a limiting factor in a 32-bit machine. Assuming a 
3gig/1gig VM split, you have less than a megabyte per thread stack at 
3500 threads, even assuming there is no other memory overhead, and there 
is a lot of other overhead... Did you try using the Thread constructor 
that specifies a stack size? Try specifying a single page - 4K.

You might also need to increase the maximum size of the Java heap. (Or 
decrease it to make room for more stack?) I have found that it can't 
grow beyond 1.5gig on x86.

If you are allocating the default stack size which is probably fairly 
large, 
Default stack size is 512k. You need 3500 * 512k = 1750M address space
for 3500 threads. Try -Xss96k. Also check your limit on max #processes
(ulimit -u), you can't create more threads than that limit either.
regards,
-hui
 the system won't appear to be using the memory because the stack
pages won't have corresponding physical pages allocated by the VM until 
they are used - the stacks grow down. But they are still allocated 
virtual address space within the process.

--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


Re: Max number of threads with NPTL

2004-02-04 Thread Vincent Touquet
On Wed, Feb 04, 2004 at 09:56:57AM -0800, Hui Huang wrote:
>Default stack size is 512k. You need 3500 * 512k = 1750M address space
>for 3500 threads. Try -Xss96k. Also check your limit on max #processes
>(ulimit -u), you can't create more threads than that limit either.

Is there a common place where these options (eg. -Xss...) are
documented?

regards,

v


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Max number of threads with NPTL

2004-02-04 Thread Hui Huang
Vincent Touquet wrote:
On Wed, Feb 04, 2004 at 09:56:57AM -0800, Hui Huang wrote:

Default stack size is 512k. You need 3500 * 512k = 1750M address space
for 3500 threads. Try -Xss96k. Also check your limit on max #processes
(ulimit -u), you can't create more threads than that limit either.


Is there a common place where these options (eg. -Xss...) are
documented?
See: http://java.sun.com/docs/hotspot

Also, you can get a list of common options by just running "java" or
"java -X".
regards,

v


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]


Re: Max number of threads with NPTL

2004-02-04 Thread nmeyers
On Wed, Feb 04, 2004 at 07:06:24PM +0100, Vincent Touquet wrote:
> On Wed, Feb 04, 2004 at 09:56:57AM -0800, Hui Huang wrote:
> >Default stack size is 512k. You need 3500 * 512k = 1750M address space
> >for 3500 threads. Try -Xss96k. Also check your limit on max #processes
> >(ulimit -u), you can't create more threads than that limit either.
> 
> Is there a common place where these options (eg. -Xss...) are
> documented?

You'll find some brief documentation if you run "java -X".

Nathan


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]



Re: Max number of threads with NPTL

2004-02-04 Thread Daniel Malmkvist
Hi

I have successfuly folowed your advise. After rekompiling the kernel so that I now can 
address 4G of memory, change the max #processes plus changed the thread stacksize i 
now can create more than 12 000 threads (which is pretty cool i thing), the limit must 
now be the 4G addressspace limit. I guess the next step is to buy i 64 bit platform...

Many thanks

/Daniel


On Wed, 04 Feb 2004 09:56:57 -0800
Hui Huang <[EMAIL PROTECTED]> wrote:

> Nathan Bryant wrote:
> > Daniel Malmkvist wrote:
> > 
> >> To my supprise i could not have more then ~3500 threads at the same time.
> >> I got a OutOfMemoryException, but there was plenty of system memory left
> >> (the JVM only ha about 10% of system physical memory).
> >>  
> >>
> > Address space might be a limiting factor in a 32-bit machine. Assuming a 
> > 3gig/1gig VM split, you have less than a megabyte per thread stack at 
> > 3500 threads, even assuming there is no other memory overhead, and there 
> > is a lot of other overhead... Did you try using the Thread constructor 
> > that specifies a stack size? Try specifying a single page - 4K.
> > 
> > You might also need to increase the maximum size of the Java heap. (Or 
> > decrease it to make room for more stack?) I have found that it can't 
> > grow beyond 1.5gig on x86.
> > 
> > If you are allocating the default stack size which is probably fairly 
> > large, 
> 
> Default stack size is 512k. You need 3500 * 512k = 1750M address space
> for 3500 threads. Try -Xss96k. Also check your limit on max #processes
> (ulimit -u), you can't create more threads than that limit either.
> 
> regards,
> -hui
> 
>   the system won't appear to be using the memory because the stack
> > pages won't have corresponding physical pages allocated by the VM until 
> > they are used - the stacks grow down. But they are still allocated 
> > virtual address space within the process.
> > 
> > 
> > --
> > To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> > with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> > 
> 
> 
> 
> --
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
> 


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]