From 973114b3cc157ea00cc9a9352aba0c888172eb7a Mon Sep 17 00:00:00 2001 From: Nikodemus Siivola Date: Sat, 19 Nov 2011 14:38:26 +0200 Subject: [PATCH] default nursery to 5% of total dynamic space size on GENCGC 5% seems like a reasonable compromise between latency and throughput. Also change a few related stray size_t types to os_vm_size_t, which necessitates moving runtime options saving bits into their own header file. --- NEWS | 4 +++- src/code/gc.lisp | 7 ++++++- src/runtime/coreparse.c | 5 +++-- src/runtime/gc-common.c | 4 ++-- src/runtime/gencgc.c | 6 ++++++ src/runtime/globals.h | 5 +++-- src/runtime/purify.c | 3 +-- src/runtime/runtime-options.h | 29 +++++++++++++++++++++++++++++ src/runtime/runtime.h | 12 ------------ 9 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 src/runtime/runtime-options.h diff --git a/NEWS b/NEWS index 5c2ea92..8040ec6 100644 --- a/NEWS +++ b/NEWS @@ -24,7 +24,9 @@ changes relative to sbcl-1.0.53: STANDARD-INSTANCE-ACCESS, and FUNCALLABLE-STANDARD-INSTANCE-ACCESS. ** Users can now defined new places usable with SB-EXT:COMPARE-AND-SWAP using an API anologous to defining new SETFable places. - * enchancement: on CHENEYGC targets, SB-KERNEL:MAKE-LISP-OBJ now does + * enhancement: on GENCGC systems nursery size now defaults to 5% of + dynamic-space size. + * enhancement: on CHENEYGC targets, SB-KERNEL:MAKE-LISP-OBJ now does the same validation of pointer objects as GENCGC does, instead of a comparatively weak bounds-check against the heap spaces. * enhancement: on win32, ABS of complex floats guards better against diff --git a/src/code/gc.lisp b/src/code/gc.lisp index 437e9d4..44b3ac5 100644 --- a/src/code/gc.lisp +++ b/src/code/gc.lisp @@ -339,7 +339,12 @@ NIL as the pathname." (defun bytes-consed-between-gcs () #!+sb-doc "The amount of memory that will be allocated before the next garbage -collection is initiated. This can be set with SETF." +collection is initiated. This can be set with SETF. + +On GENCGC platforms this is the nursery size, and defaults to 5% of dynamic +space size. + +Note: currently changes to this value are lost when saving core." (sb!alien:extern-alien "bytes_consed_between_gcs" os-vm-size-t)) (defun (setf bytes-consed-between-gcs) (val) diff --git a/src/runtime/coreparse.c b/src/runtime/coreparse.c index d1b8b96..010374c 100644 --- a/src/runtime/coreparse.c +++ b/src/runtime/coreparse.c @@ -43,6 +43,7 @@ #include "validate.h" #include "gc-internal.h" +#include "runtime-options.h" #include @@ -68,10 +69,10 @@ open_binary(char *filename, int mode) static struct runtime_options * read_runtime_options(int fd) { - size_t optarray[RUNTIME_OPTIONS_WORDS]; + os_vm_size_t optarray[RUNTIME_OPTIONS_WORDS]; struct runtime_options *options = NULL; - if (read(fd, optarray, RUNTIME_OPTIONS_WORDS * sizeof(size_t)) != + if (read(fd, optarray, RUNTIME_OPTIONS_WORDS * sizeof(os_vm_size_t)) != RUNTIME_OPTIONS_WORDS * sizeof(size_t)) { return NULL; } diff --git a/src/runtime/gc-common.c b/src/runtime/gc-common.c index 6db65fc..92457eb 100644 --- a/src/runtime/gc-common.c +++ b/src/runtime/gc-common.c @@ -52,8 +52,8 @@ #endif #endif -size_t dynamic_space_size = DEFAULT_DYNAMIC_SPACE_SIZE; -size_t thread_control_stack_size = DEFAULT_CONTROL_STACK_SIZE; +os_vm_size_t dynamic_space_size = DEFAULT_DYNAMIC_SPACE_SIZE; +os_vm_size_t thread_control_stack_size = DEFAULT_CONTROL_STACK_SIZE; inline static boolean forwarding_pointer_p(lispobj *pointer) { diff --git a/src/runtime/gencgc.c b/src/runtime/gencgc.c index 95a5d47..87f20a4 100644 --- a/src/runtime/gencgc.c +++ b/src/runtime/gencgc.c @@ -4068,6 +4068,12 @@ gc_init(void) page_table_pages = dynamic_space_size/GENCGC_CARD_BYTES; gc_assert(dynamic_space_size == npage_bytes(page_table_pages)); + /* Default nursery size to 5% of the total dynamic space size, + * min 1Mb. */ + bytes_consed_between_gcs = dynamic_space_size/(os_vm_size_t)20; + if (bytes_consed_between_gcs < (1024*1024)) + bytes_consed_between_gcs = 1024*1024; + /* The page_table must be allocated using "calloc" to initialize * the page structures correctly. There used to be a separate * initialization loop (now commented out; see below) but that was diff --git a/src/runtime/globals.h b/src/runtime/globals.h index 2c02ebe..ddb29ef 100644 --- a/src/runtime/globals.h +++ b/src/runtime/globals.h @@ -19,6 +19,7 @@ #endif #include "sbcl.h" +#include "runtime-options.h" #ifndef LANGUAGE_ASSEMBLY @@ -31,8 +32,8 @@ extern int foreign_function_call_active; foreign_function_call_active #endif -extern size_t dynamic_space_size; -extern size_t thread_control_stack_size; +extern os_vm_size_t dynamic_space_size; +extern os_vm_size_t thread_control_stack_size; extern struct runtime_options *runtime_options; diff --git a/src/runtime/purify.c b/src/runtime/purify.c index fc592d9..145ea3c 100644 --- a/src/runtime/purify.c +++ b/src/runtime/purify.c @@ -1008,8 +1008,7 @@ purify(lispobj static_roots, lispobj read_only_roots) clear_auto_gc_trigger(); /* restore mmap as it was given by os */ #endif - os_zero((os_vm_address_t) current_dynamic_space, - (os_vm_size_t) dynamic_space_size); + os_zero((os_vm_address_t) current_dynamic_space, dynamic_space_size); /* Zero the stack. */ os_zero((os_vm_address_t) access_control_stack_pointer(all_threads), diff --git a/src/runtime/runtime-options.h b/src/runtime/runtime-options.h new file mode 100644 index 0000000..9a9bf29 --- /dev/null +++ b/src/runtime/runtime-options.h @@ -0,0 +1,29 @@ +/* + * This software is part of the SBCL system. See the README file for + * more information. + * + * This software is derived from the CMU CL system, which was + * written at Carnegie Mellon University and released into the + * public domain. The software is in the public domain and is + * provided with absolutely no warranty. See the COPYING and CREDITS + * files for more information. + */ + +#ifndef _RUNTIME_OPTIONS_INCLUDED_ +#define _RUNTIME_OPTIONS_INCLUDED_ + +#include "os.h" + +#define RUNTIME_OPTIONS_MAGIC 0x31EBF355 +/* 1 for magic, 1 for boolean, 2 for struct runtime_options fields */ +#define RUNTIME_OPTIONS_WORDS (1 + 1 + 2) + +struct runtime_options { + os_vm_size_t dynamic_space_size; + os_vm_size_t thread_control_stack_size; +}; + +/* saved runtime path computed from argv[0] */ +extern char *saved_runtime_path; + +#endif diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index abf27da..b143eda 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -256,16 +256,4 @@ other_immediate_lowtag_p(lispobj header) extern void *successful_malloc (size_t size); extern char *copied_string (char *string); -#define RUNTIME_OPTIONS_MAGIC 0x31EBF355 -/* 1 for magic, 1 for boolean, 2 for struct runtime_options fields */ -#define RUNTIME_OPTIONS_WORDS (1 + 1 + 2) - -struct runtime_options { - size_t dynamic_space_size; - size_t thread_control_stack_size; -}; - -/* saved runtime path computed from argv[0] */ -extern char *saved_runtime_path; - #endif /* _SBCL_RUNTIME_H_ */ -- 1.7.10.4