default nursery to 5% of total dynamic space size on GENCGC
authorNikodemus Siivola <nikodemus@random-state.net>
Sat, 19 Nov 2011 12:38:26 +0000 (14:38 +0200)
committerNikodemus Siivola <nikodemus@random-state.net>
Sat, 19 Nov 2011 14:22:43 +0000 (16:22 +0200)
  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
src/code/gc.lisp
src/runtime/coreparse.c
src/runtime/gc-common.c
src/runtime/gencgc.c
src/runtime/globals.h
src/runtime/purify.c
src/runtime/runtime-options.h [new file with mode: 0644]
src/runtime/runtime.h

diff --git a/NEWS b/NEWS
index 5c2ea92..8040ec6 100644 (file)
--- 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
index 437e9d4..44b3ac5 100644 (file)
@@ -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)
index d1b8b96..010374c 100644 (file)
@@ -43,6 +43,7 @@
 
 #include "validate.h"
 #include "gc-internal.h"
+#include "runtime-options.h"
 
 #include <errno.h>
 
@@ -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;
     }
index 6db65fc..92457eb 100644 (file)
@@ -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) {
index 95a5d47..87f20a4 100644 (file)
@@ -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
index 2c02ebe..ddb29ef 100644 (file)
@@ -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;
 
index fc592d9..145ea3c 100644 (file)
@@ -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 (file)
index 0000000..9a9bf29
--- /dev/null
@@ -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
index abf27da..b143eda 100644 (file)
@@ -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_ */