[commit: ghc] master: Refactor stack squeezing logic (2f343b0)
git at git.haskell.org
git at git.haskell.org
Mon Sep 1 20:15:12 UTC 2014
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2f343b0cbf8adf5b9df49c7a21f1914a38811dcf/ghc
>---------------------------------------------------------------
commit 2f343b0cbf8adf5b9df49c7a21f1914a38811dcf
Author: Arash Rouhani <rarash at student.chalmers.se>
Date: Mon Sep 1 15:13:57 2014 -0500
Refactor stack squeezing logic
Summary:
This patch is only to make the code easier to read.
In addition, this is the first patch I send with the arc/differential workflow.
So I start with something very small.
Test Plan: I have not even tried to compile it yet.
Reviewers: simonmar, austin
Reviewed By: austin
Subscribers: simonmar, ezyang, carter
Differential Revision: https://phabricator.haskell.org/D189
>---------------------------------------------------------------
2f343b0cbf8adf5b9df49c7a21f1914a38811dcf
rts/ThreadPaused.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/rts/ThreadPaused.c b/rts/ThreadPaused.c
index bf7def4..af37b53 100644
--- a/rts/ThreadPaused.c
+++ b/rts/ThreadPaused.c
@@ -26,6 +26,7 @@
*
* -------------------------------------------------------------------------- */
+
struct stack_gap { StgWord gap_size; struct stack_gap *next_gap; };
static struct stack_gap *
@@ -131,7 +132,7 @@ stackSqueeze(Capability *cap, StgTSO *tso, StgPtr bottom)
adjacent_update_frames, gap);
}
- // Now we have a stack with gaps in it, and we have to walk down
+ // Now we have a stack with gap-structs in it, and we have to walk down
// shoving the stack up to fill in the gaps. A diagram might
// help:
//
@@ -200,6 +201,7 @@ threadPaused(Capability *cap, StgTSO *tso)
nat weight = 0;
nat weight_pending = 0;
rtsBool prev_was_update_frame = rtsFalse;
+ StgWord heuristic_says_squeeze;
// Check to see whether we have threads waiting to raise
// exceptions, and we're not blocking exceptions, or are blocked
@@ -358,17 +360,20 @@ threadPaused(Capability *cap, StgTSO *tso)
}
end:
- debugTrace(DEBUG_squeeze,
- "words_to_squeeze: %d, weight: %d, squeeze: %s",
- words_to_squeeze, weight,
- ((weight <= 8 && words_to_squeeze > 0) || weight < words_to_squeeze) ? "YES" : "NO");
-
// Should we squeeze or not? Arbitrary heuristic: we squeeze if
// the number of words we have to shift down is less than the
// number of stack words we squeeze away by doing so.
+ // The threshold was bumped from 5 to 8 as a result of #2797
+ heuristic_says_squeeze = ((weight <= 8 && words_to_squeeze > 0)
+ || weight < words_to_squeeze);
+
+ debugTrace(DEBUG_squeeze,
+ "words_to_squeeze: %d, weight: %d, squeeze: %s",
+ words_to_squeeze, weight,
+ heuristic_says_squeeze ? "YES" : "NO");
+
if (RtsFlags.GcFlags.squeezeUpdFrames == rtsTrue &&
- ((weight <= 8 && words_to_squeeze > 0) || weight < words_to_squeeze)) {
- // threshold above bumped from 5 to 8 as a result of #2797
+ heuristic_says_squeeze) {
stackSqueeze(cap, tso, (StgPtr)frame);
tso->flags |= TSO_SQUEEZED;
// This flag tells threadStackOverflow() that the stack was
More information about the ghc-commits
mailing list