[commit: ghc] ghc-8.6: Revert incorrect STM wakeup optimisation (279d69d)

git at git.haskell.org git at git.haskell.org
Thu Sep 13 21:00:49 UTC 2018


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.6
Link       : http://ghc.haskell.org/trac/ghc/changeset/279d69d31f9ca3c36237f0fe6b415090cf21f52a/ghc

>---------------------------------------------------------------

commit 279d69d31f9ca3c36237f0fe6b415090cf21f52a
Author: Ömer Sinan Ağacan <omeragacan at gmail.com>
Date:   Tue Sep 11 20:43:50 2018 +0200

    Revert incorrect STM wakeup optimisation
    
    Summary: (see the comments)
    
    Reviewers: simonmar, bgamari, erikd
    
    Reviewed By: simonmar
    
    Subscribers: rwbarton, carter
    
    Differential Revision: https://phabricator.haskell.org/D5144
    
    (cherry picked from commit 36740b4c346c619e31d24d6672caa6f4f7fea123)


>---------------------------------------------------------------

279d69d31f9ca3c36237f0fe6b415090cf21f52a
 rts/STM.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/rts/STM.c b/rts/STM.c
index 976ad87..dc0b0eb 100644
--- a/rts/STM.c
+++ b/rts/STM.c
@@ -337,11 +337,11 @@ static void unpark_tso(Capability *cap, StgTSO *tso) {
     // it belongs to this cap, or send a message to the owning cap
     // otherwise.
 
-    // But we don't really want to send multiple messages if we write
-    // to the same TVar multiple times, and the owning cap hasn't yet
-    // woken up the thread and removed it from the TVar's watch list.
-    // So, we use the tso->block_info as a flag to indicate whether
-    // we've already done tryWakeupThread() for this thread.
+    // TODO: This sends multiple messages if we write to the same TVar multiple
+    // times and the owning cap hasn't yet woken up the thread and removed it
+    // from the TVar's watch list. We tried to optimise this in D4961, but that
+    // patch was incorrect and broke other things, see #15544 comment:17. See
+    // #15626 for the tracking ticket.
 
     // Safety Note: we hold the TVar lock at this point, so we know
     // that this thread is definitely still blocked, since the first
@@ -349,12 +349,7 @@ static void unpark_tso(Capability *cap, StgTSO *tso) {
     // TVar watch queues, and to do that it would need to lock the
     // TVar.
 
-    if (tso->block_info.closure != &stg_STM_AWOKEN_closure) {
-        // safe to do a non-atomic test-and-set here, because it's
-        // fine if we do multiple tryWakeupThread()s.
-        tso->block_info.closure = &stg_STM_AWOKEN_closure;
-        tryWakeupThread(cap,tso);
-    }
+    tryWakeupThread(cap,tso);
 }
 
 static void unpark_waiters_on(Capability *cap, StgTVar *s) {



More information about the ghc-commits mailing list