You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Peddireddy Srikanth <pe...@gmail.com> on 2005/07/27 09:08:56 UTC

setting -Xss option and its impact on servlet threads

Hi ,

I read about -Xss JVM option used to set the thread stack size and I
want to use it for tomcat during startup.
My thinking is that if I set it to some smaller value than the default
value, this will save me some memory when large number of sevlet
threads are started by tomcat during high traffic.and this  will help
me in giving some larger value for -Xmx option or else if I  have 2000
set for my MaxThreads and starting all those threads with default
thread stack space will not leave any memory for heap.
But I have some basic doubts regarding this::

  1) what is the default stack size for Sun JVM on windows (Win 2003
to be more specefic)??
  2) Will this setting affect both normal threads and the servlet
threads created by tomcat?? or only normal threads?
  3) If I set that to, say 128K , and if some of my thread (servlet 
or  normal) needed more stack space than this in any case what happens
(obvious answer for this would be that thread execution would fail but
I want to know it from some one who experienced it)

Please correct me if my assumptions are wrong and any suggestion in
this regard will be appreciated.

With regards
Srikanth.P

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: setting -Xss option and its impact on servlet threads

Posted by Peddireddy Srikanth <pe...@gmail.com>.
Thanx for the reply
As far as I know if thread space provided insufficient for JVM it
should throw stack overflow exception is'nt ??
Ok Will this approach works:
say I reduced stack size to 128 K
Then I invoked every possible feature of my web app to see whether any
of my modules are failing bcoz of reduced stack space. If every part
of my app works fine I will commit on my current setting for -Xss
If something fails, I will increase it and again run the test

but my one concern is, whether all this effort will yeld me any
improvement or not?

regards
Srikanth

On 7/27/05, Arup Vidyerthy <li...@yahoo.co.uk> wrote:
> On Windows I believe it is 256K. Don't reduce it to 128K unless you are
> absolutely sure what you are doing.
> 
> Also, sometimes when the JVM does run it trouble allocating stack correctly,
> it may throw an exception (actually it may be an OutOfMemoryError) 'can't
> create new native thread'.... It happened to us in our application when we
> used the -Xss parameter to override the default stack size to 128K.
> 
> Regards...
> Arup Vidyerthy
> 
> 
> -----Original Message-----
> From: Darryl L. Miles [mailto:darryl@netbauds.net]
> Sent: 27 July 2005 12:03
> To: Tomcat Users List
> Subject: Re: setting -Xss option and its impact on servlet threads
> 
> 
> Peddireddy Srikanth wrote:
> 
> >  1) what is the default stack size for Sun JVM on windows (Win 2003 to
> >be more specefic)??
> >
> >
> Dont know.
> 
> >  2) Will this setting affect both normal threads and the servlet
> >threads created by tomcat?? or only normal threads?
> >
> >
> I believe there is a 1:1 corelation between all Java application threads, be
> they Servlet or normal threads.  That is to say a Servlet thread uses
> exactly 1 Java thread.
> 
> >  3) If I set that to, say 128K , and if some of my thread (servlet or
> >normal) needed more stack space than this in any case what happens
> >(obvious answer for this would be that thread execution would fail but
> >I want to know it from some one who experienced it)
> >
> >
> Are you able to change the stack size on a per Java Thread basis?
> 
> If the underlying JVM uses kernel level threads and stack arrangement in a
> 1:1 fashion (unlikely from the observations I've seen), an unmapped
> page/area is usualy left at the end of the stack space if this is touched
> (read or write) the application will get a terminal signal and the entire
> JVM forced to exit just like it would accessing any other bit of invalid
> memory.
> 
> However as JVM is a sandbox and it can know the amount of stack space a
> method needs before its invoked it is completely possible for it to be able
> to check/test its virtual Java stack has enough space left in the CPU
> instruction stack as there does not need to be 1:1 to the Java execution
> stack.  Its possible for a JVM to implement its Java code execution stack
> completely within the operating system heap area.
> 
> I dont believe Java in general needs a large java execution stack as all
> arrays are implemented as object allocations that come from the heap.
> So its not like the C language where you can have a few Kb byte array on a
> whim, in Java it just has to store the pointers to that array as a local
> variable in the java execution stack.
> 
> 
> I would be very interested to understand how Sun's JVM application stack
> works and its interactions with OS level threads,  stacks and address space
> applications.
> 
> With platform level threads there is a clear trade off with thread stack
> size and number of available threads, amount of available heap and number of
> library / file mappings (when working with 32bit CPUs at least).  They all
> squeeze each other for their bit of address space but in Java this does not
> seem to be the case so much.
> 
> --
> Darryl L. Miles
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 
> 
> ___________________________________________________________
> How much free photo storage do you get? Store your holiday
> snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: setting -Xss option and its impact on servlet threads

Posted by Arup Vidyerthy <li...@yahoo.co.uk>.
On Windows I believe it is 256K. Don't reduce it to 128K unless you are
absolutely sure what you are doing.

Also, sometimes when the JVM does run it trouble allocating stack correctly,
it may throw an exception (actually it may be an OutOfMemoryError) 'can't
create new native thread'.... It happened to us in our application when we
used the -Xss parameter to override the default stack size to 128K.

Regards...
Arup Vidyerthy


-----Original Message-----
From: Darryl L. Miles [mailto:darryl@netbauds.net] 
Sent: 27 July 2005 12:03
To: Tomcat Users List
Subject: Re: setting -Xss option and its impact on servlet threads


Peddireddy Srikanth wrote:

>  1) what is the default stack size for Sun JVM on windows (Win 2003 to 
>be more specefic)??
>  
>
Dont know.

