From 0b0842005c6c68f5f0d7ab428eb153e5a47334d1 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 16 Apr 2008 21:51:09 +0000 Subject: [PATCH] treat the global work list as a queue rather than a stack --- includes/Storage.h | 1 + rts/sm/GC.c | 1 + rts/sm/GCUtils.c | 12 ++++++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/includes/Storage.h b/includes/Storage.h index c51f51b..32d4e9b 100644 --- a/includes/Storage.h +++ b/includes/Storage.h @@ -88,6 +88,7 @@ typedef struct step_ { unsigned int n_old_blocks; // number of blocks in from-space bdescr * todos; // blocks waiting to be scavenged + bdescr * todos_last; unsigned int n_todos; // count of above bdescr * scavenged_large_objects; // live large objs after GC (d-link) diff --git a/rts/sm/GC.c b/rts/sm/GC.c index 5b16694..934c91f 100644 --- a/rts/sm/GC.c +++ b/rts/sm/GC.c @@ -1197,6 +1197,7 @@ init_collected_gen (nat g, nat n_threads) // we don't have any to-be-scavenged blocks yet stp->todos = NULL; + stp->todos_last = NULL; stp->n_todos = 0; // initialise the large object queues. diff --git a/rts/sm/GCUtils.c b/rts/sm/GCUtils.c index 636f23d..b400744 100644 --- a/rts/sm/GCUtils.c +++ b/rts/sm/GCUtils.c @@ -65,6 +65,9 @@ grab_todo_block (step_workspace *ws) ACQUIRE_SPIN_LOCK(&stp->sync_todo); if (stp->todos) { bd = stp->todos; + if (stp->todos == stp->todos_last) { + stp->todos_last = NULL; + } stp->todos = bd->link; stp->n_todos--; bd->link = NULL; @@ -78,8 +81,13 @@ push_todo_block (bdescr *bd, step *stp) { ASSERT(bd->link == NULL); ACQUIRE_SPIN_LOCK(&stp->sync_todo); - bd->link = stp->todos; - stp->todos = bd; + if (stp->todos_last == NULL) { + stp->todos_last = bd; + stp->todos = bd; + } else { + stp->todos_last->link = bd; + stp->todos_last = bd; + } stp->n_todos++; trace(TRACE_gc, "step %d, n_todos: %d", stp->abs_no, stp->n_todos); RELEASE_SPIN_LOCK(&stp->sync_todo); -- 1.7.10.4