summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2013-11-28 11:32:08 +0100
committerAndy Wingo <wingo@pobox.com>2013-11-28 11:32:08 +0100
commit064d24093b752999979b4a71d19f60489c5dfc6a (patch)
treea8e3f7b76dbe3816c29e433f2a03cec26d48111e
parenta0a4d859c4101e41d669a62142a6ce1fb55d3a64 (diff)
downloadguile-064d24093b752999979b4a71d19f60489c5dfc6a.tar.gz
Tune initial heap size
* libguile/fluids.c (new_fluid): Don't run an explicit GC for the first fluid. * libguile/gc.c (DEFAULT_INITIAL_HEAP_SIZE, scm_storage_prehistory): Enlarge from 32 kB to 512 or 1024 kB, depending on word size. Reduces startup time by 10 or 15% by avoiding excessive GC. * libguile/private-gc.h: Remove SCM_DEFAULT_INIT_HEAP_SIZE_2 definition here.
-rw-r--r--libguile/fluids.c2
-rw-r--r--libguile/gc.c8
-rw-r--r--libguile/private-gc.h14
3 files changed, 9 insertions, 15 deletions
diff --git a/libguile/fluids.c b/libguile/fluids.c
index 22d825beb..4e0684af8 100644
--- a/libguile/fluids.c
+++ b/libguile/fluids.c
@@ -116,7 +116,7 @@ new_fluid (SCM init)
if (allocated_fluids[n] == NULL)
break;
- if (trial == 0 && n >= allocated_fluids_len)
+ if (trial == 0 && n >= allocated_fluids_len && allocated_fluids_len)
/* All fluid numbers are in use. Run a GC and retry. Explicitly
running the GC is costly and bad-style. We only do this because
dynamic state fluid vectors would grow unreasonably if fluid numbers
diff --git a/libguile/gc.c b/libguile/gc.c
index e822f49fb..dc7f5b0b5 100644
--- a/libguile/gc.c
+++ b/libguile/gc.c
@@ -70,6 +70,12 @@ extern unsigned long * __libc_ia64_register_backing_store_base;
#include <unistd.h>
#endif
+/* Size in bytes of the initial heap. This should be about the size of
+ result of 'guile -c "(display (assq-ref (gc-stats)
+ 'heap-total-allocated))"'. */
+
+#define DEFAULT_INITIAL_HEAP_SIZE (128 * 1024 * SIZEOF_SCM_T_BITS)
+
/* Set this to != 0 if every cell that is accessed shall be checked:
*/
int scm_debug_cell_accesses_p = 0;
@@ -593,7 +599,7 @@ scm_storage_prehistory ()
GC_INIT ();
- GC_expand_hp (SCM_DEFAULT_INIT_HEAP_SIZE_2);
+ GC_expand_hp (DEFAULT_INITIAL_HEAP_SIZE);
/* We only need to register a displacement for those types for which the
higher bits of the type tag are used to store a pointer (that is, a
diff --git a/libguile/private-gc.h b/libguile/private-gc.h
index 4c691dd0b..f0fa7998c 100644
--- a/libguile/private-gc.h
+++ b/libguile/private-gc.h
@@ -1,7 +1,7 @@
/*
* private-gc.h - private declarations for garbage collection.
*
- * Copyright (C) 2002, 03, 04, 05, 06, 07, 08, 09, 11 Free Software Foundation, Inc.
+ * Copyright (C) 2002, 03, 04, 05, 06, 07, 08, 09, 11, 13 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -24,18 +24,6 @@
#include "_scm.h"
-/* {heap tuning parameters}
- *
- * These are parameters for controlling memory allocation. The heap
- * is the area out of which scm_cons, and object headers are allocated.
- *
- * Each heap cell is 8 bytes on a 32 bit machine and 16 bytes on a
- * 64 bit machine. The units of the _SIZE parameters are bytes.
- * Cons pairs and object headers occupy one heap cell.
- */
-
-
-#define SCM_DEFAULT_INIT_HEAP_SIZE_2 32*1024
#define SCM_DOUBLECELL_ALIGNED_P(x) (((2 * sizeof (scm_t_cell) - 1) & SCM_UNPACK (x)) == 0)