>  2) Will this setting affect both normal threads and the servlet 
>threads created by tomcat?? or only normal threads?
>  
>
I believe there is a 1:1 corelation between all Java application threads, be
they Servlet or normal threads.  That is to say a Servlet thread uses
exactly 1 Java thread.

>  3) If I set that to, say 128K , and if some of my thread (servlet or  
>normal) needed more stack space than this in any case what happens 
>(obvious answer for this would be that thread execution would fail but 
>I want to know it from some one who experienced it)
>  
>
Are you able to change the stack size on a per Java Thread basis?

If the underlying JVM uses kernel level threads and stack arrangement in a
1:1 fashion (unlikely from the observations I've seen), an unmapped
page/area is usualy left at the end of the stack space if this is touched
(read or write) the application will get a terminal signal and the entire
JVM forced to exit just like it would accessing any other bit of invalid
memory.

However as JVM is a sandbox and it can know the amount of stack space a
method needs before its invoked it is completely possible for it to be able
to check/test its virtual Java stack has enough space left in the CPU
instruction stack as there does not need to be 1:1 to the Java execution
stack.  Its possible for a JVM to implement its Java code execution stack
completely within the operating system heap area.

I dont believe Java in general needs a large java execution stack as all
arrays are implemented as object allocations that come from the heap.  
So its not like the C language where you can have a few Kb byte array on a
whim, in Java it just has to store the pointers to that array as a local
variable in the java execution stack.


I would be very interested to understand how Sun's JVM application stack
works and its interactions with OS level threads,  stacks and address space
applications.

With platform level threads there is a clear trade off with thread stack
size and number of available threads, amount of available heap and number of
library / file mappings (when working with 32bit CPUs at least).  They all
squeeze each other for their bit of address space but in Java this does not
seem to be the case so much.

--
Darryl L. Miles



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


		
___________________________________________________________ 
How much free photo storage do you get? Store your holiday 
snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: setting -Xss option and its impact on servlet threads

Posted by "Darryl L. Miles" <da...@netbauds.net>.
Peddireddy Srikanth wrote:

>  1) what is the default stack size for Sun JVM on windows (Win 2003
>to be more specefic)??
>  
>
Dont know.

>  2) Will this setting affect both normal threads and the servlet
>threads created by tomcat?? or only normal threads?
>  
>
I believe there is a 1:1 corelation between all Java application 
threads, be they Servlet or normal threads.  That is to say a Servlet 
thread uses exactly 1 Java thread.

>  3) If I set that to, say 128K , and if some of my thread (servlet 
>or  normal) needed more stack space than this in any case what happens
>(obvious answer for this would be that thread execution would fail but
>I want to know it from some one who experienced it)
>  
>
Are you able to change the stack size on a per Java Thread basis?

If the underlying JVM uses kernel level threads and stack arrangement in 
a 1:1 fashion (unlikely from the observations I've seen), an unmapped 
page/area is usualy left at the end of the stack space if this is 
touched (read or write) the application will get a terminal signal and 
the entire JVM forced to exit just like it would accessing any other bit 
of invalid memory.

However as JVM is a sandbox and it can know the amount of stack space a 
method needs before its invoked it is completely possible for it to be 
able to check/test its virtual Java stack has enough space left in the 
CPU instruction stack as there does not need to be 1:1 to the Java 
execution stack.  Its possible for a JVM to implement its Java code 
execution stack completely within the operating system heap area.

I dont believe Java in general needs a large java execution stack as all 
arrays are implemented as object allocations that come from the heap.  
So its not like the C language where you can have a few Kb byte array on 
a whim, in Java it just has to store the pointers to that array as a 
local variable in the java execution stack.


I would be very interested to understand how Sun's JVM application stack 
works and its interactions with OS level threads,  stacks and address 
space applications.

With platform level threads there is a clear trade off with thread stack 
size and number of available threads, amount of available heap and 
number of library / file mappings (when working with 32bit CPUs at 
least).  They all squeeze each other for their bit of address space but 
in Java this does not seem to be the case so much.

--  
Darryl L. Miles



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org