POSIX version of epicsThreadCreate needs to enable code calling pthread_attr_setstacksize

Bug #541205 reported by Jeff Hill
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
EPICS Base
Fix Released
Low
mrk

Bug Description

> Andrew wrote:
> Divide that remaining 2GB by the stack space allocated for
> each thread and you'll get an estimate of the maximum
> number of threads that you can run in a single process.
>
> In our case (Red Hat), the default stacksize is 10240
> Kbytes per thread, which gives a limit of 204 threads.
>
> # Limit stacksize for Linux to increase number of threads
> # 10240 is 204 threads (default)
> # 4096 is 512 threads
> ulimit -s 4096

Some comments:

o I had to read this a 2nd time to see that this is 4096 KBytes (not Bytes) per thread.
o this is virtual, and not actual space used in the page file
o the actual space used by each thread is probably two to three orders of magnitude smaller

> Dirk wrote:
> That means, that CA is not scalable any more (?)
>

Contrary to my previous concerns, it appears that a 64 bit Linux system will *not* be required for large gateways, and that CA scales just fine if one changes the "ulimit -s" quota. This fits with our experience with vxWorks where IOCs are routinely used with more than 200 circuits (within 32 MByte non-virtual address spaces).

Its starting to appear that the root problem is that the posix version of epicsThreadCreate needs to call pthread_attr_setstacksize to do the equivalent of "ulimit -s". I looked in the code and this is turned off if OSITHREAD_USE_DEFAULT_STACK is defined, and I see "-D OSITHREAD_USE_DEFAULT_STACK" on the Linux compiler's command line.

Original Mantis Bug: mantis-143
    http://www.aps.anl.gov/epics/mantis/view_bug_page.php?f_id=143

Tags: 3.14
Revision history for this message
Jeff Hill (johill-lanl) wrote :

An update on the results from epicsMaxThreadsHost on windows:

o On W2K the maximum is always 2000 threads.
o On WXP the maximum is 30,000 if STACK_SIZE_PARAM_IS_A_RESERVATION is specified when spawning the thread, and 2000 otherwise.

I will be changing the windows version of epicsThreadCreate to use STACK_SIZE_PARAM_IS_A_RESERVATION.

Revision history for this message
mrk (mrk-aps) wrote :

fixed R3.14.7

Revision history for this message
Andrew Johnson (anj) wrote :

R3.14.7 Released

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.