diff options
author | Simon Marlow <marlowsd@gmail.com> | 2016-08-02 09:55:31 +0100 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2016-08-03 08:07:34 +0100 |
commit | 55f5aed756cd5d464942dddcb33e0bd19b05f2a4 (patch) | |
tree | f8c0acd76b0945d44cca86946bd638ceee440aa3 /rts/sm/Sanity.c | |
parent | 36565a9ba200d40e0be8407e57ada1b4a1c55814 (diff) | |
download | haskell-55f5aed756cd5d464942dddcb33e0bd19b05f2a4.tar.gz |
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
Diffstat (limited to 'rts/sm/Sanity.c')
-rw-r--r-- | rts/sm/Sanity.c | 6 |
1 files changed, 4 insertions, 2 deletions
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); } /* ----------------------------------------------------------------------------- |