From 917b0e72f72944ecc6af48f43604593974b752de Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Sun, 19 Feb 2012 15:19:14 +0100 Subject: [PATCH] tune default hash table sizes * libguile/modules.c: In my current image, there are 1790 bindings in the root module, which tips over to the next hash vector size, so declare that to prevent rehashing. * libguile/srcprop.c (scm_init_srcprop): Don't preallocate a big source_whash table, as we might not need it (if everything is compiled, for example). * module/ice-9/boot-9.scm (make-module): Don't preall-cate big hash tables for imported bindings. Instead trust that resizing works correctly. --- libguile/modules.c | 4 ++-- libguile/srcprop.c | 2 +- module/ice-9/boot-9.scm | 6 +----- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/libguile/modules.c b/libguile/modules.c index 7498549ee..a5150f8c7 100644 --- a/libguile/modules.c +++ b/libguile/modules.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1998,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011 Free Software Foundation, Inc. +/* Copyright (C) 1998,2000,2001,2002,2003,2004,2006,2007,2008,2009,2010,2011,2012 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 @@ -1000,7 +1000,7 @@ SCM_SYMBOL (scm_sym_system_module, "system-module"); void scm_modules_prehistory () { - scm_pre_modules_obarray = scm_c_make_hash_table (1533); + scm_pre_modules_obarray = scm_c_make_hash_table (1790); } void diff --git a/libguile/srcprop.c b/libguile/srcprop.c index cc71fd182..dbebf779f 100644 --- a/libguile/srcprop.c +++ b/libguile/srcprop.c @@ -347,7 +347,7 @@ scm_init_srcprop () scm_tc16_srcprops = scm_make_smob_type ("srcprops", 0); scm_set_smob_print (scm_tc16_srcprops, srcprops_print); - scm_source_whash = scm_c_make_weak_table (2047, SCM_WEAK_TABLE_KIND_KEY); + scm_source_whash = scm_c_make_weak_table (0, SCM_WEAK_TABLE_KIND_KEY); scm_c_define ("source-whash", scm_source_whash); scm_last_alist_filename = scm_cons (SCM_EOL, diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index a7cd47ae1..68f54a7ea 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -1803,10 +1803,6 @@ VALUE." ;; initial uses list, or binding procedure. ;; (define* (make-module #:optional (size 31) (uses '()) (binder #f)) - (define %default-import-size - ;; Typical number of imported bindings actually used by a module. - 600) - (if (not (integer? size)) (error "Illegal size to make-module." size)) (if (not (and (list? uses) @@ -1819,7 +1815,7 @@ VALUE." (let ((module (module-constructor (make-hash-table size) uses binder #f macroexpand #f #f #f - (make-hash-table %default-import-size) + (make-hash-table) '() (make-weak-key-hash-table 31) #f (make-hash-table 7) #f #f #f)))