diff options
-rw-r--r-- | viengoos/ChangeLog | 16 | ||||
-rw-r--r-- | viengoos/activity.h | 17 | ||||
-rw-r--r-- | viengoos/object.c | 15 | ||||
-rw-r--r-- | viengoos/pager.c | 62 |
4 files changed, 86 insertions, 24 deletions
diff --git a/viengoos/ChangeLog b/viengoos/ChangeLog index eeb6c2b..7081af3 100644 --- a/viengoos/ChangeLog +++ b/viengoos/ChangeLog @@ -1,5 +1,21 @@ 2008-06-23 Neal H. Walfield <neal@gnu.org> + * activity.h (struct activity): Add field frames_pending_eviction. + Note that we now include frames that are in the laundry in the + FRAMES_TOTAL and FRAMES_LOCAL variables. + * object.c (object_desc_claim): If claiming a non-discardable + eviction candidate, update ACTIVITY's FRAMES_LOCAL, and it and its + ancestors' FRAMES_TOTAL and FRAMES_PENDING_EVICTION fields. + * pager.c (reclaim_from): Update VICTIM->FRAMES_LOCAL, + FRAMES_TOTAL and FRAMES_PENDING_EVICTION appropriately. + (process): If ACTIVITY_FRAMES is less than GOAL / 1000, don't + bother collecting the activity. + (pager_collect): Loop at most 8 times. Increase the active factor + by two. When calling process, don't include the frames pending + eviction. + +2008-06-23 Neal H. Walfield <neal@gnu.org> + * activity.h (struct activity): Add field priorities_count. * activity.c (activity_destroy): Update it. * object.c (object_desc_claim): Likewise. diff --git a/viengoos/activity.h b/viengoos/activity.h index 9465154..8e439e7 100644 --- a/viengoos/activity.h +++ b/viengoos/activity.h @@ -90,15 +90,22 @@ struct activity struct eviction_list eviction_dirty; /* Number of frames allocated to this activity not counting - children. */ + children. This includes all frames allocated on the PRIORITY + tree and the ACTIVE, INACTIVE and EVICTION_DIRTY lists (but not + the EVICTION_CLEAN list, as it is elements on it are immediately + reclaimable). */ uint32_t frames_local; /* Number of frames allocated to this activity (including children). - This is the sum of the number of objects on ACTIVE and INACTIVE - plus the number of frames allocated to each child. This does not - include the number of frames on the eviction_clean and - eviction_dirty lists. */ + This is the sum of the number of objects on the PRIORITY tree, + and the ACTIVE, INACTIVE and EVICTION_DIRTY lists plus the number + of frames allocated to each child. This does not include the + number of frames on the eviction_clean and eviction_dirty + lists. */ uint32_t frames_total; + /* Dirty frames that are pending eviction. */ + uint32_t frames_pending_eviction; + /* Whether the activity has been marked as dead (and thus will be shortly deallocated). */ unsigned char dying; diff --git a/viengoos/object.c b/viengoos/object.c index 80a8f25..bd90b7e 100644 --- a/viengoos/object.c +++ b/viengoos/object.c @@ -770,6 +770,21 @@ object_desc_claim (struct activity *activity, struct object_desc *desc, { laundry_list_unlink (&laundry, desc); eviction_list_unlink (&desc->activity->eviction_dirty, desc); + + if (update_accounting) + { + if (activity != desc->activity) + desc->activity->frames_local --; + + struct activity *ancestor = desc->activity; + activity_for_each_ancestor + (ancestor, + ({ + if (activity != desc->activity) + ancestor->frames_total --; + ancestor->frames_pending_eviction --; + })); + } } else { diff --git a/viengoos/pager.c b/viengoos/pager.c index 50816be..43c0c6d 100644 --- a/viengoos/pager.c +++ b/viengoos/pager.c @@ -268,12 +268,17 @@ reclaim_from (struct activity *victim, int goal) } } - ACTIVITY_STAT_UPDATE (victim, evicted, count); - - victim->frames_local -= count; + victim->frames_local -= count - laundry_count; struct activity *ancestor = victim; - activity_for_each_ancestor (ancestor, - ({ ancestor->frames_total -= count; })); + activity_for_each_ancestor + (ancestor, + ({ + ancestor->frames_total -= count - laundry_count; + ancestor->frames_pending_eviction += laundry_count; + + ACTIVITY_STATS (ancestor)->evicted += count; + })); + debug (5, "Reclaimed from " OID_FMT ": goal: %d; %d frames; " DEBUG_BOLD ("%d in laundry, %d made available (%d discarded)") " " "(now: avail: %d, laundry: %d)", @@ -341,19 +346,22 @@ pager_collect (int goal) struct activity_memory_policy activity_policy, int activity_frames) { - debug (0, "Considering " OID_FMT - ": policy: %d/%d; frames: %d (total: %d/%d; active: %d/%d)", + debug (5, "Considering " OID_FMT + ": policy: %d/%d; frames: %d (total: %d/%d; " + "pending eviction: %d/%d, active: %d/%d)", OID_PRINTF (object_oid ((struct object *) activity)), activity_policy.priority, activity_policy.weight, activity_frames, activity->frames_total, activity->frames_local, + eviction_list_count (&activity->eviction_dirty), + activity->frames_pending_eviction, ACTIVITY_STATS_LAST (activity)->active, ACTIVITY_STATS_LAST (activity)->active_local); - if (activity_frames <= 0) + if (activity_frames <= goal / 1000) /* ACTIVITY has no frames to yield; don't consider it. */ { - debug (0, "Not choosing activity " OID_FMT, + debug (5, "Not choosing activity " OID_FMT, OID_PRINTF (object_oid ((struct object *) activity))); return false; } @@ -425,7 +433,7 @@ pager_collect (int goal) victim = root_activity; do { - debug (0, "Current victim: " OID_FMT, + debug (5, "Current victim: " OID_FMT, OID_PRINTF (object_to_object_desc ((struct object *) victim) ->oid)); @@ -435,7 +443,7 @@ pager_collect (int goal) /* Each time through, we let the number of active frames play a less significant role. */ unsigned int factor; - for (factor = 0; ! victim; factor ++) + for (factor = 0; ! victim && factor < 16; factor += 2) { bool have_self = false; @@ -450,15 +458,21 @@ pager_collect (int goal) { have_self = true; int frames = parent->frames_local - - (ACTIVITY_STATS_LAST (parent)->active_local >> factor); - done = process (parent, parent->policy.child_rel, frames); + - eviction_list_count (&parent->eviction_dirty) + - (ACTIVITY_STATS_LAST (parent)->active_local + >> factor); + if (frames > 0) + done = process (parent, parent->policy.child_rel, + frames); if (done) break; } int frames = child->frames_total + - child->frames_pending_eviction - (ACTIVITY_STATS_LAST (child)->active >> factor); - done = process (child, child->policy.sibling_rel, frames); + if (frames > 0) + done = process (child, child->policy.sibling_rel, frames); if (done) break; } @@ -466,20 +480,27 @@ pager_collect (int goal) if (! done && ! have_self) { int frames = parent->frames_local + - eviction_list_count (&parent->eviction_dirty) - (ACTIVITY_STATS_LAST (parent)->active_local >> factor); - process (parent, parent->policy.child_rel, frames); + if (frames > 0) + process (parent, parent->policy.child_rel, frames); } if (victim) break; - debug (0, "nothing; raising factor to %d", 1 << (factor + 1)); + debug (5, "nothing; raising factor to %d", 1 << (factor + 1)); } + if (! victim) + break; assert (victim); } while (victim != parent); + if (! victim) + break; + /* We steal from VICTIM. */ /* Calculate VICTIM's share of the frames allocated to all the @@ -498,11 +519,14 @@ pager_collect (int goal) assertx (victim_frames >= share, "%d < %d", victim_frames, share); - debug (0, "Revoking from activity " OID_FMT "%s, %d/%d frames, " - "share: %d, goal: %d", + debug (0, DEBUG_BOLD ("Revoking from activity " OID_FMT "%s, ") + "%d/%d frames (pending eviction: %d/%d), share: %d, goal: %d", OID_PRINTF (object_to_object_desc ((struct object *) victim)->oid), victim->parent ? "" : " (root activity)", - victim->frames_total, victim->frames_local, share, goal); + victim->frames_local, victim->frames_total, + eviction_list_count (&victim->eviction_dirty), + victim->frames_pending_eviction, + share, goal); int reclaim = victim_frames - share; if (reclaim > goal) |