mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 13:49:16 +02:00
Issue #477 - Added CYC_PTHREAD_SET_STACK_SIZE
This commit is contained in:
parent
15a8f2cfe5
commit
4ff0bca100
4 changed files with 10 additions and 19 deletions
|
@ -6,6 +6,7 @@ Features
|
||||||
|
|
||||||
- Initiate major garbage collections faster after allocating a huge object (larger than 500K). This allows the system to reclaim the memory faster and keep overall memory usage low for certain workloads.
|
- Initiate major garbage collections faster after allocating a huge object (larger than 500K). This allows the system to reclaim the memory faster and keep overall memory usage low for certain workloads.
|
||||||
- Cyclone will no longer memoize pure functions by default.
|
- Cyclone will no longer memoize pure functions by default.
|
||||||
|
- Added build option `CYC_PTHREAD_SET_STACK_SIZE` to allow Cyclone to specify a thread stack size rather than using the OS default.
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
|
|
||||||
|
|
1
Makefile
1
Makefile
|
@ -197,6 +197,7 @@ mstreams.o : mstreams.c $(HEADERS)
|
||||||
|
|
||||||
runtime.o : runtime.c $(HEADERS)
|
runtime.o : runtime.c $(HEADERS)
|
||||||
$(CCOMP) -c \
|
$(CCOMP) -c \
|
||||||
|
-DCYC_PTHREAD_SET_STACK_SIZE=$(CYC_PTHREAD_SET_STACK_SIZE) \
|
||||||
-DCYC_INSTALL_DIR=\"$(PREFIX)\" \
|
-DCYC_INSTALL_DIR=\"$(PREFIX)\" \
|
||||||
-DCYC_INSTALL_LIB=\"$(LIBDIR)\" \
|
-DCYC_INSTALL_LIB=\"$(LIBDIR)\" \
|
||||||
-DCYC_INSTALL_BIN=\"$(BINDIR)\" \
|
-DCYC_INSTALL_BIN=\"$(BINDIR)\" \
|
||||||
|
|
|
@ -13,6 +13,11 @@ CYC_PROFILING ?=
|
||||||
CYC_GCC_OPT_FLAGS ?= -O2
|
CYC_GCC_OPT_FLAGS ?= -O2
|
||||||
#CYC_GCC_OPT_FLAGS ?= -g
|
#CYC_GCC_OPT_FLAGS ?= -g
|
||||||
|
|
||||||
|
# Change this to 1 to use a custom stack size for threads.
|
||||||
|
# Required on platforms such as Alpine Linux that use a
|
||||||
|
# very small stack by default.
|
||||||
|
CYC_PTHREAD_SET_STACK_SIZE ?= 0
|
||||||
|
|
||||||
OS = $(shell uname)
|
OS = $(shell uname)
|
||||||
CC ?= cc
|
CC ?= cc
|
||||||
|
|
||||||
|
|
22
runtime.c
22
runtime.c
|
@ -6823,28 +6823,12 @@ void *_Cyc_init_thread(object thread_and_thunk)
|
||||||
*/
|
*/
|
||||||
object Cyc_spawn_thread(object thread_and_thunk)
|
object Cyc_spawn_thread(object thread_and_thunk)
|
||||||
{
|
{
|
||||||
// TODO: if we want to return mutator number to the caller, we need
|
|
||||||
// to reserve a number here. need to figure out how we are going to
|
|
||||||
// synchronize access to GC mutator fields, and then reserve one
|
|
||||||
// here. will need to pass it, along with thunk, to Cyc_init_thread.
|
|
||||||
// Then can use a new function up there to add the mutator, since we
|
|
||||||
// already have the number.
|
|
||||||
/*
|
|
||||||
how to manage gc mutators. need to handle:
|
|
||||||
- need to be able to allocate a thread but not run it yet.
|
|
||||||
maybe have a run level, or status
|
|
||||||
- need to make mutators thread safe, ideally without major performance impacts
|
|
||||||
- thread terminates
|
|
||||||
- should mark mutator as 'done'
|
|
||||||
- at an opportune moment, free mutator and set it back
|
|
||||||
to null
|
|
||||||
|
|
||||||
what is the right data structure? is the array OK? or would it be better
|
|
||||||
to look at the lock-free structures provided by ck?
|
|
||||||
*/
|
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
|
#if CYC_PTHREAD_SET_STACK_SIZE
|
||||||
|
pthread_attr_setstacksize(&attr, 1024*1024*8);
|
||||||
|
#endif
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
if (pthread_create(&thread, &attr, _Cyc_init_thread, thread_and_thunk)) {
|
if (pthread_create(&thread, &attr, _Cyc_init_thread, thread_and_thunk)) {
|
||||||
fprintf(stderr, "Error creating a new thread\n");
|
fprintf(stderr, "Error creating a new thread\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue