Skip to content

Commit

Permalink
Increase default stack size for thread stacks.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbehrends committed Oct 13, 2020
1 parent 758a08c commit 690d95f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/hpc/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <sys/mman.h>
#include <unistd.h>

#ifdef HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif

#ifdef USE_BOEHM_GC
# ifdef HPCGAP
# define GC_THREADS
Expand Down Expand Up @@ -324,6 +328,14 @@ void RunThreadedMain(int (*mainFunction)(int, char **),
*/
volatile int dummy[1];
size_t amount;
#ifdef HAVE_SYS_RESOURCE_H
// Ensure that we have enough room to allocate the stack
// on a boundary that is a multiple of TLS_SIZE.
struct rlimit rlim;
getrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = TLS_SIZE * 3;
setrlimit(RLIMIT_STACK, &rlim);
#endif
amount = ((uintptr_t)dummy) & ~TLS_MASK;
volatile char * p = alloca(((uintptr_t)dummy) & ~TLS_MASK);
volatile char * q;
Expand Down
6 changes: 5 additions & 1 deletion src/hpc/tlsconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
#ifndef USE_NATIVE_TLS

enum {
TLS_SIZE = (sizeof(UInt) == 8) ? (1 << 20) : (1 << 18),
#ifdef HAVE_SYS_RESOURCE_H
TLS_SIZE = (sizeof(UInt) == 8) ? (1 << 23) : (1 << 22),
#else
TLS_SIZE = (sizeof(UInt) == 8) ? (1 << 22) : (1 << 21),
#endif
};
#define TLS_MASK (~(TLS_SIZE - 1))

Expand Down

0 comments on commit 690d95f

Please sign in to comment.