Skip to content

Commit d882e30

Browse files
committed
Revert "mark the keys dirty before we do async runs to start the database"
This reverts commit 26aac1a.
1 parent bd455bf commit d882e30

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

ghcide/src/Development/IDE/Core/Shake.hs

+3-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ import Data.Default
9696
import Data.Dynamic
9797
import Data.EnumMap.Strict (EnumMap)
9898
import qualified Data.EnumMap.Strict as EM
99-
import Data.Foldable (find, for_, traverse_)
99+
import Data.Foldable (find, for_)
100100
import Data.Functor ((<&>))
101101
import Data.Functor.Identity
102102
import Data.Hashable
@@ -172,7 +172,6 @@ import qualified StmContainers.Map as STM
172172
import System.FilePath hiding (makeRelative)
173173
import System.IO.Unsafe (unsafePerformIO)
174174
import System.Time.Extra
175-
import Development.IDE.Graph.Database (shakeMarkDirtyKeys)
176175
-- See Note [Guidelines For Using CPP In GHCIDE Import Statements]
177176

178177
#if !MIN_VERSION_ghc(9,3,0)
@@ -854,15 +853,14 @@ newSession recorder extras@ShakeExtras{..} vfsMod shakeDb acts reason = do
854853
whenJust allPendingKeys $ \kk -> setTag otSpan "keys" (BS8.pack $ unlines $ map show $ toListKeySet kk)
855854
let keysActs = pumpActionThread otSpan : map (run otSpan) (reenqueued ++ acts)
856855
res <- try @SomeException $
857-
restore $ shakeRunDatabaseForKeys shakeDb keysActs
856+
restore $ shakeRunDatabaseForKeys (toListKeySet <$> allPendingKeys) shakeDb keysActs
858857
return $ do
859858
let exception =
860859
case res of
861860
Left e -> Just e
862861
_ -> Nothing
863862
logWith recorder Debug $ LogBuildSessionFinish exception
864-
-- mark the key as dirty in hls graph
865-
traverse_ (shakeMarkDirtyKeys shakeDb) allPendingKeys
863+
866864
-- Do the work in a background thread
867865
workThread <- asyncWithUnmask workRun
868866

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

+8-12
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ module Development.IDE.Graph.Database(
88
shakeGetBuildStep,
99
shakeGetDatabaseKeys,
1010
shakeGetDirtySet,
11-
shakeGetCleanKeys,
12-
shakeMarkDirtyKeys,
13-
shakeGetBuildEdges) where
11+
shakeGetCleanKeys
12+
,shakeGetBuildEdges) where
1413
import Control.Concurrent.STM.Stats (readTVarIO)
1514
import Data.Dynamic
1615
import Data.Maybe
@@ -35,7 +34,7 @@ shakeNewDatabase opts rules = do
3534
pure $ ShakeDatabase (length actions) actions db
3635

3736
shakeRunDatabase :: ShakeDatabase -> [Action a] -> IO [a]
38-
shakeRunDatabase = shakeRunDatabaseForKeys
37+
shakeRunDatabase = shakeRunDatabaseForKeys Nothing
3938

4039
-- | Returns the set of dirty keys annotated with their age (in # of builds)
4140
shakeGetDirtySet :: ShakeDatabase -> IO [(Key, Int)]
@@ -53,19 +52,16 @@ unvoid :: Functor m => m () -> m a
5352
unvoid = fmap undefined
5453

5554
-- | Assumes that the database is not running a build
56-
-- dirty keys should be marked using `shakeMarkDirtyKeys`
57-
-- before calling this function
5855
shakeRunDatabaseForKeys
59-
::
60-
ShakeDatabase
56+
:: Maybe [Key]
57+
-- ^ Set of keys changed since last run. 'Nothing' means everything has changed
58+
-> ShakeDatabase
6159
-> [Action a]
6260
-> IO [a]
63-
shakeRunDatabaseForKeys (ShakeDatabase lenAs1 as1 db) as2 = do
61+
shakeRunDatabaseForKeys keysChanged (ShakeDatabase lenAs1 as1 db) as2 = do
62+
incDatabase db keysChanged
6463
fmap (drop lenAs1) $ runActions db $ map unvoid as1 ++ as2
6564

66-
shakeMarkDirtyKeys :: ShakeDatabase -> KeySet -> IO ()
67-
shakeMarkDirtyKeys (ShakeDatabase _ _ db) keys = incDatabase db $ Just (toListKeySet keys)
68-
6965
-- | Given a 'ShakeDatabase', write an HTML profile to the given file about the latest run.
7066
shakeProfileDatabase :: ShakeDatabase -> FilePath -> IO ()
7167
shakeProfileDatabase (ShakeDatabase _ _ s) file = writeProfile file s

0 commit comments

Comments
 (0)