summaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-04-03 18:54:59 -0700
committerKaz Kylheku <kaz@kylheku.com>2012-04-03 18:54:59 -0700
commit4fe91fbeb4aa86ac43e530621220d46c8c03bffc (patch)
treed0abcc4350bb16444ce45369fbe3b08594053021 /gc.c
parent6934d519958914508da133a6d5851811220e46fb (diff)
downloadtxr-4fe91fbeb4aa86ac43e530621220d46c8c03bffc.tar.gz
txr-4fe91fbeb4aa86ac43e530621220d46c8c03bffc.tar.bz2
txr-4fe91fbeb4aa86ac43e530621220d46c8c03bffc.zip
Performance tweaking and fixes.
* gc.c (BACKPTR_VEC_SIZE): Increase greatly, so that we don't trigger gc due to overflow of the backptr array. This is not likely to yield a lot of free objects except in a full GC. (FULL_GC_INTERVAL): From 10 to 20. (gc): Take a not of whether or not gc was entered with free_list being exhausted or not. Call more() only if the free_list was empty, and a full sweep was done. Reset partial_gc_count only when a full gc is triggered.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/gc.c b/gc.c
index 3433fa78..06d74473 100644
--- a/gc.c
+++ b/gc.c
@@ -44,8 +44,8 @@
#define PROT_STACK_SIZE 1024
#define HEAP_SIZE 16384
-#define BACKPTR_VEC_SIZE 4096
-#define FULL_GC_INTERVAL 10
+#define BACKPTR_VEC_SIZE (2 * HEAP_SIZE)
+#define FULL_GC_INTERVAL 20
#define FRESHQ_SIZE (2 * HEAP_SIZE)
typedef struct heap {
@@ -539,11 +539,14 @@ void gc(void)
val gc_stack_top = nil;
if (gc_enabled) {
+ int free_list_empty = free_list != nil;
+
#if CONFIG_GEN_GC
if (backptr_idx &&
(++partial_gc_count == FULL_GC_INTERVAL || backptr_oflow))
{
full = 1;
+ partial_gc_count = 0;
} else {
full = 0;
}
@@ -554,11 +557,11 @@ void gc(void)
gc_enabled = 0;
mark(&mc, &gc_stack_top);
hash_process_weak();
- if ((sweep() < 3 * HEAP_SIZE / 4) && (full || !opt_gc_debug))
+ if ((sweep() < 3 * HEAP_SIZE / 4)
+ && full && free_list_empty)
more();
gc_enabled = 1;
#if CONFIG_GEN_GC
- partial_gc_count = 0;
backptr_idx = 0;
backptr_oflow = 0;
freshq_head = freshq_tail = 0;