Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 61cf5e4

Browse files
hls-graph: simplify AIO; scoped cancellation; fewer threads; safe cleanup
- Replace ad-hoc AIO with structured concurrency (TVar + async registry); builder returns results directly; remove lazy splitIO/unsafePerformIO - Reduce redundant thread creation; use per-key builderOne and STM retry instead of spawning; fewer races - Add AsyncParentKill (ThreadId, Step) and treat it as async; use cancelWith from Shake to scope cancellation to the current session - Mask critical sections and do uninterruptible cleanup on exception (mark Dirty) to avoid stuck Running and hangs - Adjust types/wiring (Running payload, runAIO takes Step, compute/refresh signatures); minor tweaks in ghcide Shake/Plugin.Test Fixes #4718
1 parent 60a6c48 commit 61cf5e4

File tree

6 files changed

+116
-150
lines changed

6 files changed

+116
-150
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ import Development.IDE.GHC.Orphans ()
140140
import Development.IDE.Graph hiding (ShakeValue,
141141
action)
142142
import qualified Development.IDE.Graph as Shake
143-
import Development.IDE.Graph.Database (ShakeDatabase,
143+
import Development.IDE.Graph.Database (AsyncParentKill (..),
144+
ShakeDatabase,
144145
shakeGetBuildStep,
145146
shakeGetDatabaseKeys,
146147
shakeNewDatabase,
@@ -908,8 +909,11 @@ newSession recorder extras@ShakeExtras{..} vfsMod shakeDb acts reason = do
908909

909910
-- Cancelling is required to flush the Shake database when either
910911
-- the filesystem or the Ghc configuration have changed
912+
step <- shakeGetBuildStep shakeDb
911913
let cancelShakeSession :: IO ()
912-
cancelShakeSession = cancel workThread
914+
cancelShakeSession = do
915+
tid <- myThreadId
916+
cancelWith workThread $ AsyncParentKill tid step
913917

914918
pure (ShakeSession{..})
915919

‎ghcide/src/Development/IDE/Plugin/Test.hs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import Development.IDE.Graph.Database (ShakeDatabase,
3939
shakeGetBuildStep,
4040
shakeGetCleanKeys)
4141
import Development.IDE.Graph.Internal.Types (Result (resultBuilt, resultChanged, resultVisited),
42-
Step (Step))
42+
Step)
4343
import qualified Development.IDE.Graph.Internal.Types as Graph
4444
import Development.IDE.Types.Action
4545
import Development.IDE.Types.HscEnvEq (HscEnvEq (hscEnv))
@@ -145,7 +145,7 @@ getDatabaseKeys :: (Graph.Result -> Step)
145145
getDatabaseKeys field db = do
146146
keys <- shakeGetCleanKeys db
147147
step <- shakeGetBuildStep db
148-
return [ k | (k, res) <- keys, field res == Stepstep]
148+
return [ k | (k, res) <- keys, field res == step]
149149

150150
parseAction :: CI String -> NormalizedFilePath -> Action (Either Text Bool)
151151
parseAction "typecheck" fp = Right . isJust <$> use TypeCheck fp

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module Development.IDE.Graph.Database(
2+
AsyncParentKill(..),
23
ShakeDatabase,
34
ShakeValue,
45
shakeNewDatabase,
@@ -8,8 +9,8 @@ module Development.IDE.Graph.Database(
89
shakeGetBuildStep,
910
shakeGetDatabaseKeys,
1011
shakeGetDirtySet,
11-
shakeGetCleanKeys
12-
,shakeGetBuildEdges) where
12+
shakeGetCleanKeys,
13+
shakeGetBuildEdges) where
1314
import Control.Concurrent.STM.Stats (readTVarIO)
1415
import Data.Dynamic
1516
import Data.Maybe
@@ -42,9 +43,9 @@ shakeGetDirtySet (ShakeDatabase _ _ db) =
4243
Development.IDE.Graph.Internal.Database.getDirtySet db
4344

4445
-- | Returns the build number
45-
shakeGetBuildStep :: ShakeDatabase -> IO Int
46+
shakeGetBuildStep :: ShakeDatabase -> IO Step
4647
shakeGetBuildStep (ShakeDatabase _ _ db) = do
47-
Steps <- readTVarIO $ databaseStep db
48+
s <- readTVarIO $ databaseStep db
4849
return s
4950

5051
-- Only valid if we never pull on the results, which we don't

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,10 @@ actionFork act k = do
8181

8282
isAsyncException :: SomeException -> Bool
8383
isAsyncException e
84+
| Just (_ :: SomeAsyncException) <- fromException e = True
8485
| Just (_ :: AsyncCancelled) <- fromException e = True
8586
| Just (_ :: AsyncException) <- fromException e = True
87+
| Just (_ :: AsyncParentKill) <- fromException e = True
8688
| Just (_ :: ExitCode) <- fromException e = True
8789
| otherwise = False
8890

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /