Skip to content

Commit 0d64e02

Browse files
committed
cleanup
1 parent 35ee2b9 commit 0d64e02

File tree

7 files changed

+22
-501
lines changed

7 files changed

+22
-501
lines changed

.github/workflows/flakiness.yml

Lines changed: 0 additions & 109 deletions
This file was deleted.

hls-graph/src/Development/IDE/Graph/Internal/Action.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ actionFork act k = do
8181

8282
isAsyncException :: SomeException -> Bool
8383
isAsyncException e
84-
| Just (_ :: SomeAsyncException) <- fromException e = True
8584
| Just (_ :: AsyncCancelled) <- fromException e = True
8685
| Just (_ :: AsyncException) <- fromException e = True
8786
| Just (_ :: ExitCode) <- fromException e = True

hls-graph/src/Development/IDE/Graph/Internal/Database.hs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Control.Concurrent.Extra
1717
import Control.Concurrent.STM.Stats (STM, atomically,
1818
atomicallyNamed,
1919
modifyTVar', newTVarIO,
20-
readTVarIO, retry)
20+
readTMVar, readTVarIO)
2121
import Control.Exception
2222
import Control.Monad
2323
import Control.Monad.IO.Class (MonadIO (liftIO))
@@ -39,7 +39,8 @@ import qualified Focus
3939
import qualified ListT
4040
import qualified StmContainers.Map as SMap
4141
import System.Time.Extra (duration, sleep)
42-
import UnliftIO (MonadUnliftIO (withRunInIO))
42+
import UnliftIO (MonadUnliftIO (withRunInIO),
43+
newEmptyTMVarIO)
4344
import qualified UnliftIO.Exception as UE
4445

4546
#if MIN_VERSION_base(4,19,0)
@@ -78,7 +79,7 @@ incDatabase db Nothing = do
7879
updateDirty :: Monad m => Focus.Focus KeyDetails m ()
7980
updateDirty = Focus.adjust $ \(KeyDetails status rdeps) ->
8081
let status'
81-
| Running _ x <- status = Dirty x
82+
| Running _ _ x <- status = Dirty x
8283
| Clean x <- status = Dirty (Just x)
8384
| otherwise = status
8485
in KeyDetails status' rdeps
@@ -112,6 +113,7 @@ builder db stack keys = do
112113
builderOne :: BuildArity -> Database -> Stack -> Key -> AIO (Key, IO Result)
113114
builderOne ba db@Database {..} stack id = UE.mask $ \restore -> do
114115
current <- liftIO $ readTVarIO databaseStep
116+
barrier <- newEmptyTMVarIO
115117
(k, registerWaitResult) <- liftIO $ atomicallyNamed "builder" $ do
116118
-- Spawn the id if needed
117119
status <- SMap.lookup id databaseValues
@@ -124,14 +126,14 @@ builderOne ba db@Database {..} stack id = UE.mask $ \restore -> do
124126
`UE.onException` (UE.uninterruptibleMask_ $ liftIO (atomicallyNamed "builder - onException" (SMap.focus updateDirty id databaseValues)))
125127
BuildUnary -> fmap return $ refresh db stack id s
126128
-- Mark the key as running
127-
SMap.focus (updateStatus $ Running current s) id databaseValues
129+
SMap.focus (updateStatus $ Running current (atomically $ readTMVar barrier) s) id databaseValues
128130
return act
129131
in case viewDirty current $ maybe (Dirty Nothing) keyStatus status of
130132
Dirty mbr -> refreshRsult mbr
131-
Running step _mbr
133+
Running step ba _mbr
132134
| step /= current -> error $ "Inconsistent database state: key " ++ show id ++ " is marked Running at step " ++ show step ++ " but current step is " ++ show current
133135
| memberStack id stack -> throw $ StackException stack
134-
| otherwise -> retry
136+
| otherwise -> pure . pure $ ba
135137
Clean r -> pure . pure . pure $ r
136138
-- force here might contains async exceptions from previous runs
137139
pure (id, val)

hls-graph/src/Development/IDE/Graph/Internal/Types.hs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
module Development.IDE.Graph.Internal.Types where
77

88
import Control.Concurrent.STM (STM)
9+
import Control.Monad (void, (>=>))
910
import Control.Monad.Catch
1011
import Control.Monad.IO.Class
1112
import Control.Monad.Trans.Reader
@@ -79,8 +80,8 @@ getDatabase :: Action Database
7980
getDatabase = Action $ asks actionDatabase
8081

8182
-- | waitForDatabaseRunningKeysAction waits for all keys in the database to finish running.
82-
-- waitForDatabaseRunningKeysAction :: Action ()
83-
-- waitForDatabaseRunningKeysAction = getDatabase >>= liftIO . waitForDatabaseRunningKeys
83+
waitForDatabaseRunningKeysAction :: Action ()
84+
waitForDatabaseRunningKeysAction = getDatabase >>= liftIO . waitForDatabaseRunningKeys
8485

8586
---------------------------------------------------------------------
8687
-- DATABASE
@@ -112,12 +113,10 @@ data Database = Database {
112113
databaseRules :: TheRules,
113114
databaseStep :: !(TVar Step),
114115
databaseValues :: !(Map Key KeyDetails)
115-
-- ^ The set of dirty keys, which are the keys that have been marked as dirty
116-
-- by the client, it would be removed once the target key is marked as clean.
117116
}
118117

119-
-- waitForDatabaseRunningKeys :: Database -> IO ()
120-
-- waitForDatabaseRunningKeys = getDatabaseValues >=> mapM_ (waitRunning . snd)
118+
waitForDatabaseRunningKeys :: Database -> IO ()
119+
waitForDatabaseRunningKeys = getDatabaseValues >=> mapM_ (waitRunning . snd)
121120

122121
getDatabaseValues :: Database -> IO [(Key, Status)]
123122
getDatabaseValues = atomically
@@ -131,19 +130,23 @@ data Status
131130
| Dirty (Maybe Result)
132131
| Running {
133132
runningStep :: !Step,
134-
-- runningWait :: !(IO ()),
133+
runningWait :: !(IO Result),
135134
-- runningResult :: Result, -- LAZY
136135
runningPrev :: !(Maybe Result)
137136
}
138137

139138
viewDirty :: Step -> Status -> Status
140-
viewDirty currentStep (Running s re) | currentStep /= s = Dirty re
139+
viewDirty currentStep (Running s _ re) | currentStep /= s = Dirty re
141140
viewDirty _ other = other
142141

143142
getResult :: Status -> Maybe Result
144-
getResult (Clean re) = Just re
145-
getResult (Dirty m_re) = m_re
146-
getResult (Running _ m_re) = m_re -- watch out: this returns the previous result
143+
getResult (Clean re) = Just re
144+
getResult (Dirty m_re) = m_re
145+
getResult (Running _ _ m_re) = m_re -- watch out: this returns the previous result
146+
147+
waitRunning :: Status -> IO ()
148+
waitRunning Running{..} = void runningWait
149+
waitRunning _ = return ()
147150

148151
data Result = Result {
149152
resultValue :: !Value,

scripts/eventlog-dump.fish

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)