From 55f5aed756cd5d464942dddcb33e0bd19b05f2a4 Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Tue, 2 Aug 2016 09:55:31 +0100 Subject: Track the lengths of the thread queues Summary: Knowing the length of the run queue in O(1) time is useful: for example we don't have to traverse the run queue to know how many threads we have to migrate in schedulePushWork(). Test Plan: validate Reviewers: ezyang, erikd, bgamari, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2437 --- rts/sm/Sanity.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'rts/sm/Sanity.c') diff --git a/rts/sm/Sanity.c b/rts/sm/Sanity.c index 6f6b15c4e8..f1b57eae66 100644 --- a/rts/sm/Sanity.c +++ b/rts/sm/Sanity.c @@ -839,12 +839,14 @@ checkRunQueue(Capability *cap) { StgTSO *prev, *tso; prev = END_TSO_QUEUE; - for (tso = cap->run_queue_hd; tso != END_TSO_QUEUE; - prev = tso, tso = tso->_link) { + uint32_t n; + for (n = 0, tso = cap->run_queue_hd; tso != END_TSO_QUEUE; + prev = tso, tso = tso->_link, n++) { ASSERT(prev == END_TSO_QUEUE || prev->_link == tso); ASSERT(tso->block_info.prev == prev); } ASSERT(cap->run_queue_tl == prev); + ASSERT(cap->n_run_queue == n); } /* ----------------------------------------------------------------------------- -- cgit v1.2.1