[commit: ghc] master: Revert incorrect STM wakeup optimisation (36740b4)

git at git.haskell.org git at git.haskell.org
Tue Sep 11 19:59:33 UTC 2018


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/36740b4c346c619e31d24d6672caa6f4f7fea123/ghc

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

commit 36740b4c346c619e31d24d6672caa6f4f7fea123
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


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

36740b4c346c619e31d24d6672caa6f4f7fea123
 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