[uim-commit] r147 - trunk/uim
yamaken@freedesktop.org
yamaken@freedesktop.org
Thu Jan 6 20:24:43 PST 2005
Author: yamaken
Date: 2005-01-06 20:24:41 -0800 (Thu, 06 Jan 2005)
New Revision: 147
Modified:
trunk/uim/slib.c
trunk/uim/uim-scm.c
Log:
* This commit tunes GC frequency of the Scheme interpreter. This
significantly reduces GC frequency on near-threshold unfortunate
case
* uim/uim-scm.c
- Update copyright
- (uim_scm_init):
* Add new arg "-t16384" to siod_argv to specify
heap_alloc_threshold. The value reduces GC frequency, but
increases memory consumption. This is a tradeoff
* Move the position of verbose arg to top of siod_argv to
stabilize index even if new arg is added
* uim/slib.c
- (heap_alloc_threshold, gc_cells_sweeped): New static variable
- (gc_sweep): Update gc_cells_sweeped
- (gc_ms_stats_end): Show new statistics items gc_cells_sweeped,
number of heaps and map number of heaps
- (gc_for_newcell):
* Simplify detection of length of freelist
* Refer heap_alloc_threshold to determine whether new heap is
required or not
- (siod_init):
* Add initialization of heap_alloc_threshold and
gc_cells_sweeped. heap_alloc_threshold keeps original hardcoded
value 100
* Add parsing of new option '-t' (heap_alloc_threshold)
Modified: trunk/uim/slib.c
===================================================================
--- trunk/uim/slib.c 2005-01-06 21:42:13 UTC (rev 146)
+++ trunk/uim/slib.c 2005-01-07 04:24:41 UTC (rev 147)
@@ -80,6 +80,7 @@
fix broken feature? and provide (Sep-28-2004) YamaKen
removed non-standard _"str" syntax for i18n (Sep-30-2004) YamaKen
added NESTED_REPL_C_STRING feature (Dec-31-2004) YamaKen
+ added heap_alloc_threshold and make configurable (Jan-07-2005) YamaKen
*/
#include "config.h"
@@ -201,6 +202,7 @@
static LISP *heaps;
static LISP heap, heap_end;
static long heap_size;
+static long heap_alloc_threshold;
static long gc_status_flag;
static char *init_file;
static char *tkbuffer;
@@ -236,6 +238,7 @@
static struct gc_protected *protected_registers;
static jmp_buf save_regs_gc_mark;
static double gc_rt;
+static long gc_cells_sweeped;
static long gc_cells_collected;
static char *user_ch_readm;
static char *user_te_readm;
@@ -2493,9 +2496,9 @@
gc_sweep (void)
{
LISP ptr, end, nfreelist, org;
- long n, k;
+ long s, n, k;
end = heap_end;
- n = 0;
+ s = n = 0;
nfreelist = NIL;
for (k = 0; k < nheaps; ++k)
if (heaps[k])
@@ -2511,9 +2514,12 @@
CDR (ptr) = nfreelist;
nfreelist = ptr;
}
- else
+ else {
(*ptr).gc_mark = 0;
+ ++s;
+ }
}
+ gc_cells_sweeped = s;
gc_cells_collected = n;
freelist = nfreelist;
}
@@ -2545,12 +2551,20 @@
static void
gc_ms_stats_end (void)
{
+ long n, i;
+ for (n = i = 0; i < nheaps; ++i)
+ if (heaps[i])
+ ++n;
+
gc_rt = myruntime () - gc_rt;
gc_time_taken = gc_time_taken + gc_rt;
if (gc_status_flag && (siod_verbose_level >= 4))
- fprintf (siod_output, "[GC took %g cpu seconds, %ld cells collected]\n",
+ fprintf (siod_output, "[GC took %g cpu seconds, %ld / %ld cells collected in %ld / %ld heaps]\n",
gc_rt,
- gc_cells_collected);
+ gc_cells_collected,
+ gc_cells_sweeped,
+ n,
+ nheaps);
}
static void
@@ -2577,8 +2591,6 @@
static void
gc_for_newcell (void)
{
- long n;
- LISP l;
if (heap < heap_end)
{
freelist = heap;
@@ -2591,15 +2603,13 @@
errjmp_ok = 0;
gc_mark_and_sweep ();
errjmp_ok = 1;
- for (n = 0, l = freelist; (n < 100) && NNULLP (l); ++n)
- l = CDR (l);
- if (n == 0)
+ if (gc_cells_collected == 0)
{
if NULLP
(allocate_aheap ())
gc_fatal_error ();
}
- else if ((n == 100) && NNULLP (sym_after_gc))
+ else if ((gc_cells_collected >= heap_alloc_threshold) && NNULLP (sym_after_gc))
leval (leval (sym_after_gc, NIL), NIL);
else
allocate_aheap ();
@@ -4659,6 +4669,7 @@
heaps = NULL;
heap = 0; heap_end = 0;
heap_size = 5000;
+ heap_alloc_threshold = 100;
gc_status_flag = 1;
init_file = (char *)NULL;
tkbuffer = NULL;
@@ -4692,6 +4703,7 @@
user_types = NULL;
protected_registers = NULL;
gc_rt = 0;
+ gc_cells_sweeped = 0;
gc_cells_collected = 0;
user_ch_readm = "";
user_te_readm = "";
@@ -4722,6 +4734,9 @@
if ((ptr = strchr (&(argv[k][2]), ':')))
nheaps = atol (&ptr[1]);
break;
+ case 't':
+ heap_alloc_threshold = atol (&(argv[k][2]));
+ break;
case 'o':
obarray_dim = atol (&(argv[k][2]));
break;
Modified: trunk/uim/uim-scm.c
===================================================================
--- trunk/uim/uim-scm.c 2005-01-06 21:42:13 UTC (rev 146)
+++ trunk/uim/uim-scm.c 2005-01-07 04:24:41 UTC (rev 147)
@@ -1,6 +1,6 @@
/*
- Copyright (c) 2003,2004 uim Project http://uim.freedesktop.org/
+ Copyright (c) 2003-2005 uim Project http://uim.freedesktop.org/
All rights reserved.
@@ -419,11 +419,12 @@
char *siod_argv[] =
{
"siod",
+ "-v0", /* siod_verbose_level */
"-h16384:64", /* heap_size(unit: lisp objects):nheaps */
+ "-t16384", /* heap_alloc_threshold (unit: lisp objects) */
"-o1024", /* obarray_dim (hash size of symbol table) */
"-s262144", /* stack_size (unit: bytes) */
- "-n128", /* inums_dim (preallocated fixnum objects) */
- "-v0" /* siod_verbose_level */
+ "-n128" /* inums_dim (preallocated fixnum objects) */
};
char verbose_argv[] = "-v4";
int siod_argc, warnflag = 1;
@@ -439,7 +440,7 @@
else
verbose_argv[2] = verbose_level[0];
}
- siod_argv[5] = verbose_argv;
+ siod_argv[1] = verbose_argv;
}
/* init siod */
siod_argc = sizeof(siod_argv) / sizeof(char *);
More information about the Uim-commit
mailing list