Skip to content

Commit

Permalink
Remove reads (@michaelpj suggestion)
Browse files Browse the repository at this point in the history
After
=====
```
STM transaction statistics (2021-12-12 22:11:20.016977 UTC):
Transaction               Commits    Retries      Ratio
_anonymous_                 15227        116       0.01
action queue - pop              2          2       1.00
actionQueue - done              2          0       0.00
actionQueue - peek             29          0       0.00
actionQueue - push              2          0       0.00
builder                    282373        771       0.00
compute                     16882         32       0.00
debouncer                    6864        215       0.03
define - dirtyKeys          16900          0       0.00
define - read 1             10710          3       0.00
define - read 2              6254          3       0.00
define - write               6248          1       0.00
diagnostics - hidden         6893         10       0.00
diagnostics - publish        4006        200       0.05
diagnostics - read           6901          1       0.00
diagnostics - update         6893         22       0.00
incDatabase                 10966          0       0.00
lastValueIO 4                2200          0       0.00
lastValueIO 5                2200          0       0.00
recordProgress              31238        387       0.01
recordProgress2             31238         79       0.00
updateReverseDeps           64994        387       0.01
```
  • Loading branch information
pepeiborra committed Dec 12, 2021
1 parent fb614bd commit d6643e2
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ghcide/src/Development/IDE/Core/ProgressReporting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module Development.IDE.Core.ProgressReporting

import Control.Concurrent.Async
import Control.Concurrent.STM.Stats (TVar, atomicallyNamed,
newTVarIO, readTVar,
readTVarIO, writeTVar)
modifyTVar', newTVarIO,
readTVarIO)
import Control.Concurrent.Strict
import Control.Monad.Extra
import Control.Monad.IO.Class
Expand Down Expand Up @@ -86,14 +86,12 @@ recordProgress :: InProgressState -> NormalizedFilePath -> (Int -> Int) -> IO ()
recordProgress InProgressState{..} file shift = do
(prev, new) <- atomicallyNamed "recordProgress" $ STM.focus alterPrevAndNew file currentVar
atomicallyNamed "recordProgress2" $ do
done <- readTVar doneVar
todo <- readTVar todoVar
case (prev,new) of
(Nothing,0) -> writeTVar doneVar (done+1) >> writeTVar todoVar (todo+1)
(Nothing,_) -> writeTVar todoVar (todo+1)
(Nothing,0) -> modifyTVar' doneVar (+1) >> modifyTVar' todoVar (+1)
(Nothing,_) -> modifyTVar' todoVar (+1)
(Just 0, 0) -> pure ()
(Just 0, _) -> writeTVar doneVar (done-1)
(Just _, 0) -> writeTVar doneVar (done+1)
(Just 0, _) -> modifyTVar' doneVar pred
(Just _, 0) -> modifyTVar' doneVar (+1)
(Just _, _) -> pure()
where
alterPrevAndNew = do
Expand Down

0 comments on commit d6643e2

Please sign in to comment.