[Git][ghc/ghc][wip/romes/async-rpc] 5 commits: interp: spawn fillPipe thread, writePipe now safely interruptible
by Andrea Vezzosi (@trac-Saizan) 27 Oct '26
by Andrea Vezzosi (@trac-Saizan) 27 Oct '26
27 Oct '26
Andrea Vezzosi pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
f4cd1fff by Andrea Vezzosi at 2026-10-27T11:37:54+01:00
interp: spawn fillPipe thread, writePipe now safely interruptible
Previously an async exception during a call to `writePipe` could have caused a
partial write, making any further write impossible to parse from the other end.
Now `writePipe` merely pushes the message onto a queue, and the actual write
happens in a separate `fillPipe` thread. As a result of this and previous
changes, `interpCmd` no longer needs `interruptibleMask` to preserve the state
of the protocol.
`writePipe` waits for the actual write to complete, and rethrows exceptions
raised in the write attempt, if any.
- - - - -
90ceb49f by Andrea Vezzosi at 2026-10-27T11:38:07+01:00
Follow `Note [Exceptions in TH]` in `qReport` implementation
`qReport b msg` should use `seqList msg` to trigger any exceptions in the
`String`, as explained in the note.
Through refactors the `seqList msg` call followed the bulk of the implementation
in `GHC.Tc.Gen.Splice.report`, but the call should be in `qReport` itself, so
that, even with -fexternal-interpreter, `msg` gets forced right away and any
exceptions get reported as a compilation error.
Follow up to 'interp: spawn fillPipe thread, writePipe now safely
interruptible'.
- - - - -
9fc81afa by Rodrigo Mesquita at 2026-10-27T11:38:07+01:00
test: make T3171 not fragile and add version for ext interp too
- actually test the sleep of the user-given expression gets interrupted
- the ext interp version tests two things:
- Requests can be cancelled without terminating the ext interp (#18852)
- The stmt being evaluated gets interrupted in the ext interp (that
is, ^C gets sent to the thread running the user-given expression
and doesn't affect the ext interp main thread)
- testing ext interp requires sending ^C to whole process group
Fixes #15383
- - - - -
a5f19ce3 by Andrea Vezzosi at 2026-10-27T11:38:07+01:00
interp: cancel requests if async exceptions while waiting for reply.
- - - - -
d16a4f36 by Andrea Vezzosi at 2026-10-27T11:38:08+01:00
interp: do not terminate ext. interp. process on exception
`sendMessage` throwing an exception does not warrant terminating the external
interpreter process anymore, because communication can keep going no matter what.
`stopInterp` now resets the whole `Interp` state, so that a new
ExtInterpInstance can be later created and work correctly.
`withExtInterp` now calls `stopInterp` on a `PipeClosedException` and rethrows.
Fixes #18852
- - - - -
16 changed files:
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/Runtime/Interpreter/Process.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/Splice.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Message/Async.hs
- libraries/ghci/GHCi/Server.hs
- libraries/ghci/GHCi/Server/Threads.hs
- libraries/template-haskell/Language/Haskell/TH/Syntax.hs
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/ghci/should_run/T3171.stdout
- + testsuite/tests/ghci/should_run/T3171ext.stdout
- testsuite/tests/ghci/should_run/all.T
- + testsuite/tests/th/T8987b.hs
- + testsuite/tests/th/T8987b.stderr
- testsuite/tests/th/all.T
Changes:
=====================================
compiler/GHC/Runtime/Interpreter.hs
=====================================
@@ -105,7 +105,7 @@ import GHCi.Run
import Control.Concurrent
import Control.Monad
import Control.Monad.IO.Class
-import Control.Monad.Catch as MC (mask)
+import Control.Monad.Catch as MC (mask, handle, MonadThrow (..))
import Data.Binary
import Data.ByteString (ByteString)
import qualified Data.ByteString.Short as SBS
@@ -196,16 +196,16 @@ interpCmd interp msg = case interpInstance interp of
#if defined(HAVE_INTERNAL_INTERPRETER)
InternalInterp -> run msg -- Just run it directly
#endif
- ExternalInterp ext -> withExtInterp ext $ \inst ->
- uninterruptibleMask_ $ -- Note [uninterruptibleMask_ and interpCmd]
- sendMessage inst msg
+ ExternalInterp ext -> withExtInterp interp ext $ \inst ->
+ sendMessage inst msg
-
-withExtInterp :: ExceptionMonad m => ExtInterp -> (forall d. ExtInterpInstance d -> m a) -> m a
-withExtInterp ext action = case ext of
+withExtInterp :: ExceptionMonad m => Interp -> ExtInterp -> (forall d. ExtInterpInstance d -> m a) -> m a
+withExtInterp interp ext action = stopInterpOnPipeClosed $ case ext of
ExtJS i -> withJSInterp i action
ExtWasm i -> withWasmInterp i action
ExtIServ i -> withIServ i action
+ where
+ stopInterpOnPipeClosed = MC.handle $ \ (e :: PipeClosedException) -> liftIO (stopInterp interp) >> MC.throwM e
withExtInterpStatus :: ExtInterp -> (forall d. ExtInterpStatusVar d -> m a) -> m a
withExtInterpStatus ext action = case ext of
@@ -213,15 +213,6 @@ withExtInterpStatus ext action = case ext of
ExtWasm i -> action $ interpStatus i
ExtIServ i -> action (interpStatus i)
--- Note [uninterruptibleMask_ and interpCmd]
--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--- If we receive an async exception, such as ^C, while communicating
--- with the iserv process then we will be out-of-sync and not be able
--- to recover. Thus we use uninterruptibleMask_ during
--- communication. A ^C will be delivered to the iserv process (because
--- signals get sent to the whole process group) which will interrupt
--- the running computation and return an EvalException result.
-
-- | Grab a lock on the 'IServ' and do something with it.
-- Overloaded because this is used from TcM as well as IO.
withIServ
@@ -480,11 +471,9 @@ lookupSymbol interp str = withSymbolCache interp str $
#endif
ExternalInterp ext -> case ext of
ExtIServ i -> withIServ i $ \inst -> do
- uninterruptibleMask_ $
sendMessage inst (LookupSymbol (fastStringToShortByteString (interpSymbolToCLabel str)))
ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str)
ExtWasm i -> withWasmInterp i $ \inst -> do
- uninterruptibleMask_ $
sendMessage inst (LookupSymbol (fastStringToShortByteString (interpSymbolToCLabel str)))
lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> InterpSymbol s -> IO (Maybe (RemotePtr ()))
@@ -495,7 +484,6 @@ lookupSymbolInDLL interp dll str = withSymbolCache interp str $
#endif
ExternalInterp ext -> case ext of
ExtIServ i -> withIServ i $ \inst -> do
- uninterruptibleMask_ $
sendMessage inst (LookupSymbolInDLL dll (fastStringToShortByteString (interpSymbolToCLabel str)))
ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str)
-- wasm dyld doesn't track which symbol comes from which .so
@@ -656,6 +644,9 @@ stopInterp interp = case interpInstance interp of
else sendMessage i Shutdown
-- We asked the server to shutdown, so we will also shutdown any communication.
closePipe (interpPipe (instProcess i))
+ modifyMVar_ (loader_state (interpLoader interp)) (const $ pure Nothing)
+ purgeInterpSymbolCache (interpSymbolCache interp)
+ modifyMVar_ (interpStringCache interp) (const $ pure emptyFsEnv)
pure InterpPending
-- -----------------------------------------------------------------------------
=====================================
compiler/GHC/Runtime/Interpreter/Process.hs
=====================================
@@ -12,13 +12,10 @@ import GHC.Prelude
import GHC.Runtime.Interpreter.Types
import GHCi.Message
-import GHC.IO (catchException)
import GHC.Utils.Panic
import GHC.Utils.Exception as Ex
import Data.Binary
-import System.Exit
-import System.Process
import Control.Concurrent
import Data.IORef
import Control.Concurrent.STM
@@ -34,7 +31,6 @@ import Control.Concurrent.STM
sendMessage :: Binary a => ExtInterpInstance d -> Message a -> IO a
sendMessage i msg =
remoteCall (interpPipe proc) msg
- `catchException` \(e :: SomeException) -> handleInterpProcessFailure proc e
where
proc = instProcess i
@@ -64,7 +60,7 @@ sendTHComputation i msg reqHandler = mask $ \restore -> do
where
proc = instProcess i
handleOne mbox doneRef = do
- handleRemoteTHCall (interpPipe proc) mbox $ \req -> do
+ handleRemoteTHCall (interpPipe proc) mbox $ \_setCancel req -> do
(stop, res) <- reqHandler req
writeIORef doneRef stop
return res
@@ -77,18 +73,6 @@ sendTHComputation i msg reqHandler = mask $ \restore -> do
else loop
in loop
-handleInterpProcessFailure :: InterpProcess -> SomeException -> IO a
-handleInterpProcessFailure i e = do
- let hdl = interpHandle i
- ex <- getProcessExitCode hdl
- case ex of
- Just (ExitFailure n) ->
- throwIO (InstallationError ("External interpreter terminated (" ++ show n ++ ")"))
- _ -> do
- terminateProcess hdl
- _ <- waitForProcess hdl
- throw e
-
data CancelTHHandler = CancelTHHandler deriving Show
instance Exception CancelTHHandler where
fromException = asyncExceptionFromException
=====================================
compiler/GHC/Tc/Errors/Types.hs
=====================================
@@ -7091,6 +7091,7 @@ data SpliceFailReason
th/T5976
th/T7276a
th/T8987
+ th/T8987b
th/TH_exn1
th/TH_exn2
th/TH_runIO
=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -1160,7 +1160,7 @@ runRemoteModFinalizers (ThModFinalizers finRefs) = do
runQinTcM $ sequence_ qs
#endif
- ExternalInterp ext -> withExtInterp ext $ \inst -> do
+ ExternalInterp ext -> withExtInterp interp ext $ \inst -> do
tcg <- getGblEnv
th_state <- readTcRef (tcg_th_remote_state tcg)
case th_state of
@@ -1472,11 +1472,9 @@ when showing an error message.
To call runQ in the Tc monad, we need to make TcM an instance of Quasi:
-}
--- 'msg' is forced to ensure exceptions don't escape,
--- see Note [Exceptions in TH]
report :: Bool -> [Char] -> TcM ()
-report True msg = seqList msg $ addErr $ TcRnTHError $ ReportCustomQuasiError True msg
-report False msg = seqList msg $ addDiagnostic $ TcRnTHError $ ReportCustomQuasiError False msg
+report True msg = addErr $ TcRnTHError $ ReportCustomQuasiError True msg
+report False msg = addDiagnostic $ TcRnTHError $ ReportCustomQuasiError False msg
addTopDecls :: [TH.Dec] -> TcM ()
addTopDecls thds = do
@@ -1575,7 +1573,7 @@ metaHandlersTcM runInIO = TH.MetaHandlers {
; let i = toInteger (getKey u)
; return (TH.mkNameU s i) }
- , mReport = fmap runInIO . report
+ , mReport = \ b msg -> runInIO (report b msg)
, mLocation = runInIO location
@@ -1819,7 +1817,7 @@ runTH ty fhv = do
return r
#endif
- ExternalInterp ext -> withExtInterp ext $ \inst -> do
+ ExternalInterp ext -> withExtInterp interp ext $ \inst -> do
-- Run it on the server. For an overview of how TH works with
-- Remote GHCi, see Note [Remote Template Haskell] in
-- libraries/ghci/GHCi/TH.hs.
=====================================
libraries/ghci/GHCi/Message.hs
=====================================
@@ -27,7 +27,7 @@ module GHCi.Message
, Pipe(..), mkPipeFromHandles, mkPipeFromContinuations, closePipe
, remoteCall, remoteTHCall
, handleRemoteCall, handleRemoteTHCall, writeReply
- , RemoteProcessException(..), PipeReadClosedException(..)
+ , RemoteProcessException(..), PipeClosedException(..)
, InboxId(..)
, newMailbox
@@ -666,12 +666,12 @@ remoteCall pipe msg = either throwIO (pure . runGet get)
-- | Handle a single 'Message' request on the interpreter and reply to the host
handleRemoteCall :: Pipe
-> (Msg -> IO Msg) {-^ Msg hook -}
- -> (forall a. (Show a, Binary a) => WriteReply a %1 -> Message a -> IO r)
+ -> (forall a. (Show a, Binary a) => WriteReply a %1 -> (IO () -> IO ()) -> Message a -> IO r)
-> IO r
handleRemoteCall pipe hook k =
- handleAsyncReq pipe getMessage Nothing \(WriteReply writer) msg0 -> IO \s0 ->
+ handleAsyncReq pipe getMessage Nothing \(WriteReply writer) sa msg0 -> IO \s0 ->
case hook msg0 |#> s0 of -- unIO for linearity checking
- (# s1, Msg msg #) -> k (WriteReply \x -> writer (fmap put x)) msg |#> s1
+ (# s1, Msg msg #) -> k (WriteReply \x -> writer (fmap put x)) sa msg |#> s1
-- | Send a 'THMessage' request to the host and wait for a reply from the host
-- to the interpreter.
@@ -687,9 +687,9 @@ remoteTHCall pipe ii msg = either throwIO (pure . runGet get)
-- Symmterically to 'remoteTHCall', we always want to specify the 'InboxId' for
-- RunTH "reverse requests"
handleRemoteTHCall
- :: Pipe -> InboxId -> (forall a. (Show a, Binary a) => THMessage a -> IO a) -> IO ()
+ :: Pipe -> InboxId -> (forall a. (Show a, Binary a) => (IO () -> IO ()) -> THMessage a -> IO a) -> IO ()
handleRemoteTHCall pipe ii k =
- handleAsyncReq pipe getTHMessage (Just ii) \writer (THMsg msg) -> IO \s0 ->
- case k msg |#> s0 of -- unIO for linearity checking
+ handleAsyncReq pipe getTHMessage (Just ii) \writer sa (THMsg msg) -> IO \s0 ->
+ case k sa msg |#> s0 of -- unIO for linearity checking
(# s1, a #) -> writeReply writer (put a) |#> s1
=====================================
libraries/ghci/GHCi/Message/Async.hs
=====================================
@@ -7,7 +7,7 @@ module GHCi.Message.Async
(
-- * Pipes
Pipe(..), mkPipeFromHandles, mkPipeFromContinuations
- , closePipe, PipeReadClosedException(..)
+ , closePipe, PipeClosedException(..)
-- * Interface for async bidirectional RPC
, remoteAsyncReq, handleAsyncReq
@@ -77,6 +77,10 @@ data Pipe = Pipe
, pipeReadClosed :: !(TVar Bool)
-- ^ After the pipe is closed, messages can no longer be received from the
-- other end, but the 'AsyncManager' queues might not be empty yet.
+ , pipeWriteClosed :: !(TVar Bool)
+ -- ^ After the write end of the pipe is closed we can no longer submit
+ -- requests or respond to ones we receive, but we might still receive
+ -- replies.
}
-- | Make a 'Pipe' from a 'Handle' to read and a 'Handle' to write.
@@ -91,7 +95,13 @@ mkPipeFromHandles pipeRead pipeWrite = do
-- | Make a 'Pipe' from a reader function and a writer function.
-- The pipe should be closed with 'closePipe', which will call 'pipeCloseRead' and 'pipeCloseWrite'.
-mkPipeFromContinuations :: IO ByteString -> (B.Builder -> IO ())
+--
+-- Arguments 'getSome' and 'putAll' should throw an `IOException` when communication fails
+-- or is no longer possible.
+mkPipeFromContinuations :: IO ByteString
+ -- ^ getSome
+ -> (B.Builder -> IO ())
+ -- ^ putAll
-> IO ()
-- ^ pipeCloseRead
-> IO ()
@@ -101,6 +111,7 @@ mkPipeFromContinuations getSome putAll pipeCloseRead pipeCloseWrite = mdo
pipeLeftovers <- newIORef Nothing
pipeLock <- newMVar ()
pipeReadClosed <- newTVarIO False
+ pipeWriteClosed <- newTVarIO False
mdo
pipeAsyncMngr <- newAsyncManager p
let p = Pipe { .. }
@@ -114,19 +125,33 @@ mkPipeFromContinuations getSome putAll pipeCloseRead pipeCloseWrite = mdo
-- write. Only then do we stop the drain thread, which closes the read end
-- itself once its read has finished. On Windows its read can't be
-- interrupted, so this waits for the other side to close its write end too.
+-- Finally we stop the write thread, which could be blocked waiting for more to write.
closePipe :: Pipe -> IO ()
closePipe p@Pipe{..} = do
readAlreadyClosed <- atomically $ do
closed <- readTVar pipeReadClosed
failPendingReplies p (toException PipeReadClosedException)
pure closed
- withLock p pipeCloseWrite `finally`
- unless readAlreadyClosed
- (throwTo (asyncDrainTid pipeAsyncMngr) PipeReadClosedException)
--- | We've closed the pipe read end on this process
-data PipeReadClosedException = PipeReadClosedException deriving Show
-instance Exception PipeReadClosedException
+ writeAlreadyClosed <- atomically $ do
+ closed <- readTVar pipeWriteClosed
+ failPendingWrites p (toException PipeWriteClosedException)
+ pure closed
+
+ unless writeAlreadyClosed (withLock p pipeCloseWrite)
+ `finally` do
+ unless readAlreadyClosed
+ (throwTo (asyncDrainTid pipeAsyncMngr) PipeReadClosedException)
+ unless writeAlreadyClosed
+ (throwTo (asyncFillTid pipeAsyncMngr) PipeWriteClosedException)
+
+data PipeClosedException
+ = PipeReadClosedException -- ^ We've closed the pipe read end on this process
+
+ | PipeWriteClosedException -- ^ We've closed the pipe write end on this process
+ deriving Show
+instance Exception PipeClosedException
+
--------------------------------------------------------------------------------
-- ** Pipe thread-safe read/write
@@ -135,7 +160,19 @@ instance Exception PipeReadClosedException
-- and identify whether they are requests or replies.
writePipe :: Pipe -> IddMsg -> IO ()
-writePipe p@Pipe{..} = withLock p . putAll . execPut . put
+writePipe p msg = do
+ var <- atomically $ writePipeAsync p msg
+ either throwIO pure =<< atomically (takeTMVar var)
+
+writePipeAsync :: Pipe -> IddMsg -> STM (TMVar (Either SomeException ()))
+writePipeAsync Pipe{..} msg = do
+ var <- newEmptyTMVar
+ readTVar pipeWriteClosed >>= \case
+ True -> throwSTM PipeWriteClosedException
+ False -> pure ()
+ writeTQueue (writeQueue pipeAsyncMngr) (msg, var)
+ pure var
+
-- | Only the 'drainPipe' thread should read from the pipe directly. Other
-- functions should wait for the matching reply to be delivered asynchronously.
@@ -181,6 +218,8 @@ withLock Pipe{..} = bracket (takeMVar pipeLock) (putMVar pipeLock) . const
--------------------------------------------------------------------------------
-- | Send an asynchronous request and block waiting for a matching reply
+--
+-- See Note [Exceptions during serialization] about exceptions the 'Put' argument might raise.
remoteAsyncReq :: Pipe -> Put -> (Maybe InboxId) -> IO (Either SomeException LB.ByteString)
remoteAsyncReq pipe msg ii = do
@@ -205,14 +244,18 @@ remoteAsyncReq pipe msg ii = do
-- Write request
writePipe pipe (Request uq ii (runPut msg))
`onException`
- -- the req wasn't done, or no one will be reading the reply:
- -- in either case, drop it from the pending map.
- atomically (modifyTVar pendingReplies (IntMap.delete uq))
+ -- the req wasn't done, or no one will be reading the reply:
+ -- in either case, drop it from the pending map.
+ atomically (modifyTVar pendingReplies (IntMap.delete uq))
-- Block waiting for reply
atomically (takeTMVar wv)
`onException`
- atomically (modifyTVar pendingReplies (IntMap.delete uq))
+ atomically (do
+ modifyTVar pendingReplies (IntMap.delete uq)
+ -- we don't wait for Cancel to be written on the pipe,
+ -- and won't get a reply: nowhere to report it anyway.
+ writePipeAsync pipe (Cancel uq))
-- | Receive a single asynchronous request and send a matching reply
-- asynchronously (the handler may fork a computation that eventually replies
@@ -222,19 +265,25 @@ remoteAsyncReq pipe msg ii = do
-- It must be used exactly once (all requests expect a reply, and you can't
-- reply more than once). Linear types enforce the handler replies in every
-- branch, and if the handler otherwise throws, it is handled by 'handleAsyncReq'.
-handleAsyncReq :: Pipe -> Get a -> (Maybe InboxId) -> (WriteReply Put %1 -> a -> IO r) -> IO r
+--
+-- See Note [Exceptions during serialization] about exceptions the 'Put' argument might raise.
+handleAsyncReq :: Pipe -> Get a -> (Maybe InboxId) -> (WriteReply Put %1 -> (IO () -> IO ()) -> a -> IO r) -> IO r
handleAsyncReq pipe getit mii k = mask $ \restore -> do
let am = pipeAsyncMngr pipe
ack <- newEmptyMVar
-- Block waiting for request
mbreq <- atomically $ do
+ readTVar (pipeWriteClosed pipe) >>= \case
+ -- We will not be able to write the reply, so no point in continuiting.
+ True -> throwSTM PipeWriteClosedException
+ False -> pure ()
isClosed <- readTVar (pipeReadClosed pipe)
taken <- case mii of
Nothing -> tryReadTQueue $ requestsQueue am
Just ii -> tryReadTQueue =<< getMailbox am ii
case taken of
- Just req -> pure (Just req)
+ Just req@(uq,_) -> fetchedRequest am uq >> pure (Just req)
Nothing | isClosed -> pure Nothing -- empty and closed
| otherwise -> retry -- wait for msg
@@ -242,9 +291,9 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
Nothing -> throwIO PipeReadClosedException -- can't expect reqs
Just (uq, bs) -> do
let reply p = do
- writePipe pipe (Reply uq (bimap toSerializableException runPut p))
+ b <- atomically $ doneHandling am uq
+ when b $ writePipe pipe (Reply uq (bimap toSerializableException runPut p))
putMVar ack ()
-
-- Run the continuation which must reply exactly once with 'writeReply'
case runGetOrFail getit bs of
Left (_, _, err) -> do
@@ -252,7 +301,7 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
reply (Left (toException exc))
throwIO exc
Right (_, _, it) ->
- restore (k (WriteReply reply) it)
+ restore (k (WriteReply reply) (setActive am uq) it)
-- If there's an exception before the reply is sent, reply with an error instead.
`catch` \(e :: SomeException) -> do
@@ -266,6 +315,7 @@ handleAsyncReq pipe getit mii k = mask $ \restore -> do
reply (Left e)
throwIO e
+
-- | 'handleSyncReq' failed to decode an incoming request payload using the given @'Get' a@
newtype DecodeAsyncReqException = DecodeAsyncReqException String deriving Show
instance Exception DecodeAsyncReqException
@@ -307,6 +357,28 @@ getMailbox am (InboxId ii) = do
-- ** Async matching "internals" -----------------------------------------------
+-- | Tracks handling status of a received 'Request'. The values are states of a
+-- tiny state machine used to coordinate cancelations.
+--
+-- 'handleAsyncReq' will pop a request from the appropriate queue, setting the
+-- status to `Fetched`. Then one of two things can happen first:
+-- - we receive a 'Cancel', then status is set to `Canceling` so the cancel
+-- action will run when set.
+-- - handler sets a cancel action, then reception of a `Cancel` runs that
+-- action and deletes the RequestStatus.
+--
+-- If RequestStatus is `Canceling` or absent, then a `Reply` won't be sent.
+--
+-- The two possible transition paths:
+-- requestsQueue -> Fetched -> Active cancel -> gone
+-- requestsQueue -> Fetched -> Canceling -> gone
+
+data RequestStatus
+ = Fetched -- ^ 'Fetched' from a request queue, to pass to handler.
+ | Active (IO ()) -- ^ Handler set a cancel action, and has not sent a reply
+ -- yet. The cancel action must not block.
+ | Canceling -- ^ `Cancel` received while status is still `Fetched`.
+
data AsyncManager = AsyncManager
{ pendingReply :: !(TVar (IntMap (TMVar (Either SomeException LB.ByteString))))
-- ^ When a request is sent, keep track that we're expecting a reply. The
@@ -317,10 +389,16 @@ data AsyncManager = AsyncManager
-- /without/ a specific 'InboxId', queue it here. A request handler will
-- pop the next request from it. (Nothing except the 'drainPipe' thread
-- should read from the pipe). Read with @'handleAsyncReq' p get Nothing@.
+ , cancelStatus :: !(TVar (IntMap RequestStatus))
+ -- ^ When a `Cancel uq` is received, we lookup `uq` in this map and call the
+ -- callback if present.
, mailboxQueues :: !(TVar (IntMap (TQueue (CorrelationId, LB.ByteString))))
-- ^ Requests for a specific 'InboxId' that can be read using
-- @'handleAsyncReq' p get (Just <mailboxid>)@.
+ , writeQueue :: !(TQueue (IddMsg, TMVar (Either SomeException ())))
+ -- ^ Messages to write on the pipe.
, asyncDrainTid :: !ThreadId
+ , asyncFillTid :: !ThreadId
, asyncFreshId :: !(IORef Int)
}
@@ -346,15 +424,21 @@ type CorrelationId = Int
-- exclusively.
data IddMsg = Request !CorrelationId !(Maybe InboxId) LB.ByteString
| Reply !CorrelationId (Either SerializableException LB.ByteString)
+ | Cancel !CorrelationId -- ^ Technically a Request, but no Reply
+ -- is expected, the CorrelationId is the
+ -- one of the Request being canceled.
instance Binary IddMsg where
put (Request i ii bs) = putWord8 0 >> put i >> put ii >> put bs
put (Reply i bs) = putWord8 1 >> put i >> put bs
+ put (Cancel i) = putWord8 2 >> put i
+
get = do
b <- getWord8
case b of
0 -> Request <$> get <*> get <*> get
1 -> Reply <$> get <*> get
+ 2 -> Cancel <$> get
_ -> fail $ "impossible: Binary IddMsg - " ++ show b
newAsyncManager :: Pipe -> IO AsyncManager
@@ -362,11 +446,17 @@ newAsyncManager pipe = do
asyncFreshId <- newIORef 0
pendingReply <- newTVarIO IntMap.empty
requestsQueue <- newTQueueIO
+ cancelStatus <- newTVarIO IntMap.empty
mailboxQueues <- newTVarIO IntMap.empty
+ writeQueue <- newTQueueIO
-- Fork thread to drain read end.
-- (cleaned up on 'closePipe')
- asyncDrainTid <- forkIOWithUnmask (drainPipe pipe)
+ asyncDrainTid <- mask_ $ forkIOWithUnmask (drainPipe pipe)
+
+ -- Fork thread to fill write end.
+ -- (cleaned up on 'closePipe')
+ asyncFillTid <- mask_ $ forkIOWithUnmask (fillPipe pipe)
let am = AsyncManager{..}
pure am
@@ -382,41 +472,134 @@ drainPipe :: Pipe -> (forall x. IO x -> IO x) -> IO ()
drainPipe p unmask = catch (unmask $ loop `finally` pipeCloseRead p) replyToPendings where
loop = do
readPipe p >>= \case
- -- Receive a reply to a pending notification
- Just (Reply uq bs) -> do
- atomically $ do
- m <- readTVar (pendingReply am)
- case IntMap.lookup uq m of
- Nothing ->
- -- the req was dropped from pending bc there was an exception, and no
- -- one's listening any more. the reply is ignored
- pure ()
- Just wv -> do
- writeTVar (pendingReply am) (IntMap.delete uq m)
- -- signal matching request
- putTMVar wv (bimap (toException . RemoteProcessException) id bs)
- loop
- -- Receive a request and queue it
- Just (Request uq mbi bs) -> do
- atomically $ case mbi of
- Nothing ->
- -- "Global" request
- writeTQueue (requestsQueue am) (uq,bs)
- Just ii -> do
- -- "Specific mailbox" request
- q <- getMailbox am ii
- writeTQueue q (uq,bs)
+ Just msg -> do
+ handleMsg msg
loop
-- EOF on read handle
Nothing -> do
-- clean up pipe then exit loop
replyToPendings (toException PipeReadClosedException)
pure ()
+ handleMsg = \case
+ -- Receive a reply to a pending notification
+ Reply uq bs -> do
+ atomically $ do
+ m <- readTVar (pendingReply am)
+ case IntMap.lookup uq m of
+ Nothing ->
+ -- the req was dropped from pending bc there was an exception, and no
+ -- one's listening any more. the reply is ignored
+ pure ()
+ Just wv -> do
+ writeTVar (pendingReply am) (IntMap.delete uq m)
+ -- signal matching request
+ putTMVar wv (bimap (toException . RemoteProcessException) id bs)
+ -- Receive a request and queue it
+ Request uq mbi bs -> do
+ atomically $ case mbi of
+ Nothing ->
+ -- "Global" request
+ writeTQueue (requestsQueue am) (uq,bs)
+ Just ii -> do
+ -- "Specific mailbox" request
+ q <- getMailbox am ii
+ writeTQueue q (uq,bs)
+ Cancel uq -> cancelRequest am uq
replyToPendings e = atomically $ failPendingReplies p e
am = pipeAsyncMngr p
+cancelRequest :: AsyncManager -> CorrelationId -> IO ()
+cancelRequest am uq = join . atomically $ do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> pure (pure ())
+ Just Fetched -> writeTVar (cancelStatus am) (IntMap.insert uq Canceling cs) >> pure (pure ())
+ Just (Active cancel) -> writeTVar (cancelStatus am) (IntMap.delete uq cs) >> pure cancel
+ Just Canceling -> pure (pure ())
+
+-- | Returns @True@ when the handler should write its 'Reply'.
+doneHandling :: AsyncManager -> CorrelationId -> STM Bool
+doneHandling am uq = do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> pure False
+ Just s -> do
+ writeTVar (cancelStatus am) $ IntMap.delete uq cs
+ case s of
+ Canceling -> pure False
+ _ -> pure True
+
+setActive :: AsyncManager -> CorrelationId -> IO () -> IO ()
+setActive am uq cancel = join . atomically $ do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> pure (pure ()) -- reply already received.
+ Just Fetched -> writeTVar (cancelStatus am) (IntMap.insert uq (Active cancel) cs) >> pure (pure ())
+ Just (Active _) -> writeTVar (cancelStatus am) (IntMap.insert uq (Active cancel) cs) >> pure (pure ())
+ Just Canceling -> pure cancel
+
+fetchedRequest :: AsyncManager -> CorrelationId -> STM ()
+fetchedRequest am uq = do
+ cs <- readTVar (cancelStatus am)
+ case IntMap.lookup uq cs of
+ Nothing -> writeTVar (cancelStatus am) (IntMap.insert uq Fetched cs)
+ Just Fetched -> error "impossible"
+ Just (Active _) -> error "impossible"
+ Just Canceling -> error "impossible"
+
+
+
+{-
+Note [Exceptions during serialization]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+For efficiency reasons, any `IddMsg` to be sent is forced only when already
+writing onto the Pipe, so we cannot discern whether any raised exception
+originated due to forcing during serialization or from interacting with the
+Pipe.
+
+If the exceptions happen to be `SomeAsyncException` or `IOException` the write
+end of the `Pipe` will be closed while rethrowing them, as those are likely to
+indicate something is wrong with the `Pipe` itself. Same for
+PipeWriteClosedException, used by `closePipe`.
+
+It is recommended to fully force messages at the source, to avoid needlessly
+interrupting communication.
+-}
+
+
+-- | "Fill"s write end of the Pipe with queued messages.
+--
+-- Because Pipe is written to from this thread rather than 'writePipe', calls to
+-- the latter can be interrupted without compromising the protocol.
+--
+-- Closes the Pipe write end when stopping, notifying any messages still queued to write.
+fillPipe :: Pipe -> (forall x. IO x -> IO x) -> IO ()
+fillPipe p unmask = catch (loop `finally` pipeCloseWrite p) (atomically . failPendingWrites p) where
+ loop = do
+ (msg,var) <- atomically $ readTQueue (writeQueue am)
+ success <- handle (\ e -> atomically (putTMVar var (Left e)) >> rethrowIfPipeFatal e >> pure False) $ do
+ unmask $ withLock p (putAll p . execPut . put $ msg)
+ pure True
+ when success $ atomically $ putTMVar var (Right ())
+ loop
+
+ -- See Note [Exceptions during serialization]
+ rethrowIfPipeFatal e
+ | Just SomeAsyncException{} <- fromException e = throwIO e
+ | Just (_ :: IOException) <- fromException e = throwIO e
+ | Just PipeWriteClosedException <- fromException e = throwIO e
+ | otherwise = pure ()
+ am = pipeAsyncMngr p
+
+failPendingWrites :: Pipe -> SomeException -> STM ()
+failPendingWrites p e = do
+ writeTVar (pipeWriteClosed p) True
+ writes <- flushTQueue (writeQueue (pipeAsyncMngr p))
+ mapM_ (`writeTMVar` Left e) (map snd writes)
+
failPendingReplies :: Pipe -> SomeException -> STM ()
failPendingReplies p e = do
-- reqs are only added if pipe not closed;
@@ -456,7 +639,7 @@ runWriteReply (WriteReply r) = r
(|#>) (IO fs) s = fs s
(%>>=) :: (IO a) -> (a -> IO b) %1 -> IO b
-(%>>=) = \ m f -> IO (\s0 ->
+(%>>=) = \ m -> \ f -> IO (\s0 ->
case m |#> s0 of -- unIO for linearity checking
(# s1, x #) -> f x |#> s1)
infixl 1 %>>=
=====================================
libraries/ghci/GHCi/Server.hs
=====================================
@@ -66,13 +66,13 @@ servWithCustom
-> IO ()
servWithCustom verbose hook pipe restore customHandler = do
ref <- newIORef False
- withThreadManager $ \mngr ->
+ withThreadManager $ \mngr -> do
loop ref mngr `finally` closePipe pipe
where
loop doneRef mngr = do
when verbose $ trace "reading pipe..."
- handleRemoteCall pipe hook $ \wr (msg :: Message a) ->
+ handleRemoteCall pipe hook $ \wr setCancel (msg :: Message a) ->
discardCtrlC %>>= \_ ->
when verbose (trace ("msg: " ++ (show msg))) %>>= \_ ->
@@ -83,8 +83,10 @@ servWithCustom verbose hook pipe restore customHandler = do
reply () %>>= writeReply wr
RunTH ii st q ty loc -> spawnFinally mngr (runWriteReply wr)
(wrapRunTH ii (runTH pipe ii st q ty loc))
+ (setCancel . void . forkIO . killThread)
RunModFinalizers ii st qs -> spawnFinally mngr (runWriteReply wr)
(wrapRunTH ii (runModFinalizerRefs pipe ii st qs))
+ (setCancel . void . forkIO . killThread)
_other -> run msg >>= reply %>>= writeReply wr
isDone <- readIORef doneRef
=====================================
libraries/ghci/GHCi/Server/Threads.hs
=====================================
@@ -41,8 +41,8 @@ withThreadManager k = do
-- | Linear and resource-safe because 'ThreadManager' is guaranteed to wait or
-- cancel all threads.
-spawnFinally :: ThreadManager -> (Either SomeException a -> IO ()) %1 -> IO a -> IO ()
-spawnFinally ThreadManager{..} = unsafe_linear \fin -> \action -> void $
+spawnFinally :: ThreadManager -> (Either SomeException a -> IO ()) %1 -> IO a -> (ThreadId -> IO b) -> IO b
+spawnFinally ThreadManager{..} = unsafe_linear \fin -> \action -> \k ->
forkFinally
( mask $ \unmask -> do
tid <- myThreadId
@@ -57,6 +57,7 @@ spawnFinally ThreadManager{..} = unsafe_linear \fin -> \action -> void $
else throwIO ThreadKilled
)
( \ea -> fin ea )
+ >>= k
unsafe_linear :: (a -> b) %1 -> (a %1 -> b)
unsafe_linear = Unsafe.unsafeCoerce (Unsafe.unsafeCoerce :: (a -> b) -> (a %1 -> b))
=====================================
libraries/template-haskell/Language/Haskell/TH/Syntax.hs
=====================================
@@ -528,7 +528,9 @@ class (MonadIO m, MonadFail m) => Quasi m where
-- | Report an error (True) or warning (False)
-- ...but carry on; use 'fail' to stop. See 'report'.
qReport :: Bool -> String -> m ()
- qReport b s = qRunQ $ report b s
+ -- 'msg' is forced to ensure exceptions don't escape,
+ -- see Note [Exceptions in TH]
+ qReport b msg = seqList msg $ qRunQ $ Internal.report b msg
-- | See 'recover'.
qRecover :: m a -- ^ the error handler
@@ -665,13 +667,18 @@ instance Quasi Q where
-- | Report an error (True) or warning (False),
-- but carry on; use 'fail' to stop.
report :: Bool -> String -> Q ()
-report = Internal.report
+report = qReport
{-# DEPRECATED report "Use reportError or reportWarning instead" #-} -- deprecated in 7.6
-- | Report an error to the user, but allow the current splice's computation to carry on. To abort the computation, use 'fail'.
reportError :: String -> Q ()
-reportError = report True
+reportError = qReport True
-- | Report a warning to the user, and carry on.
reportWarning :: String -> Q ()
-reportWarning = report False
+reportWarning = qReport False
+
+-- | copied from GHC.Utils.Misc
+seqList :: [a] -> b -> b
+seqList [] b = b
+seqList (x:xs) b = x `seq` seqList xs b
=====================================
testsuite/tests/ghci/should_run/Makefile
=====================================
@@ -3,10 +3,20 @@ include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
# Test that threadDelay can be interrupted by ^C.
-T3171:
- echo "do Control.Concurrent.threadDelay 3000000; putStrLn \"threadDelay was not interrupted\"" | \
- "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) & \
- sleep 2; kill -INT $$!; wait
+# Wait for the statement to start before interrupting (#15383), and signal
+# the external interpreter too (the `pgrep -P $!`), as ^C in a terminal would.
+#
+# The ext interp tests both:
+# - interrupting a remote request doesn't terminate the ext interpreter (#18852)
+# - a ^C gets propagated to the thread evaluating the user request on the ext
+# interpreter so that it gets interrupted
+T3171ext: T3171_OPTS = -fexternal-interpreter
+T3171 T3171ext:
+ rm -f $@.started
+ echo 'do { writeFile "$@.started" ""; (Control.Concurrent.threadDelay 100000000 >> putStrLn "threadDelay was not interrupted.") `Control.Exception.catch` \(e :: Control.Exception.SomeException) -> System.IO.hPutStrLn System.IO.stderr ("threadDelay was interrupted: " ++ show e) >> Control.Exception.throwIO e }' | \
+ "$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) $(T3171_OPTS) & \
+ while [ ! -e $@.started ] && kill -0 $$! 2>/dev/null; do sleep 0.1; done; \
+ kill -INT $$! $$(pgrep -P $$!); wait
TopEnvIface:
"$(TEST_HC)" $(TEST_HC_OPTS_INTERACTIVE) TopEnvIface -v1 -fno-hide-source-paths -e "a" -e ":q" -fwrite-if-simplified-core -fwrite-interface
=====================================
testsuite/tests/ghci/should_run/T3171.stdout
=====================================
@@ -1 +1,2 @@
+threadDelay was interrupted: user interrupt
Interrupted.
=====================================
testsuite/tests/ghci/should_run/T3171ext.stdout
=====================================
@@ -0,0 +1,2 @@
+threadDelay was interrupted: user interrupt
+Interrupted.
=====================================
testsuite/tests/ghci/should_run/all.T
=====================================
@@ -12,11 +12,17 @@ test('T27287', [just_ghci, combined_output], makefile_test, [])
test('T3171',
[when(opsys('mingw32'),skip),
- fragile(15383),
req_interp,
combined_output],
makefile_test, [])
+test('T3171ext',
+ [when(opsys('mingw32'),skip),
+ req_interp,
+ unless(config.have_ext_interp, skip),
+ combined_output],
+ makefile_test, [])
+
test('ghcirun004', just_ghci, compile_and_run, [''])
test('T8377', just_ghci, compile_and_run, [''])
test('T9914', just_ghci, ghci_script, ['T9914.script'])
=====================================
testsuite/tests/th/T8987b.hs
=====================================
@@ -0,0 +1,8 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module T8987b where
+import Language.Haskell.TH
+import System.IO.Error
+import Control.Exception
+
+$(reportWarning ['1', throw (userError "IOError in warning")] >> return [])
=====================================
testsuite/tests/th/T8987b.stderr
=====================================
@@ -0,0 +1,6 @@
+T8987b.hs:1:1: error: [GHC-87897]
+ Exception when trying to run compile-time code:
+ user error (IOError in warning)
+ Code: (reportWarning ['1', throw (userError "IOError in warning")]
+ >> return [])
+
=====================================
testsuite/tests/th/all.T
=====================================
@@ -306,6 +306,7 @@ test('T8884', normal, compile, ['-v0'])
test('T8954', normal, compile, ['-v0'])
test('T8932', normal, compile_fail, ['-v0'])
test('T8987', normal, compile_fail, ['-v0'])
+test('T8987b', normal, compile_fail, ['-v0'])
test('T7241', normal, compile_fail, ['-v0'])
test('T9262', normal, compile, ['-v0'])
test('T9199', normal, compile, ['-v0'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5be020df64ac8df323a83a0043fc42…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/5be020df64ac8df323a83a0043fc42…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/romes/multi-threaded-debugger] 40 commits: test: make T3171 not fragile and add version for ext interp too
by Rodrigo Mesquita (@alt-romes) 27 Oct '26
by Rodrigo Mesquita (@alt-romes) 27 Oct '26
27 Oct '26
Rodrigo Mesquita pushed to branch wip/romes/multi-threaded-debugger at Glasgow Haskell Compiler / GHC
Commits:
422ec8e5 by Rodrigo Mesquita at 2026-10-23T14:41:27+02:00
test: make T3171 not fragile and add version for ext interp too
- actually test the sleep of the user-given expression gets interrupted
- the ext interp version tests two things:
- Requests can be cancelled without terminating the ext interp (#18852)
- The stmt being evaluated gets interrupted in the ext interp (that
is, ^C gets sent to the thread running the user-given expression
and doesn't affect the ext interp main thread)
- testing ext interp requires sending ^C to whole process group
Fixes #15383
- - - - -
ea1dd1c7 by Andrea Vezzosi at 2026-10-26T09:50:00+01:00
interp: cancel requests if async exceptions while waiting for reply.
- - - - -
05f68d0e by Andrea Vezzosi at 2026-10-26T18:21:34+01:00
interp: more uninterruptibleMask_ removed
- - - - -
7e21b3f8 by Andrea Vezzosi at 2026-10-26T23:42:27+01:00
interp: do not terminate ext. interp. process on exception
`sendMessage` throwing an exception does not warrant terminating the external
interpreter process anymore, because communication can keep going no matter what.
`stopInterp` now resets the whole `Interp` state, so that a new
ExtInterpInstance can be later created and work correctly.
- - - - -
1c9fe4ea by Andrea Vezzosi at 2026-10-27T08:54:09+01:00
fixup! interp: spawn fillPipe thread, writePipe now safely interruptible
- - - - -
8dbf2fd4 by Andrea Vezzosi at 2026-10-27T08:58:54+01:00
interp: withExtInterp calls stopInterp on PipeClosedException
- - - - -
5be020df by Andrea Vezzosi at 2026-10-27T09:05:16+01:00
fixup! interp: cancel requests if async exceptions while waiting for reply.
- - - - -
081d2af7 by Rodrigo Mesquita at 2026-10-27T10:33:45+00:00
Global break action which uses shared thread map
the status Var must actually be global across all threads, otherwise all of them will block trying to write some Status Var no one is looking at at all
have to fix these toggle untoggle things
very satisfying solution with mutable state
Matthew-certified big brain
WIP
HMmm almost there I think
pretty great progressssssssss
ExecOptions isolateThreadBreaks
ThreadBreaksIsolationMode
move to GHCi.Run.Breakpoints
- - - - -
fd092d1b by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Refactor: we have the interactive Ids directly... clean up significantly
Removes things like
names <- map idName ids
map (\i -> let id = find (\x -> i==idName x) names) idso
and is more straightforward because there's less state going around (no
more updating HscEnv as an output)
It also kills `printTypeOfNames` completely, since now we just have the
Ids. No longer `lookupName` names to get back the ids...
```
printTypeOfName :: GHC.GhcMonad m => Name -> m ()
printTypeOfName n
= do maybe_tything <- GHC.lookupName n
case maybe_tything of
Nothing -> return ()
Just thing -> printTyThing thing
```
now is just `printTyThing . AnId`
Also:
```diff
- tythings <- catMaybes `liftM` mapM GHC.lookupName namesSorted
- docs <- mapM pprTypeAndContents [i | AnId i <- tythings]
+ docs <- mapM pprTypeAndContents idsSorted
```
(and yes, in ExecBreaks there are only Ids, no TyThings, bc they are
only constructed by the interpreter execution which can only bind ids.
for TyThings use runDecls which doesn't return execBreaks.)
I have a plan for the `resumes`, I'm getting there.
fixes
grrr
UNDO the removing-hsc-env-globality part of the clean up and keep just the good parts
fixes
- - - - -
30e63bc7 by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Make the ExecBreak contain a Resume
Put the resume in ExecBreak
- - - - -
6e080b8b by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Make resumeExec receive a Resume as an argument
- - - - -
f3ef734d by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Build EvalOpts once per exec rather than per breakpoint stop
in interpreter_steplocal the allocations increased because now we're
updating `eval_opts` after constructing them in `handleRunStatus` (which
is run many times since in step-local most often we don't stop, just
check).
So drop the update to the eval_opts, and, in fact, pull their
construction out. the loop always uses the same eval_opts, so no point
in constructing them inside from scratch every time.
-3.6% from this branch which had the regressions in
interpreter_steplocal
- - - - -
aac8c29c by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Look up a thread's ResumeContext without taking a lock
modifyMVar is unnecessarily expensive and blocking when most often we
just care about reading without modifying. optimize for default case
(thread context already exists). It is called every single time a
breakpoint is hit (regardless of whether we stop there, e.g. in
interpreter_steplocal we do not stop there often)
-3.3% improvement over original regression
- - - - -
42e3e95b by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Every thread resume-context keeps a var for its EvalStatus
Kill the global mapping from thread id to EvalStatus
Instead, keep the EvalStatus in the ResumeContext associated to a thread
in the threadContextVar (where entries are created on breakpoints being
hit and when writing an EvalComplete result)
Before, every breakpoint hit meant reading the global map TVar and
deleting a map entry which did a lot of allocations. Now, we have a
Nothing variable which we overwrite to "take" rather than deleting from
a Map and allocating the GlobalDbgMap too. Note that for every
breakpoint hit we'd have to insert the ThreadId entry in the map again
(because we deleted it last time we resumed), again allocating
unnecessarily. Now it's only a look up on the map and an update on the
variable directly.
And a LOT of breakpoints were hit on interpreter_steplocal, stress
testing the cost of hitting a breakpoint
The isolated threads move to their own top-level TVar Set.
-4.4% improvement over the regression
- - - - -
0e9d8b01 by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Move whether a thread is isolated to the same global map
Stops us from reconstructing the set every time this changed instead to
being a per thread variable just toggled on/off, by default non-isolated
like before (before it was Set.empty, Set.insert for True, Set.delete
for FALSE). This is more straightforward -- there's always an isolation
mode per thread and we can toggle it directly
reduces slightly allocations, but the main advantage is killing a second
global map and making it more uniform with just one thread map and no
membership check for toggledness.
- - - - -
c97217d0 by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Prefer foldl' in readAnyThreadEvalBreak txn
retry 'orElse' next is just next, so we might as well use a strict fold
- - - - -
adaf801f by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Add inline TODO about improving efficiency of readyAnyThreadBreak
It is currently O(N) in number of threads that have hit breakpoints
It should be number of *live* threads that have hit breaks, bc we still need to find a way to evacuate threads from the map
- - - - -
11a6c0cb by Rodrigo Mesquita at 2026-10-27T10:33:46+00:00
Set global breakpoint action in sandboxIO rather than withBreakAction
- - - - -
ae43af89 by Rodrigo Mesquita at 2026-10-27T10:33:47+00:00
TODO comment on breakOnException being global rather than per-thread
- - - - -
377809cb by Rodrigo Mesquita at 2026-10-27T10:33:47+00:00
fixmeup
- - - - -
1c0801f5 by Rodrigo Mesquita at 2026-10-27T10:34:08+00:00
WIP: Asynchronous eval/resume
- - - - -
9173debe by Rodrigo Mesquita at 2026-10-27T10:34:10+00:00
Fix commentary
- - - - -
1add71e6 by Rodrigo Mesquita at 2026-10-27T10:34:10+00:00
fix
- - - - -
10b933a8 by Rodrigo Mesquita at 2026-10-27T10:34:10+00:00
more fixes
- - - - -
d6957a49 by Rodrigo Mesquita at 2026-10-27T10:34:25+00:00
fixes api use, kill uninterruptible mask
- - - - -
ce28d80c by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
Kill redundant custom handler in GHCi.Server
- - - - -
fa310706 by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
Revert "Kill redundant custom handler in GHCi.Server"
This reverts commit a64e1dbdc9f7a5d46a33c3bbafa69ffa49aee1ec.
- - - - -
1b4812d9 by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
clean up some comments in GHCi.Signals
- - - - -
091cc0da by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
TSO_STOP_ON_EXCEPTION -- per-thread break-on-exception
- - - - -
22ae37c5 by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
Add redirectInterrupts again
- - - - -
4b02fa0e by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
unmask runIt only
- - - - -
f99eaaf8 by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
Revert "Add redirectInterrupts again"
This reverts commit 564c64781849dd3e681b68ae6b167779403118a6.
- - - - -
6c6486ea by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
Move cmmtn
- - - - -
518c3554 by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
internal interp: redirect interrupts on waits to the thread we're waiting for
- - - - -
0eec43cc by Rodrigo Mesquita at 2026-10-27T10:34:27+00:00
Do redirectInterrupts to ext interp too
- - - - -
8e4cea00 by Rodrigo Mesquita at 2026-10-27T10:34:41+00:00
get rid of installSignalHandlers and discardCtrlC and uninterruptibleMask
- - - - -
c81f4571 by Rodrigo Mesquita at 2026-10-27T10:34:41+00:00
fixes
- - - - -
aec7d6c1 by Rodrigo Mesquita at 2026-10-27T10:34:42+00:00
Manage thread status stopped vs running and allow many threads to read the same result off of a stoped thread
- - - - -
e5100d77 by Rodrigo Mesquita at 2026-10-27T10:34:42+00:00
abstracrt resumeStoppedThread
and use it in abandonStmt too.
- - - - -
6f99c52e by Rodrigo Mesquita at 2026-10-27T10:40:31+00:00
fix redirect todo on seq/resumeseq
- - - - -
35 changed files:
- compiler/GHC.hs
- compiler/GHC/Driver/Config.hs
- compiler/GHC/Runtime/Debugger.hs
- compiler/GHC/Runtime/Eval.hs
- compiler/GHC/Runtime/Eval/Types.hs
- compiler/GHC/Runtime/Heap/Inspect.hs
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/Runtime/Interpreter/Process.hs
- compiler/GHC/Tc/Gen/Splice.hs
- ghc/GHCi/UI.hs
- ghc/GHCi/UI/Monad.hs
- libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingDisabled.hsc
- libraries/ghc-heap/GHC/Exts/Heap/FFIClosures_ProfilingEnabled.hsc
- libraries/ghc-heap/tests/parse_tso_flags.hs
- libraries/ghc-internal/src/GHC/Internal/Heap/Closures.hs
- libraries/ghci/GHCi/Debugger.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Message/Async.hs
- libraries/ghci/GHCi/Run.hs
- + libraries/ghci/GHCi/Run/Breakpoints.hs
- libraries/ghci/GHCi/Server.hs
- libraries/ghci/GHCi/Server/Threads.hs
- libraries/ghci/GHCi/Signals.hs
- libraries/ghci/ghci.cabal.in
- rts/Exception.cmm
- rts/Interpreter.c
- rts/RtsSymbols.c
- rts/include/rts/Constants.h
- testsuite/tests/ghc-api/T8628.hs
- testsuite/tests/ghc-api/T8639_api.hs
- testsuite/tests/ghc-api/apirecomp001/myghc.hs
- testsuite/tests/ghci/should_run/Makefile
- testsuite/tests/ghci/should_run/T3171.stdout
- + testsuite/tests/ghci/should_run/T3171ext.stdout
- testsuite/tests/ghci/should_run/all.T
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4be7bc824442286f1c25394e23d73c…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4be7bc824442286f1c25394e23d73c…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/mangoiv/28038] Abort more eagerly when trying to bind type variables in Patbinds
by Magnus (@MangoIV) 27 Oct '26
by Magnus (@MangoIV) 27 Oct '26
27 Oct '26
Magnus pushed to branch wip/mangoiv/28038 at Glasgow Haskell Compiler / GHC
Commits:
ab20f8f8 by mangoiv at 2026-10-27T11:31:32+01:00
Abort more eagerly when trying to bind type variables in Patbinds
GHC currently does not allow to bind type variables in patterns. When
a user would try that, we didn't abort eagerly enough after discovering
the error and thus ran into a panic looking up the type in the env while
trying to update the local context. Instead, when discovering the error,
we now just failM as late as possible before lookin up the tv binds.
Fixes #28038
- - - - -
6 changed files:
- + changelog.d/28038
- compiler/GHC/Tc/Gen/Pat.hs
- + testsuite/tests/typecheck/should_fail/T28038.hs
- + testsuite/tests/typecheck/should_fail/T28038.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_PatternBindingExistential.stderr
- testsuite/tests/typecheck/should_fail/all.T
Changes:
=====================================
changelog.d/28038
=====================================
@@ -0,0 +1,12 @@
+section: compiler
+synopsis:
+ Fix a panic when trying to bind a type variable in patterns.
+description:
+ GHC currently does not allow to bind type variables in patterns. When
+ a user would try that, in some situations, we didn't abort eagerly
+ enough after discovering the error and thus ran into a panic looking up
+ the type in the env while trying to update the local context. Instead,
+ when discovering the error,
+ we now abort eagerly.
+mrs: !16868
+issues: #28038
=====================================
compiler/GHC/Tc/Gen/Pat.hs
=====================================
@@ -1900,11 +1900,6 @@ tcConTyArg :: Subst -> Checker (HsTyPat GhcRn, TyVar) ()
tcConTyArg tenv penv (rn_ty, con_tv) thing_inside
= do { (sig_wcs, sig_ibs, arg_ty) <- tcHsTyPat rn_ty (substTy tenv (varType con_tv))
- ; case NE.nonEmpty sig_ibs of
- Just sig_ibs_ne | inPatBind penv ->
- addErr (TcRnCannotBindTyVarsInPatBind sig_ibs_ne)
- _ -> pure ()
-
-- This unification is straight from Figure 7 of
-- "Type Variables in Patterns", Haskell'18
-- OK to drop coercions here. These unifications are all about
@@ -1912,6 +1907,12 @@ tcConTyArg tenv penv (rn_ty, con_tv) thing_inside
-- See Note [Type applications in patterns] (W1)
; _ <- unifyType Nothing arg_ty (substTyVar tenv con_tv)
+ ; case NE.nonEmpty sig_ibs of
+ Just sig_ibs_ne | inPatBind penv -> do
+ addErr (TcRnCannotBindTyVarsInPatBind sig_ibs_ne)
+ failM
+ _ -> pure ()
+
; result <- tcExtendNameTyVarEnv sig_wcs $
tcExtendNameTyVarEnv sig_ibs $
thing_inside
=====================================
testsuite/tests/typecheck/should_fail/T28038.hs
=====================================
@@ -0,0 +1,12 @@
+{-# LANGUAGE RequiredTypeArguments #-}
+module Main where
+
+data A where
+ A :: forall a -> A
+
+main :: IO ()
+main = do
+ let a = A Int
+ let A b = a
+ pure ()
+
=====================================
testsuite/tests/typecheck/should_fail/T28038.stderr
=====================================
@@ -0,0 +1,6 @@
+T28038.hs:10:7: error: [GHC-48361]
+ • Binding type variables is not allowed in pattern bindings
+ • In the pattern: A b
+ In a pattern binding: A b = a
+ In a stmt of a 'do' block: let A b = a
+
=====================================
testsuite/tests/typecheck/should_fail/TyAppPat_PatternBindingExistential.stderr
=====================================
@@ -3,18 +3,6 @@ TyAppPat_PatternBindingExistential.hs:10:1: error: [GHC-48361]
• In the pattern: Some @a x
In a pattern binding: Some @a x = Some (5 :: Integer)
-TyAppPat_PatternBindingExistential.hs:10:9: error: [GHC-25897]
- • Couldn't match expected type ‘p’ with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- a pattern with constructor: Some :: forall a. a -> Some,
- in a pattern binding
- at TyAppPat_PatternBindingExistential.hs:10:1-9
- ‘p’ is a rigid type variable bound by
- the inferred type of x :: p
- at TyAppPat_PatternBindingExistential.hs:10:1-31
- • In the pattern: Some @a x
- In a pattern binding: Some @a x = Some (5 :: Integer)
-
TyAppPat_PatternBindingExistential.hs:13:3: error: [GHC-39999]
• Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -768,3 +768,4 @@ test('T26532', normal, compile_fail, [''])
test('T27731', normal, compile_fail, [''])
test('T27844', normal, compile_fail, [''])
test('T26543a', normal, compile_fail, [''])
+test('T28038', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab20f8f872430cabd831b459df39ad7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab20f8f872430cabd831b459df39ad7…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/mangoiv/28038] Abort more eagerly when trying to bind type variables in Patbinds
by Magnus (@MangoIV) 27 Oct '26
by Magnus (@MangoIV) 27 Oct '26
27 Oct '26
Magnus pushed to branch wip/mangoiv/28038 at Glasgow Haskell Compiler / GHC
Commits:
ab20f8f8 by mangoiv at 2026-10-27T11:31:32+01:00
Abort more eagerly when trying to bind type variables in Patbinds
GHC currently does not allow to bind type variables in patterns. When
a user would try that, we didn't abort eagerly enough after discovering
the error and thus ran into a panic looking up the type in the env while
trying to update the local context. Instead, when discovering the error,
we now just failM as late as possible before lookin up the tv binds.
Fixes #28038
- - - - -
6 changed files:
- + changelog.d/28038
- compiler/GHC/Tc/Gen/Pat.hs
- + testsuite/tests/typecheck/should_fail/T28038.hs
- + testsuite/tests/typecheck/should_fail/T28038.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_PatternBindingExistential.stderr
- testsuite/tests/typecheck/should_fail/all.T
Changes:
=====================================
changelog.d/28038
=====================================
@@ -0,0 +1,12 @@
+section: compiler
+synopsis:
+ Fix a panic when trying to bind a type variable in patterns.
+description:
+ GHC currently does not allow to bind type variables in patterns. When
+ a user would try that, in some situations, we didn't abort eagerly
+ enough after discovering the error and thus ran into a panic looking up
+ the type in the env while trying to update the local context. Instead,
+ when discovering the error,
+ we now abort eagerly.
+mrs: !16868
+issues: #28038
=====================================
compiler/GHC/Tc/Gen/Pat.hs
=====================================
@@ -1900,11 +1900,6 @@ tcConTyArg :: Subst -> Checker (HsTyPat GhcRn, TyVar) ()
tcConTyArg tenv penv (rn_ty, con_tv) thing_inside
= do { (sig_wcs, sig_ibs, arg_ty) <- tcHsTyPat rn_ty (substTy tenv (varType con_tv))
- ; case NE.nonEmpty sig_ibs of
- Just sig_ibs_ne | inPatBind penv ->
- addErr (TcRnCannotBindTyVarsInPatBind sig_ibs_ne)
- _ -> pure ()
-
-- This unification is straight from Figure 7 of
-- "Type Variables in Patterns", Haskell'18
-- OK to drop coercions here. These unifications are all about
@@ -1912,6 +1907,12 @@ tcConTyArg tenv penv (rn_ty, con_tv) thing_inside
-- See Note [Type applications in patterns] (W1)
; _ <- unifyType Nothing arg_ty (substTyVar tenv con_tv)
+ ; case NE.nonEmpty sig_ibs of
+ Just sig_ibs_ne | inPatBind penv -> do
+ addErr (TcRnCannotBindTyVarsInPatBind sig_ibs_ne)
+ failM
+ _ -> pure ()
+
; result <- tcExtendNameTyVarEnv sig_wcs $
tcExtendNameTyVarEnv sig_ibs $
thing_inside
=====================================
testsuite/tests/typecheck/should_fail/T28038.hs
=====================================
@@ -0,0 +1,12 @@
+{-# LANGUAGE RequiredTypeArguments #-}
+module Main where
+
+data A where
+ A :: forall a -> A
+
+main :: IO ()
+main = do
+ let a = A Int
+ let A b = a
+ pure ()
+
=====================================
testsuite/tests/typecheck/should_fail/T28038.stderr
=====================================
@@ -0,0 +1,6 @@
+T28038.hs:10:7: error: [GHC-48361]
+ • Binding type variables is not allowed in pattern bindings
+ • In the pattern: A b
+ In a pattern binding: A b = a
+ In a stmt of a 'do' block: let A b = a
+
=====================================
testsuite/tests/typecheck/should_fail/TyAppPat_PatternBindingExistential.stderr
=====================================
@@ -3,18 +3,6 @@ TyAppPat_PatternBindingExistential.hs:10:1: error: [GHC-48361]
• In the pattern: Some @a x
In a pattern binding: Some @a x = Some (5 :: Integer)
-TyAppPat_PatternBindingExistential.hs:10:9: error: [GHC-25897]
- • Couldn't match expected type ‘p’ with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- a pattern with constructor: Some :: forall a. a -> Some,
- in a pattern binding
- at TyAppPat_PatternBindingExistential.hs:10:1-9
- ‘p’ is a rigid type variable bound by
- the inferred type of x :: p
- at TyAppPat_PatternBindingExistential.hs:10:1-31
- • In the pattern: Some @a x
- In a pattern binding: Some @a x = Some (5 :: Integer)
-
TyAppPat_PatternBindingExistential.hs:13:3: error: [GHC-39999]
• Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -768,3 +768,4 @@ test('T26532', normal, compile_fail, [''])
test('T27731', normal, compile_fail, [''])
test('T27844', normal, compile_fail, [''])
test('T26543a', normal, compile_fail, [''])
+test('T28038', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab20f8f872430cabd831b459df39ad7…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ab20f8f872430cabd831b459df39ad7…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/davide/io_manager_tests] 24 commits: add options for resizing bytearrays (#27244)
by Zubin (@wz1000) 27 Oct '26
by Zubin (@wz1000) 27 Oct '26
27 Oct '26
Zubin pushed to branch wip/davide/io_manager_tests at Glasgow Haskell Compiler / GHC
Commits:
13dff5d0 by L0neGamer at 2026-10-22T21:37:31-04:00
add options for resizing bytearrays (#27244)
add five mutable bytearray resizing operations
for various kinds of pinnedness and aligning.
- prefer unpinned when allocating new array (``resizeMutableByteArrayPreferUnpinned#``; the ``resizeMutableByteArray#`` default)
- prefer pinned when allocating new array (``resizeMutableByteArrayPreferPinned#``)
- prefer aligned and pinned when allocating new array (``resizeMutableByteArrayPreferAlignedPinned#``)
- prefer same as input bytearray when allocating new array (``resizeMutableByteArrayKeepPinnedness#``)
- ensure the output array is aligned and pinned after operation (``resizeMutableByteArrayMakeAlignedPinned#``)
- - - - -
0c17201c by Sylvain Henry at 2026-10-22T21:38:23-04:00
JS: implement performMinorGC and performBlockingMajorGC (#28012)
GHC.Internal.System.Mem imports three C entry points: performMajorGC,
performGC (for performMinorGC) and performBlockingMajorGC. The JS RTS
only defined h$performMajorGC, so calling performMinorGC or
performBlockingMajorGC threw "ReferenceError: h$performGC is not
defined" at runtime.
The JS RTS has a single non-generational collector, so both missing
entry points are now aliases of h$performMajorGC.
Add a test that calls every GC entry point of System.Mem.
Co-Authored-By: Claude Fable 5.1 <noreply(a)anthropic.com>
- - - - -
7a631ff2 by L0neGamer at 2026-10-23T09:11:39-04:00
Mon(a|oi)d of No (Return|Mappend) progress (!15795)
Make non-canonical definitions of return and mappend
non-suppressible errors, and make canonical definitions
of those methods warnings.
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/328
- - - - -
14656fd4 by Simon Jakobi at 2026-10-23T09:12:27-04:00
Cmm: keep the CBE substitution idempotent
When blocks are merged over multiple rounds during common block
elimination, a block that won a merge in an earlier round can still
lose a merge in a later round. The substitution map (Subst) used to
record this as a chain: the earlier loser mapped to a block that was
itself eliminated. In PLT terminology, the substitution became
*non-idempotent*. Applying such a substitution with a single lookup
left edges to unreachable blocks in the Cmm graph, eventually leading
to a setInfoTableStackMap panic (#27368).
With this patch, each round's fresh substitutions are applied to the old
ones as they are added (extendSubst), so every eliminated block maps
directly to its final replacement and the substitution stays idempotent.
Fixes #27368.
Assisted-by: Claude Fable 5.1
- - - - -
92848e61 by Evgeny Malyshev at 2026-10-23T20:26:04-04:00
hadrian: Include transitive dependencies in Haddock builds
Haddock needs indirect dependency interfaces to resolve references to
definitions outside a package's direct dependencies. Expose Cabal's
configured dependency closure through ContextData and use it alongside
the direct list, preserving direct-interface precedence.
Bump Shake's cache version for the serialized oracle change. Add a
Hadrian selftest requiring template-haskell's indirect ghc-prim interface.
Fixes #25850.
Fixes #27786.
Assisted-By: OpenAI Codex
Metric Increase:
haddock.Cabal
- - - - -
5e8ae81b by Zubin Duggal at 2026-10-23T20:26:47-04:00
WinIO: Don't confuse Win32 errors and NTSTATUS codes
WinIO misinterpreted NTSTATUS codes as Win32 errors, and had some ad hoc logic to deal with this.
However, this logic was incomplete and resulted in the mishandling of results of certain I/O operations
(see testcase).
Now the `ErrCode` argument in `CompletionCallback` is always the Win32 error code,
and we convert the NTSTATUS using RtlNtStatusToDosError.
Also when an overlapped/async operation such as ReadFile fails immediately,
with a Win32 error such as ERROR_BROKEN_PIPE, we don't get a further completion
notification, so we never recorded the failure. This worked by coincidence
earlier, because `STATUS_PENDING` happened to have the same numerical code as
`ERROR_NO_MORE_ITEMS`, but it doesn't now that we translate `STATUS_PENDING`
into the correct Win32 error code (`ERROR_IO_PENDING`). Fix this by using
the Win32 error value we obtained when an operation returns `STATUS_PENDING`.
Fixes #27971
- - - - -
c42ed66a by Martijn Bastiaan at 2026-10-24T16:00:42+02:00
Add single-threaded test for #27526 + #27123
Issue #27526 is a duplicate of #27123, which has already been fixed in
HEAD. The proposed patch in the former carries a "nicer" regression test
in that it doesn't rely on multi-threading to trigger.
Closes #27526
- - - - -
7f73f515 by Simon Peyton Jones at 2026-10-24T17:29:19-04:00
Refactor QuickLook a bit
This MR simply refactors QuickLook a bit. In particular, it
simplifies `tcApp`, and moves shared code into `finishApp`.
It also adds `Note [QuickLook: arguments before result]`
responding to #26599.
There should be no user-visible changes, except perhaps in error messages,
which improve marginally.
For some reason T24984 compiles 8% faster. I'll take the win!
Metric Decrease:
T24984
- - - - -
a4a3a964 by Alan Zimmerman at 2026-10-24T17:30:03-04:00
EPA: Use AnnList for XClosedTypeFamily
We now have TTG annotations for FamilyInfo.
Make use of it to store the AnnList annotations for a closed type
family.
- - - - -
953e4c7f by sheaf at 2026-10-26T18:19:10-04:00
Rework LogQueue to be a proper queue
Now 'LogQueue' uses a 'TQueue' with a separate 'TVar' to indicate
whether the log queue is finished logging, instead of the previous weird
data representation using a reverse-order '[Maybe Msg]' with 'Nothing'
denoting the end of the queue.
- - - - -
ec29c5fa by Rodrigo Mesquita at 2026-10-26T18:19:10-04:00
Refactor GHC.Driver.MakeAction
Pull out of 'runParPipelines' the logic for creating a 'MakeEnv' ready
to be used by multiple threads, as that will be useful for downsweep as
well (which doesn't fit the 'runPipelines' flow), rather than being just
for upsweep.
The code is moved and re-structured to match the export list, simplify
the sequentiality checks previously both in 'runPipelines' and
'runAllPipelines', which were weirdly similar and confusing; into the
two part step where we need these checks: (1) to construct the MakeEnv,
(2) to run the MakeActions in parallel. These two steps are separate and
used to be too mixed up.
Some additional little simplifications or clean ups here and there.
- - - - -
3fb22073 by Rodrigo Mesquita at 2026-10-26T18:19:11-04:00
Refactor GHC.Driver.Downsweep in preparation for parallel downsweep
Pure refactor to improve the code to facilitate implementing parallel
downsweep in the next commit.
This commit puts a MakeEnv into the DownsweepEnv, gives the fields
proper names and uses RecordWildcards to simplify, rather than passing
around all diagnostic wrappers, driver-message-things and using 10s of
positional fields.
No behavior changes here!
- - - - -
52f385a7 by sheaf at 2026-10-26T18:19:11-04:00
Driver: enableCodeGenForTH in load', not downsweep
enableCodeGenForTH modifies the module graph for planning, creating
fresh temporary paths. So it should only be run when we are about to
execute a build plan (e.g. in load'), so that consumers that want to
know facts about the module graph don't go looking for files that don't
exist yet (in particular 'haddock --no-compilation').
- - - - -
82402d14 by sheaf at 2026-10-26T18:19:11-04:00
2-phase Cache/Search Finder monad
This commit restructures the finder abstraction by introducing the
'FinderM' monad, which splits module lookup operations into two phases:
- a cache-only phase, performing no filesystem access,
- from the first cache miss onwards, a search action which may access
the filesystem.
This allows consumers to distinguish between quick cached results versus
more expensive filesystem search operations.
- - - - -
5c302b40 by sheaf at 2026-10-26T18:19:11-04:00
Separate Home/External finder caches
The caches for home modules and modules from external units have
different lifetimes, needing to be invalidated at different points.
This commit moves the cache for modules from external units into the
'UnitState' type, which keeps the cache correct whenever package flags
or package databases change (setSessionDynFlags, :set -package ...,
Backpack's addUnit).
This also makes it easier to clear the cache of home modules, as they
are now stored separately (obviating the 'isUnitEnvInstalledModule'
check we used to perform).
- - - - -
605fbb96 by sheaf at 2026-10-26T18:19:11-04:00
Add known home modules to the finder cache
The finder looks in the file system for the on-disk source that
corresponds to a Haskell module name. There are two kinds of modules
where we need to bypass this search:
- a file passed directly in the command line, which may not be in any
search path and whose module name may differ from the file name;
- Backpack signatures and modules, which do not exist as files at all.
This commit handles these two situations by adding an immutable
'KnownHomeModules' in the finder cache, which is always consulted first
before doing any search.
This removes the ad-hoc imperative logic which relied on mutating the
finder cache at careful points.
'setModuleGraph' now also takes the known home modules, so that the
module graph and the known home modules are always set consistently.
See Note [Known home modules] in GHC.Unit.Finder.Types.
- - - - -
82718f44 by sheaf at 2026-10-26T18:19:11-04:00
Make 'UnresolvedImport' into a suitable cache key
The goal of this commit is to make 'UnresolvedImport' suitable for use
as a cache key. Specifically, during downsweep we want to be able to
cache module resolution queries. We want to do this using some kind of
map, e.g. (roughly speaking):
Map UnresolvedImport ResolvedImport
For this to work, 'UnresolvedImport' must contain **precisely** the
input data to each resolution computation. In other words:
1. If something changes that materially affects resolution, it must
be stored in the cache key.
2. If changing some input does not materially affect the outcome,
then it must not be stored in the cache key.
To satisfy (1), we change 'UnitNode' to also keep track of the home
unit in whose unit state the unit's dependencies were looked up.
For (2), 'ImportResolution' now stores a 'ModuleLookupScope' instead of an
'UnresolvedImportOrigin'. Plugin imports are expressed with a new
'LookupPlugin' scope. The source location of an import, which is
immaterial to the resolution, is stored out of band outside
'UnresolvedImport', in 'ModSummary'.
- - - - -
d4635c7c by sheaf at 2026-10-26T18:19:11-04:00
Add GHC.Data.Dependent
This commit adds a minimal implementation of dependent sums
('Some', 'DSum') and dependent maps ('DMap').
The implementation is not entirely performance optimal, as there are a
few extraneous allocations compared to the full-blown implementation in
the 'dependent-map' package. For our use case (caching downsweep
computations), this does not matter much.
See GHC.Data.Dependent.
- - - - -
6759533e by sheaf at 2026-10-26T18:19:11-04:00
Driver: structured concurrent worker abstraction
This commit introduces a structured concurrency framework in the style
of the 'ki' library: a collection of threads within a scope.
We implement two kinds of concurrent workers on top of this framework:
- Independent workers cannot wait for one another at all. The only
scheduling operation is to wait for quiescence.
- Coordinating workers declare an STM readiness condition (waiting on
other workers to complete) which gates their start.
See Note [Deterministic concurrent workers] in GHC.Driver.Concurrency.
This commit ports upsweep to this new framework, with downsweep being
left as subsequent work.
Further changes along the way:
- Refactoring of how concurrency is acquired to avoid the footgun of
trying to use a no-op 'AbstractSem' as a lock in the serial case.
- The "re-run with -j1" logic for semaphore opening errors no longer
triggers on late semaphore failures (part-way through a lengthy
computation).
- Logger threads are properly cleaned up on exception, with each
concurrent worker's log queue and local TmpFs properly bracketed.
- The 'GhcMessage -> AnyGhcDiagnostic' and 'Maybe Messager'
arguments of 'depanalE', 'depanalPartial' and 'downsweep', which
were all dead in practice, have been dropped.
- Concurrent logging has been completely overhauled. Each worker has
its own log queue. Workers whose logs are printed as we go are
spawned in the order in which their logs must be printed, now using
a TQueue instead of the old complicated LogQueueQueue mechanism.
'logThread' is replaced by 'withLogPrinter', which runs the thread
that prints the log queues within a concurrent worker scope.
These changes allow us to fix issues with the exception handling:
we now always flush remaining log queues before exiting (even when
the action throws an exception), and exceptions that arise while
printing are properly rethrown. This fixes #28009.
- - - - -
38a99006 by sheaf at 2026-10-26T18:19:11-04:00
Rule-based deterministic concurrent downsweep
This commit rewrites downsweep as a single query-answering rule
(see 'DownsweepRule') that can be executed by concurrent worker threads.
The design allows every expensive operation (preprocessing files with CPP,
parsing headers, reading interfaces) to be performed concurrently
according to the -j<N>/-jsem flags.
See Note [Rules-based downsweep] in GHC.Driver.Downsweep.
The rules are run by "GHC.Driver.Concurrency.runRules" in a demand-driven
way: each worker can demand other workers to run, but never wait on
another worker. Every piece of work is done at most once.
Fixes #27514
Memory usage can increase due to doing more work concurrently:
-------------------------
Metric Increase:
MultiComponentModulesRecomp
MultiComponentModulesRecomp100
mhu-perf
-------------------------
- - - - -
9fa7b7be by sheaf at 2026-10-26T18:19:11-04:00
Acquire/release semaphore tokens more readily
This commit reworks GHC.Driver.MakeSem to use the scoped worker
abstraction of GHC.Utils.Concurrent.Scope. This allows us to get rid of
a lot of the tricky logic in GHC.Driver.MakeSem involving manual
exception handling, thread spawning and lifetime management, etc.
The main user-visible change is that token acquisition is no longer
rate limited (due to a bug, there previously was a 1s rate limit on
acquisition of semaphore tokens), with the release debounce period
shortened from 1s to 10ms.
Other changes:
- With -jsem, the number of capabilities is now capped at the number
of processors, bringing it in line with the -jN behaviour.
- Pending jobs whose wait for a token is interrupted by an exception
are now withdrawn from the jobserver, instead of acquiring a token
that it hung onto without doing useful work.
Fixes #27763
- - - - -
c83c6733 by Alan Zimmerman at 2026-10-26T18:19:55-04:00
EPA: Update AnnClsInstDecl to contain AnnList
It was already separately tracking the '{', '}' and leading ';' values.
This aligns it with layout-introducing parser productions ('vocurly'),
so the layout processing can be handled uniformly
- - - - -
452c765b by David Eichmann at 2026-10-27T15:51:43+05:30
testsuite: Fix python type errors
These errors appear when using the VSCode python extension which uses
Pylance under the hood.
- - - - -
994a3f61 by David Eichmann at 2026-10-27T15:51:43+05:30
Add test modifier to test over all IO Managers
- - - - -
221 changed files:
- + changelog.d/25850
- + changelog.d/27368
- + changelog.d/27971
- + changelog.d/28012
- + changelog.d/T27763
- + changelog.d/monad-of-no-return-canonical
- + changelog.d/parallel-downsweep
- + changelog.d/resizeMutableByteArray-pinnedness
- compiler/GHC.hs
- compiler/GHC/Builtin.hs
- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/ByteCode/Asm.hs
- compiler/GHC/Cmm/CommonBlockElim.hs
- compiler/GHC/CmmToAsm/CFG/Dominators.hs
- compiler/GHC/CmmToLlvm/CodeGen.hs
- + compiler/GHC/Data/Dependent.hs
- compiler/GHC/Data/FastString.hs
- compiler/GHC/Data/OrdList.hs
- compiler/GHC/Data/Pair.hs
- compiler/GHC/Data/Word64Map/Internal.hs
- compiler/GHC/Data/Word64Set/Internal.hs
- compiler/GHC/Driver/Backpack.hs
- compiler/GHC/Driver/CmdLine.hs
- + compiler/GHC/Driver/Concurrency.hs
- + compiler/GHC/Driver/Config/Concurrency.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/Env.hs
- compiler/GHC/Driver/Errors/Ppr.hs
- compiler/GHC/Driver/Errors/Types.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/MakeAction.hs
- compiler/GHC/Driver/MakeFile.hs
- compiler/GHC/Driver/MakeSem.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Pipeline/LogQueue.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/HsToCore/Pmc/Types.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Iface/Type.hs
- compiler/GHC/JS/Opt/Simple.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Header.hs
- compiler/GHC/Rename/Env.hs
- compiler/GHC/Rename/Module.hs
- compiler/GHC/Runtime/Interpreter/JS.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- compiler/GHC/StgToJS/Prim.hs
- compiler/GHC/Tc/Deriv/Generate.hs
- compiler/GHC/Tc/Errors/Ppr.hs
- compiler/GHC/Tc/Errors/Types.hs
- compiler/GHC/Tc/Gen/App.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Plugin.hs
- compiler/GHC/Tc/Solver/Monad.hs
- compiler/GHC/Tc/Types/Constraint.hs
- compiler/GHC/Tc/Utils/Backpack.hs
- compiler/GHC/Tc/Utils/TcMType.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/Basic.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/Hint.hs
- compiler/GHC/Types/Hint/Ppr.hs
- compiler/GHC/Types/Unique/FM.hs
- compiler/GHC/Types/Unique/Map.hs
- compiler/GHC/Types/UnresolvedImport.hs
- compiler/GHC/Unit/External/ModuleOrigin.hs
- compiler/GHC/Unit/External/Visibility.hs
- compiler/GHC/Unit/Finder.hs
- + compiler/GHC/Unit/Finder/Cache.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/Module/Graph.hs
- compiler/GHC/Unit/Module/ModSummary.hs
- compiler/GHC/Unit/Module/WholeCoreBindings.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Unit/Types.hs
- + compiler/GHC/Utils/Concurrent/Scope.hs
- compiler/GHC/Utils/Monad/Codensity.hs
- compiler/GHC/Utils/Ppr/Colour.hs
- compiler/GHC/Utils/TmpFs.hs
- compiler/ghc.cabal.in
- docs/users_guide/using-warnings.rst
- ghc/GHCi/UI.hs
- ghc/Main.hs
- ghc/ghc-bin.cabal.in
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Hadrian/Haskell/Cabal/Type.hs
- hadrian/src/Main.hs
- hadrian/src/Rules/Documentation.hs
- hadrian/src/Rules/Selftest.hs
- hadrian/src/Settings/Warnings.hs
- libraries/base/src/GHC/Base.hs
- libraries/base/src/GHC/Exts.hs
- + libraries/base/tests/IO/T27971.hs
- + libraries/base/tests/IO/T27971.stdout
- libraries/base/tests/IO/all.T
- libraries/ghc-internal/ghc-internal.cabal.in
- libraries/ghc-internal/src/GHC/Internal/Base.hs
- libraries/ghc-internal/src/GHC/Internal/Event/Windows.hsc
- libraries/ghc-internal/src/GHC/Internal/Event/Windows/FFI.hsc
- libraries/ghc-internal/src/GHC/Internal/IO/Windows/Handle.hsc
- linters/lint-codes/LintCodes/Static.hs
- rts/PrimOps.cmm
- rts/RtsSymbols.c
- rts/RtsUtils.c
- rts/include/stg/MiscClosures.h
- rts/js/environment.js
- testsuite/config/ghc
- testsuite/driver/runtests.py
- testsuite/driver/testglobals.py
- testsuite/driver/testlib.py
- testsuite/driver/testutil.py
- testsuite/tests/ado/ado-optimal.hs
- testsuite/tests/ado/ado001.hs
- + testsuite/tests/codeGen/should_compile/T27368.hs
- testsuite/tests/codeGen/should_compile/all.T
- testsuite/tests/concurrent/T13615/Parallel.hs
- testsuite/tests/concurrent/should_run/T21651.hs
- testsuite/tests/concurrent/should_run/setnumcapabilities001.hs
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/cpranal/should_run/T20598a.hs
- testsuite/tests/deriving/should_compile/T13758.hs
- testsuite/tests/deriving/should_run/all.T
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.hs
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.stderr
- + testsuite/tests/deriving/should_run/drvrun-canonical-methods.stdout
- testsuite/tests/determinism/determ017/A.hs
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/dmdanal/should_compile/T9208.hs
- testsuite/tests/driver/Makefile
- testsuite/tests/driver/T27461/Makefile
- + testsuite/tests/driver/T27461/T27461c.stderr
- testsuite/tests/driver/T27461/all.T
- + testsuite/tests/driver/T27461/src/Wrong.hs
- + testsuite/tests/driver/T28009.hs
- testsuite/tests/driver/all.T
- testsuite/tests/generics/T27245.hs
- testsuite/tests/generics/T27245.stdout
- testsuite/tests/ghc-api/downsweep/IncrementalDownsweep.hs
- testsuite/tests/ghc-api/downsweep/OldModLocation.hs
- testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs
- testsuite/tests/ghc-api/fixed-nodes/FixedNodes.hs
- testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.hs
- testsuite/tests/ghc-api/fixed-nodes/ModuleGraphInvariants.hs
- testsuite/tests/ghci.debugger/scripts/T14628.stderr
- testsuite/tests/haddock/perf/Fold.hs
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/hiefile/should_compile/hie002.hs
- testsuite/tests/hpc/raytrace/Eval.hs
- testsuite/tests/indexed-types/should_compile/T3787.hs
- testsuite/tests/indexed-types/should_fail/T7729.hs
- testsuite/tests/indexed-types/should_fail/T7729a.hs
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
- testsuite/tests/interface-stability/ghc-prim-exports.stdout
- testsuite/tests/interface-stability/ghc-prim-exports.stdout-mingw32
- testsuite/tests/module/mod133.hs
- testsuite/tests/parser/should_compile/DumpParsedAst.stderr
- testsuite/tests/parser/should_compile/DumpRenamedAst.stderr
- testsuite/tests/parser/should_compile/KindSigs.stderr
- testsuite/tests/perf/compiler/T13253.hs
- testsuite/tests/perf/compiler/T14683.hs
- testsuite/tests/perf/compiler/T16473.hs
- testsuite/tests/perf/compiler/T18730_A.hs
- testsuite/tests/perf/compiler/T25723.hs
- testsuite/tests/plugins/defaulting-plugin/DefaultLifted.hs
- testsuite/tests/pmcheck/should_compile/T11276.hs
- + testsuite/tests/primops/should_run/ResizeByteArrayPinnedness.hs
- + testsuite/tests/primops/should_run/ResizeByteArrayPinnedness.stdout
- testsuite/tests/primops/should_run/all.T
- testsuite/tests/printer/Test24533.stdout
- testsuite/tests/profiling/should_compile/T19894/StreamK.hs
- testsuite/tests/profiling/should_run/T3001-2.hs
- testsuite/tests/programs/galois_raytrace/Eval.hs
- testsuite/tests/rebindable/rebindable2.hs
- + testsuite/tests/rename/should_fail/Noncanonical.hs
- + testsuite/tests/rename/should_fail/Noncanonical.stderr
- testsuite/tests/rename/should_fail/all.T
- testsuite/tests/rename/should_fail/rnfail026.hs
- + testsuite/tests/rts/T27526.hs
- + testsuite/tests/rts/T27526.stdout
- + testsuite/tests/rts/T28012.hs
- + testsuite/tests/rts/T28012.stdout
- testsuite/tests/rts/all.T
- testsuite/tests/rts/ipe/IpeStats/Fold.hs
- testsuite/tests/simplCore/should_compile/T14908_Deps.hs
- testsuite/tests/simplCore/should_compile/simpl017.hs
- testsuite/tests/splice-imports/SI35.hs
- testsuite/tests/typecheck/should_compile/DeepSubsumption02.hs
- testsuite/tests/typecheck/should_compile/T4524.hs
- testsuite/tests/typecheck/should_compile/T4969.hs
- testsuite/tests/typecheck/should_fail/T22707.hs
- testsuite/tests/typecheck/should_fail/T22707.stderr
- testsuite/tests/typecheck/should_fail/T25950.stderr
- testsuite/tests/typecheck/should_fail/T7019.hs
- testsuite/tests/typecheck/should_fail/T8450.stderr
- testsuite/tests/typecheck/should_fail/T8603.hs
- + testsuite/tests/warnings/should_compile/RedundantCanonicalMethods.hs
- + testsuite/tests/warnings/should_compile/RedundantCanonicalMethods.stderr
- testsuite/tests/warnings/should_compile/WarnNoncanonical.hs
- testsuite/tests/warnings/should_compile/WarnNoncanonical.stderr
- testsuite/tests/warnings/should_compile/all.T
- utils/check-exact/ExactPrint.hs
- utils/check-ppr/Main.hs
- utils/haddock/haddock-api/haddock-api.cabal
- utils/haddock/haddock-api/src/Haddock/Convert.hs
- utils/haddock/haddock-api/src/Haddock/Interface.hs
- utils/haddock/haddock-api/src/Haddock/Interface/ParseModuleHeader.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
- utils/haddock/haddock-api/src/Haddock/Utils/Json.hs
- utils/haddock/haddock-library/haddock-library.cabal
- utils/haddock/haddock.cabal
- utils/runghc/Main.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6fe4ea9ff143ae0826864f09887916…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/6fe4ea9ff143ae0826864f09887916…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/mangoiv/28038] Abort more eagerly when trying to bind type variables in Patbinds
by Magnus (@MangoIV) 27 Oct '26
by Magnus (@MangoIV) 27 Oct '26
27 Oct '26
Magnus pushed to branch wip/mangoiv/28038 at Glasgow Haskell Compiler / GHC
Commits:
9de857b8 by mangoiv at 2026-10-27T10:37:05+01:00
Abort more eagerly when trying to bind type variables in Patbinds
GHC currently does not allow to bind type variables in patterns. When
a user would try that, we didn't abort eagerly enough after discovering
the error and thus ran into a panic looking up the type in the env while
trying to update the local context. Instead, when discovering the error,
we now just failM as late as possible before lookin up the tv binds.
Fixes #28038
- - - - -
5 changed files:
- compiler/GHC/Tc/Gen/Pat.hs
- + testsuite/tests/typecheck/should_fail/T28038.hs
- + testsuite/tests/typecheck/should_fail/T28038.stderr
- testsuite/tests/typecheck/should_fail/TyAppPat_PatternBindingExistential.stderr
- testsuite/tests/typecheck/should_fail/all.T
Changes:
=====================================
compiler/GHC/Tc/Gen/Pat.hs
=====================================
@@ -1900,11 +1900,6 @@ tcConTyArg :: Subst -> Checker (HsTyPat GhcRn, TyVar) ()
tcConTyArg tenv penv (rn_ty, con_tv) thing_inside
= do { (sig_wcs, sig_ibs, arg_ty) <- tcHsTyPat rn_ty (substTy tenv (varType con_tv))
- ; case NE.nonEmpty sig_ibs of
- Just sig_ibs_ne | inPatBind penv ->
- addErr (TcRnCannotBindTyVarsInPatBind sig_ibs_ne)
- _ -> pure ()
-
-- This unification is straight from Figure 7 of
-- "Type Variables in Patterns", Haskell'18
-- OK to drop coercions here. These unifications are all about
@@ -1912,6 +1907,12 @@ tcConTyArg tenv penv (rn_ty, con_tv) thing_inside
-- See Note [Type applications in patterns] (W1)
; _ <- unifyType Nothing arg_ty (substTyVar tenv con_tv)
+ ; case NE.nonEmpty sig_ibs of
+ Just sig_ibs_ne | inPatBind penv -> do
+ addErr (TcRnCannotBindTyVarsInPatBind sig_ibs_ne)
+ failM
+ _ -> pure ()
+
; result <- tcExtendNameTyVarEnv sig_wcs $
tcExtendNameTyVarEnv sig_ibs $
thing_inside
=====================================
testsuite/tests/typecheck/should_fail/T28038.hs
=====================================
@@ -0,0 +1,12 @@
+{-# LANGUAGE RequiredTypeArguments #-}
+module Main where
+
+data A where
+ A :: forall a -> A
+
+main :: IO ()
+main = do
+ let a = A Int
+ let A b = a
+ pure ()
+
=====================================
testsuite/tests/typecheck/should_fail/T28038.stderr
=====================================
@@ -0,0 +1,6 @@
+T28038.hs:10:7: error: [GHC-48361]
+ • Binding type variables is not allowed in pattern bindings
+ • In the pattern: A b
+ In a pattern binding: A b = a
+ In a stmt of a 'do' block: let A b = a
+
=====================================
testsuite/tests/typecheck/should_fail/TyAppPat_PatternBindingExistential.stderr
=====================================
@@ -3,18 +3,6 @@ TyAppPat_PatternBindingExistential.hs:10:1: error: [GHC-48361]
• In the pattern: Some @a x
In a pattern binding: Some @a x = Some (5 :: Integer)
-TyAppPat_PatternBindingExistential.hs:10:9: error: [GHC-25897]
- • Couldn't match expected type ‘p’ with actual type ‘a’
- ‘a’ is a rigid type variable bound by
- a pattern with constructor: Some :: forall a. a -> Some,
- in a pattern binding
- at TyAppPat_PatternBindingExistential.hs:10:1-9
- ‘p’ is a rigid type variable bound by
- the inferred type of x :: p
- at TyAppPat_PatternBindingExistential.hs:10:1-31
- • In the pattern: Some @a x
- In a pattern binding: Some @a x = Some (5 :: Integer)
-
TyAppPat_PatternBindingExistential.hs:13:3: error: [GHC-39999]
• Ambiguous type variable ‘a0’ arising from a use of ‘print’
prevents the constraint ‘(Show a0)’ from being solved.
=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -768,3 +768,4 @@ test('T26532', normal, compile_fail, [''])
test('T27731', normal, compile_fail, [''])
test('T27844', normal, compile_fail, [''])
test('T26543a', normal, compile_fail, [''])
+test('T28038', normal, compile_fail, [''])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9de857b80a3c57378d667d3978ca0db…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/9de857b80a3c57378d667d3978ca0db…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/romes/async-rpc] 5 commits: interp: more uninterruptibleMask_ removed
by Andrea Vezzosi (@trac-Saizan) 27 Oct '26
by Andrea Vezzosi (@trac-Saizan) 27 Oct '26
27 Oct '26
Andrea Vezzosi pushed to branch wip/romes/async-rpc at Glasgow Haskell Compiler / GHC
Commits:
05f68d0e by Andrea Vezzosi at 2026-10-26T18:21:34+01:00
interp: more uninterruptibleMask_ removed
- - - - -
7e21b3f8 by Andrea Vezzosi at 2026-10-26T23:42:27+01:00
interp: do not terminate ext. interp. process on exception
`sendMessage` throwing an exception does not warrant terminating the external
interpreter process anymore, because communication can keep going no matter what.
`stopInterp` now resets the whole `Interp` state, so that a new
ExtInterpInstance can be later created and work correctly.
- - - - -
1c9fe4ea by Andrea Vezzosi at 2026-10-27T08:54:09+01:00
fixup! interp: spawn fillPipe thread, writePipe now safely interruptible
- - - - -
8dbf2fd4 by Andrea Vezzosi at 2026-10-27T08:58:54+01:00
interp: withExtInterp calls stopInterp on PipeClosedException
- - - - -
5be020df by Andrea Vezzosi at 2026-10-27T09:05:16+01:00
fixup! interp: cancel requests if async exceptions while waiting for reply.
- - - - -
6 changed files:
- compiler/GHC/Runtime/Interpreter.hs
- compiler/GHC/Runtime/Interpreter/Process.hs
- compiler/GHC/Tc/Gen/Splice.hs
- libraries/ghci/GHCi/Message.hs
- libraries/ghci/GHCi/Message/Async.hs
- libraries/ghci/GHCi/Server.hs
Changes:
=====================================
compiler/GHC/Runtime/Interpreter.hs
=====================================
@@ -105,7 +105,7 @@ import GHCi.Run
import Control.Concurrent
import Control.Monad
import Control.Monad.IO.Class
-import Control.Monad.Catch as MC (mask)
+import Control.Monad.Catch as MC (mask, handle, MonadThrow (..))
import Data.Binary
import Data.ByteString (ByteString)
import qualified Data.ByteString.Short as SBS
@@ -196,14 +196,16 @@ interpCmd interp msg = case interpInstance interp of
#if defined(HAVE_INTERNAL_INTERPRETER)
InternalInterp -> run msg -- Just run it directly
#endif
- ExternalInterp ext -> withExtInterp ext $ \inst ->
+ ExternalInterp ext -> withExtInterp interp ext $ \inst ->
sendMessage inst msg
-withExtInterp :: ExceptionMonad m => ExtInterp -> (forall d. ExtInterpInstance d -> m a) -> m a
-withExtInterp ext action = case ext of
+withExtInterp :: ExceptionMonad m => Interp -> ExtInterp -> (forall d. ExtInterpInstance d -> m a) -> m a
+withExtInterp interp ext action = stopInterpOnPipeClosed $ case ext of
ExtJS i -> withJSInterp i action
ExtWasm i -> withWasmInterp i action
ExtIServ i -> withIServ i action
+ where
+ stopInterpOnPipeClosed = MC.handle $ \ (e :: PipeClosedException) -> liftIO (stopInterp interp) >> MC.throwM e
withExtInterpStatus :: ExtInterp -> (forall d. ExtInterpStatusVar d -> m a) -> m a
withExtInterpStatus ext action = case ext of
@@ -469,11 +471,9 @@ lookupSymbol interp str = withSymbolCache interp str $
#endif
ExternalInterp ext -> case ext of
ExtIServ i -> withIServ i $ \inst -> do
- uninterruptibleMask_ $
sendMessage inst (LookupSymbol (fastStringToShortByteString (interpSymbolToCLabel str)))
ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str)
ExtWasm i -> withWasmInterp i $ \inst -> do
- uninterruptibleMask_ $
sendMessage inst (LookupSymbol (fastStringToShortByteString (interpSymbolToCLabel str)))
lookupSymbolInDLL :: Interp -> RemotePtr LoadedDLL -> InterpSymbol s -> IO (Maybe (RemotePtr ()))
@@ -484,7 +484,6 @@ lookupSymbolInDLL interp dll str = withSymbolCache interp str $
#endif
ExternalInterp ext -> case ext of
ExtIServ i -> withIServ i $ \inst -> do
- uninterruptibleMask_ $
sendMessage inst (LookupSymbolInDLL dll (fastStringToShortByteString (interpSymbolToCLabel str)))
ExtJS {} -> pprPanic "lookupSymbol not supported by the JS interpreter" (ppr str)
-- wasm dyld doesn't track which symbol comes from which .so
@@ -645,6 +644,9 @@ stopInterp interp = case interpInstance interp of
else sendMessage i Shutdown
-- We asked the server to shutdown, so we will also shutdown any communication.
closePipe (interpPipe (instProcess i))
+ modifyMVar_ (loader_state (interpLoader interp)) (const $ pure Nothing)
+ purgeInterpSymbolCache (interpSymbolCache interp)
+ modifyMVar_ (interpStringCache interp) (const $ pure emptyFsEnv)
pure InterpPending
-- -----------------------------------------------------------------------------
=====================================
compiler/GHC/Runtime/Interpreter/Process.hs
=====================================
@@ -12,13 +12,10 @@ import GHC.Prelude
import GHC.Runtime.Interpreter.Types
import GHCi.Message
-import GHC.IO (catchException)
import GHC.Utils.Panic
import GHC.Utils.Exception as Ex
import Data.Binary
-import System.Exit
-import System.Process
import Control.Concurrent
import Data.IORef
import Control.Concurrent.STM
@@ -34,7 +31,6 @@ import Control.Concurrent.STM
sendMessage :: Binary a => ExtInterpInstance d -> Message a -> IO a
sendMessage i msg =
remoteCall (interpPipe proc) msg
- `catchException` \(e :: SomeException) -> handleInterpProcessFailure proc e
where
proc = instProcess i
@@ -77,18 +73,6 @@ sendTHComputation i msg reqHandler = mask $ \restore -> do
else loop
in loop
-handleInterpProcessFailure :: InterpProcess -> SomeException -> IO a
-handleInterpProcessFailure i e = do
- let hdl = interpHandle i
- ex <- getProcessExitCode hdl
- case ex of
- Just (ExitFailure n) ->
- throwIO (InstallationError ("External interpreter terminated (" ++ show n ++ ")"))
- _ -> do
- terminateProcess hdl
- _ <- waitForProcess hdl
- throw e
-
data CancelTHHandler = CancelTHHandler deriving Show
instance Exception CancelTHHandler where
fromException = asyncExceptionFromException
=====================================
compiler/GHC/Tc/Gen/Splice.hs
=====================================
@@ -1160,7 +1160,7 @@ runRemoteModFinalizers (ThModFinalizers finRefs) = do
runQinTcM $ sequence_ qs
#endif
- ExternalInterp ext -> withExtInterp ext $ \inst -> do
+ ExternalInterp ext -> withExtInterp interp ext $ \inst -> do
tcg <- getGblEnv
th_state <- readTcRef (tcg_th_remote_state tcg)
case th_state of
@@ -1817,7 +1817,7 @@ runTH ty fhv = do
return r
#endif
- ExternalInterp ext -> withExtInterp ext $ \inst -> do
+ ExternalInterp ext -> withExtInterp interp ext $ \inst -> do
-- Run it on the server. For an overview of how TH works with
-- Remote GHCi, see Note [Remote Template Haskell] in
-- libraries/ghci/GHCi/TH.hs.
=====================================
libraries/ghci/GHCi/Message.hs
=====================================
@@ -27,7 +27,7 @@ module GHCi.Message
, Pipe(..), mkPipeFromHandles, mkPipeFromContinuations, closePipe
, remoteCall, remoteTHCall
, handleRemoteCall, handleRemoteTHCall, writeReply
- , RemoteProcessException(..), PipeReadClosedException(..)
+ , RemoteProcessException(..), PipeClosedException(..)
, InboxId(..)
, newMailbox
@@ -75,7 +75,6 @@ import GHC.Stack.CCS
import qualified GHC.Boot.TH.Syntax as TH
import qualified GHC.Boot.TH.Monad as TH
import GHCi.Message.Async
-import Control.Monad.STM
-- -----------------------------------------------------------------------------
-- The RPC protocol between GHC and the interactive server
=====================================
libraries/ghci/GHCi/Message/Async.hs
=====================================
@@ -7,7 +7,7 @@ module GHCi.Message.Async
(
-- * Pipes
Pipe(..), mkPipeFromHandles, mkPipeFromContinuations
- , closePipe, PipeReadClosedException(..)
+ , closePipe, PipeClosedException(..)
-- * Interface for async bidirectional RPC
, remoteAsyncReq, handleAsyncReq
@@ -145,13 +145,13 @@ closePipe p@Pipe{..} = do
unless writeAlreadyClosed
(throwTo (asyncFillTid pipeAsyncMngr) PipeWriteClosedException)
--- | We've closed the pipe read end on this process
-data PipeReadClosedException = PipeReadClosedException deriving Show
-instance Exception PipeReadClosedException
+data PipeClosedException
+ = PipeReadClosedException -- ^ We've closed the pipe read end on this process
+
+ | PipeWriteClosedException -- ^ We've closed the pipe write end on this process
+ deriving Show
+instance Exception PipeClosedException
--- | We've closed the pipe write end on this process
-data PipeWriteClosedException = PipeWriteClosedException deriving Show
-instance Exception PipeWriteClosedException
--------------------------------------------------------------------------------
-- ** Pipe thread-safe read/write
@@ -539,7 +539,7 @@ fetchedRequest am uq = do
{-
Note [Exceptions during serialization]
------------------------------------------------------------------------------
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For efficiency reasons, any `IddMsg` to be sent is forced only when already
writing onto the Pipe, so we cannot discern whether any raised exception
=====================================
libraries/ghci/GHCi/Server.hs
=====================================
@@ -39,7 +39,6 @@ import System.Exit
import System.IO
import Control.Concurrent
-import Control.Monad.STM
import GHCi.Message.Async (runWriteReply, (%>>=))
import GHCi.Server.Threads
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a3a217670526335a827a72241538f4…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a3a217670526335a827a72241538f4…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][wip/fix-9809] 14 commits: Rework LogQueue to be a proper queue
by Erik de Castro Lopo (@erikd) 26 Oct '26
by Erik de Castro Lopo (@erikd) 26 Oct '26
26 Oct '26
Erik de Castro Lopo pushed to branch wip/fix-9809 at Glasgow Haskell Compiler / GHC
Commits:
953e4c7f by sheaf at 2026-10-26T18:19:10-04:00
Rework LogQueue to be a proper queue
Now 'LogQueue' uses a 'TQueue' with a separate 'TVar' to indicate
whether the log queue is finished logging, instead of the previous weird
data representation using a reverse-order '[Maybe Msg]' with 'Nothing'
denoting the end of the queue.
- - - - -
ec29c5fa by Rodrigo Mesquita at 2026-10-26T18:19:10-04:00
Refactor GHC.Driver.MakeAction
Pull out of 'runParPipelines' the logic for creating a 'MakeEnv' ready
to be used by multiple threads, as that will be useful for downsweep as
well (which doesn't fit the 'runPipelines' flow), rather than being just
for upsweep.
The code is moved and re-structured to match the export list, simplify
the sequentiality checks previously both in 'runPipelines' and
'runAllPipelines', which were weirdly similar and confusing; into the
two part step where we need these checks: (1) to construct the MakeEnv,
(2) to run the MakeActions in parallel. These two steps are separate and
used to be too mixed up.
Some additional little simplifications or clean ups here and there.
- - - - -
3fb22073 by Rodrigo Mesquita at 2026-10-26T18:19:11-04:00
Refactor GHC.Driver.Downsweep in preparation for parallel downsweep
Pure refactor to improve the code to facilitate implementing parallel
downsweep in the next commit.
This commit puts a MakeEnv into the DownsweepEnv, gives the fields
proper names and uses RecordWildcards to simplify, rather than passing
around all diagnostic wrappers, driver-message-things and using 10s of
positional fields.
No behavior changes here!
- - - - -
52f385a7 by sheaf at 2026-10-26T18:19:11-04:00
Driver: enableCodeGenForTH in load', not downsweep
enableCodeGenForTH modifies the module graph for planning, creating
fresh temporary paths. So it should only be run when we are about to
execute a build plan (e.g. in load'), so that consumers that want to
know facts about the module graph don't go looking for files that don't
exist yet (in particular 'haddock --no-compilation').
- - - - -
82402d14 by sheaf at 2026-10-26T18:19:11-04:00
2-phase Cache/Search Finder monad
This commit restructures the finder abstraction by introducing the
'FinderM' monad, which splits module lookup operations into two phases:
- a cache-only phase, performing no filesystem access,
- from the first cache miss onwards, a search action which may access
the filesystem.
This allows consumers to distinguish between quick cached results versus
more expensive filesystem search operations.
- - - - -
5c302b40 by sheaf at 2026-10-26T18:19:11-04:00
Separate Home/External finder caches
The caches for home modules and modules from external units have
different lifetimes, needing to be invalidated at different points.
This commit moves the cache for modules from external units into the
'UnitState' type, which keeps the cache correct whenever package flags
or package databases change (setSessionDynFlags, :set -package ...,
Backpack's addUnit).
This also makes it easier to clear the cache of home modules, as they
are now stored separately (obviating the 'isUnitEnvInstalledModule'
check we used to perform).
- - - - -
605fbb96 by sheaf at 2026-10-26T18:19:11-04:00
Add known home modules to the finder cache
The finder looks in the file system for the on-disk source that
corresponds to a Haskell module name. There are two kinds of modules
where we need to bypass this search:
- a file passed directly in the command line, which may not be in any
search path and whose module name may differ from the file name;
- Backpack signatures and modules, which do not exist as files at all.
This commit handles these two situations by adding an immutable
'KnownHomeModules' in the finder cache, which is always consulted first
before doing any search.
This removes the ad-hoc imperative logic which relied on mutating the
finder cache at careful points.
'setModuleGraph' now also takes the known home modules, so that the
module graph and the known home modules are always set consistently.
See Note [Known home modules] in GHC.Unit.Finder.Types.
- - - - -
82718f44 by sheaf at 2026-10-26T18:19:11-04:00
Make 'UnresolvedImport' into a suitable cache key
The goal of this commit is to make 'UnresolvedImport' suitable for use
as a cache key. Specifically, during downsweep we want to be able to
cache module resolution queries. We want to do this using some kind of
map, e.g. (roughly speaking):
Map UnresolvedImport ResolvedImport
For this to work, 'UnresolvedImport' must contain **precisely** the
input data to each resolution computation. In other words:
1. If something changes that materially affects resolution, it must
be stored in the cache key.
2. If changing some input does not materially affect the outcome,
then it must not be stored in the cache key.
To satisfy (1), we change 'UnitNode' to also keep track of the home
unit in whose unit state the unit's dependencies were looked up.
For (2), 'ImportResolution' now stores a 'ModuleLookupScope' instead of an
'UnresolvedImportOrigin'. Plugin imports are expressed with a new
'LookupPlugin' scope. The source location of an import, which is
immaterial to the resolution, is stored out of band outside
'UnresolvedImport', in 'ModSummary'.
- - - - -
d4635c7c by sheaf at 2026-10-26T18:19:11-04:00
Add GHC.Data.Dependent
This commit adds a minimal implementation of dependent sums
('Some', 'DSum') and dependent maps ('DMap').
The implementation is not entirely performance optimal, as there are a
few extraneous allocations compared to the full-blown implementation in
the 'dependent-map' package. For our use case (caching downsweep
computations), this does not matter much.
See GHC.Data.Dependent.
- - - - -
6759533e by sheaf at 2026-10-26T18:19:11-04:00
Driver: structured concurrent worker abstraction
This commit introduces a structured concurrency framework in the style
of the 'ki' library: a collection of threads within a scope.
We implement two kinds of concurrent workers on top of this framework:
- Independent workers cannot wait for one another at all. The only
scheduling operation is to wait for quiescence.
- Coordinating workers declare an STM readiness condition (waiting on
other workers to complete) which gates their start.
See Note [Deterministic concurrent workers] in GHC.Driver.Concurrency.
This commit ports upsweep to this new framework, with downsweep being
left as subsequent work.
Further changes along the way:
- Refactoring of how concurrency is acquired to avoid the footgun of
trying to use a no-op 'AbstractSem' as a lock in the serial case.
- The "re-run with -j1" logic for semaphore opening errors no longer
triggers on late semaphore failures (part-way through a lengthy
computation).
- Logger threads are properly cleaned up on exception, with each
concurrent worker's log queue and local TmpFs properly bracketed.
- The 'GhcMessage -> AnyGhcDiagnostic' and 'Maybe Messager'
arguments of 'depanalE', 'depanalPartial' and 'downsweep', which
were all dead in practice, have been dropped.
- Concurrent logging has been completely overhauled. Each worker has
its own log queue. Workers whose logs are printed as we go are
spawned in the order in which their logs must be printed, now using
a TQueue instead of the old complicated LogQueueQueue mechanism.
'logThread' is replaced by 'withLogPrinter', which runs the thread
that prints the log queues within a concurrent worker scope.
These changes allow us to fix issues with the exception handling:
we now always flush remaining log queues before exiting (even when
the action throws an exception), and exceptions that arise while
printing are properly rethrown. This fixes #28009.
- - - - -
38a99006 by sheaf at 2026-10-26T18:19:11-04:00
Rule-based deterministic concurrent downsweep
This commit rewrites downsweep as a single query-answering rule
(see 'DownsweepRule') that can be executed by concurrent worker threads.
The design allows every expensive operation (preprocessing files with CPP,
parsing headers, reading interfaces) to be performed concurrently
according to the -j<N>/-jsem flags.
See Note [Rules-based downsweep] in GHC.Driver.Downsweep.
The rules are run by "GHC.Driver.Concurrency.runRules" in a demand-driven
way: each worker can demand other workers to run, but never wait on
another worker. Every piece of work is done at most once.
Fixes #27514
Memory usage can increase due to doing more work concurrently:
-------------------------
Metric Increase:
MultiComponentModulesRecomp
MultiComponentModulesRecomp100
mhu-perf
-------------------------
- - - - -
9fa7b7be by sheaf at 2026-10-26T18:19:11-04:00
Acquire/release semaphore tokens more readily
This commit reworks GHC.Driver.MakeSem to use the scoped worker
abstraction of GHC.Utils.Concurrent.Scope. This allows us to get rid of
a lot of the tricky logic in GHC.Driver.MakeSem involving manual
exception handling, thread spawning and lifetime management, etc.
The main user-visible change is that token acquisition is no longer
rate limited (due to a bug, there previously was a 1s rate limit on
acquisition of semaphore tokens), with the release debounce period
shortened from 1s to 10ms.
Other changes:
- With -jsem, the number of capabilities is now capped at the number
of processors, bringing it in line with the -jN behaviour.
- Pending jobs whose wait for a token is interrupted by an exception
are now withdrawn from the jobserver, instead of acquiring a token
that it hung onto without doing useful work.
Fixes #27763
- - - - -
c83c6733 by Alan Zimmerman at 2026-10-26T18:19:55-04:00
EPA: Update AnnClsInstDecl to contain AnnList
It was already separately tracking the '{', '}' and leading ';' values.
This aligns it with layout-introducing parser productions ('vocurly'),
so the layout processing can be handled uniformly
- - - - -
5cc8337f by Erik de Castro Lopo at 2026-10-27T10:18:53+11:00
TimerManager: publish only evaluated timeout queues (#9809)
When many threads register timeouts at once, for example 100k forked
threads each calling registerDelay or threadDelay, the timer manager
showed huge GC overhead, memory use and timer latency. With 100k forked
registrations on -N4, master took 0.59 s and 437 MB peak memory, against
0.03 s and 31 MB when the same registrations come from one thread.
The cause goes back to 2d5eccdf1c ("IO manager: Edit the timeout queue
directly, rather than using an edit list", fixing #7653), which made every
registration atomicModifyIORef' the shared timeout queue. That publishes
the new queue as a thunk and only evaluates it afterwards, so each thread
builds its O(log n) insert on top of the previous thread's unevaluated
insert, giving thunk chains, threads blocking on each other's partly
evaluated updates, and many queue copies kept alive at once.
Registering threads now use a compare-and-swap loop that evaluates the new
queue before publishing it (IntPSQ is spine strict, so WHNF is fully
evaluated). The timer manager's own update in mkTimeout keeps using
atomicModifyIORef': with compare-and-swap its long update almost never won
against a stream of short inserts on other capabilities, which starved it
and delayed expired timeouts by hundreds of milliseconds.
Forked registrations of 100k timeouts (median of 5 runs):
-N4: 0.589 s, 437 MB -> 0.077 s, 37 MB
-N12: 1.182 s, 465 MB -> 0.125 s, 74 MB
Forked registrations of 1M timeouts on -N1:
5.85 s (range 0.69-6.49 s), 1824 MB -> 0.69 s, 193 MB
Single-thread registrations are unchanged or slightly faster, and timer
latency during registration storms improves (p99 lateness of a 1 ms
threadDelay during 100k forked registrations on -N4: 342-534 ms -> 4-7 ms).
The registration code still runs in constant stack, so #7653 stays fixed;
T7653 and the concurrent, base and ghc-internal testsuites pass.
Regression tests included.
Co-Authored-By: Claude Opus 5.5 <noreply(a)anthropic.com>
Add a test for the fix for #9809
Co-Authored-By: Claude Opus 5.5 <noreply(a)anthropic.com>
- - - - -
76 changed files:
- + changelog.d/T27763
- + changelog.d/T9809-timer-manager-contention
- + changelog.d/parallel-downsweep
- compiler/GHC.hs
- compiler/GHC/Builtin.hs
- + compiler/GHC/Data/Dependent.hs
- compiler/GHC/Driver/Backpack.hs
- + compiler/GHC/Driver/Concurrency.hs
- + compiler/GHC/Driver/Config/Concurrency.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/Env.hs
- compiler/GHC/Driver/Errors/Ppr.hs
- compiler/GHC/Driver/Errors/Types.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/MakeAction.hs
- compiler/GHC/Driver/MakeFile.hs
- compiler/GHC/Driver/MakeSem.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Pipeline/LogQueue.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Header.hs
- compiler/GHC/Runtime/Interpreter/JS.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Plugin.hs
- compiler/GHC/Tc/Utils/Backpack.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/UnresolvedImport.hs
- compiler/GHC/Unit/Finder.hs
- + compiler/GHC/Unit/Finder/Cache.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/Module/Graph.hs
- compiler/GHC/Unit/Module/ModSummary.hs
- compiler/GHC/Unit/Module/WholeCoreBindings.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Unit/Types.hs
- + compiler/GHC/Utils/Concurrent/Scope.hs
- compiler/GHC/Utils/TmpFs.hs
- compiler/ghc.cabal.in
- ghc/GHCi/UI.hs
- ghc/Main.hs
- libraries/base/tests/.gitignore
- + libraries/base/tests/T9809.hs
- libraries/base/tests/all.T
- libraries/ghc-internal/src/GHC/Internal/Event/TimerManager.hs
- linters/lint-codes/LintCodes/Static.hs
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/driver/Makefile
- testsuite/tests/driver/T27461/Makefile
- + testsuite/tests/driver/T27461/T27461c.stderr
- testsuite/tests/driver/T27461/all.T
- + testsuite/tests/driver/T27461/src/Wrong.hs
- + testsuite/tests/driver/T28009.hs
- testsuite/tests/driver/all.T
- testsuite/tests/ghc-api/downsweep/IncrementalDownsweep.hs
- testsuite/tests/ghc-api/downsweep/OldModLocation.hs
- testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs
- testsuite/tests/ghc-api/fixed-nodes/FixedNodes.hs
- testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.hs
- testsuite/tests/ghc-api/fixed-nodes/ModuleGraphInvariants.hs
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/plugins/defaulting-plugin/DefaultLifted.hs
- testsuite/tests/printer/Test24533.stdout
- testsuite/tests/splice-imports/SI35.hs
- utils/check-exact/ExactPrint.hs
- utils/check-ppr/Main.hs
- utils/haddock/haddock-api/src/Haddock/Interface.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4c4af608b690ce29179ab4496b01d…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4c4af608b690ce29179ab4496b01d…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][master] EPA: Update AnnClsInstDecl to contain AnnList
by Marge Bot (@marge-bot) 26 Oct '26
by Marge Bot (@marge-bot) 26 Oct '26
26 Oct '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
c83c6733 by Alan Zimmerman at 2026-10-26T18:19:55-04:00
EPA: Update AnnClsInstDecl to contain AnnList
It was already separately tracking the '{', '}' and leading ';' values.
This aligns it with layout-introducing parser productions ('vocurly'),
so the layout processing can be handled uniformly
- - - - -
6 changed files:
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Parser.y
- testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
- testsuite/tests/printer/Test24533.stdout
- utils/check-exact/ExactPrint.hs
Changes:
=====================================
compiler/GHC/Hs/Decls.hs
=====================================
@@ -1042,9 +1042,7 @@ data AnnClsInstDecl
= AnnClsInstDecl {
acid_instance :: EpToken "instance",
acid_where :: EpToken "where",
- acid_openc :: EpToken "{",
- acid_semis :: [EpToken ";"],
- acid_closec :: EpToken "}"
+ acid_decls :: AnnList
} deriving Data
@@ -1061,7 +1059,7 @@ type instance XTyFamInstD GhcTc = NoExtField
type instance XXInstDecl (GhcPass _) = DataConCantHappen
instance NoAnn AnnClsInstDecl where
- noAnn = AnnClsInstDecl noAnn noAnn noAnn noAnn noAnn
+ noAnn = AnnClsInstDecl noAnn noAnn noAnn
cidDeprecation :: forall p. IsPass p
=> ClsInstDecl (GhcPass p)
=====================================
compiler/GHC/Hs/Dump.hs
=====================================
@@ -268,12 +268,11 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0
showAstData' j]
annClsInstDecl :: AnnClsInstDecl -> SDoc
- annClsInstDecl (AnnClsInstDecl a b c d e) = case ba of
+ annClsInstDecl (AnnClsInstDecl a b c) = case ba of
BlankEpAnnotations -> parens $ text "blanked:" <+> text "AnnFamilyDecl"
NoBlankEpAnnotations ->
parens $ text "AnnClsInstDecl"
- $$ vcat [showAstData' a, showAstData' b, showAstData' c,
- showAstData' d, showAstData' e]
+ $$ vcat [showAstData' a, showAstData' b, showAstData' c]
annotationExprBracket :: BracketAnn (EpUniToken "[|" "⟦") (EpToken "[e|") -> SDoc
=====================================
compiler/GHC/Parser.y
=====================================
@@ -1435,8 +1435,8 @@ expModifiers1 :: { forall b. DisambECP b => PV (Located [LHsModifierOf (LocatedA
inst_decl :: { LInstDecl GhcPs }
: 'instance' maybe_warning_pragma overlap_pragma inst_type where_inst
{% do { decls <- cvBindsAndSigs (snd $ unLoc $5)
- ; let (twhere, (openc, closec, semis)) = fst $ unLoc $5
- ; let anns = AnnClsInstDecl (epTok $1) twhere openc semis closec
+ ; let (twhere, ann_list) = fst $ unLoc $5
+ ; let anns = AnnClsInstDecl (epTok $1) twhere ann_list
; let cid = ClsInstDecl
{ cid_ext = ($2, anns)
, cid_poly_ty = $4
@@ -1896,14 +1896,13 @@ decls_inst :: { Located ([EpToken ";"],OrdList (LHsDecl GhcPs)) } -- Reversed
| {- empty -} { noLoc ([],nilOL) }
decllist_inst
- :: { Located ((EpToken "{", EpToken "}", [EpToken ";"])
- , OrdList (LHsDecl GhcPs)) } -- Reversed
- : '{' decls_inst '}' { sLL $1 $> ((epTok $1,epTok $3,fst $ unLoc $2),snd $ unLoc $2) }
- | vocurly decls_inst close { L (gl $2) ((noAnn,noAnn,fst $ unLoc $2),snd $ unLoc $2) }
+ :: { Located (AnnList, OrdList (LHsDecl GhcPs)) } -- Reversed
+ : '{' decls_inst '}' { sLL $1 $> (AnnList AnnListBraces (ListBraces (epTok $1) (epTok $3)) (fst $ unLoc $2), snd $ unLoc $2) }
+ | vocurly decls_inst close { L (gl $2) (AnnList (AnnListLayout (glR $1)) ListNone (fst $ unLoc $2), snd $ unLoc $2) }
-- Instance body
--
-where_inst :: { Located ((EpToken "where", (EpToken "{", EpToken "}", [EpToken ";"]))
+where_inst :: { Located ((EpToken "where", AnnList)
, OrdList (LHsDecl GhcPs)) } -- Reversed
-- No implicit parameters
-- May have type declarations
=====================================
testsuite/tests/haddock/should_compile_flag_haddock/T17544.stderr
=====================================
@@ -999,9 +999,11 @@
(EpTok (EpaSpan { T17544.hs:23:1-8 }))
(EpTok
(EpaSpan { T17544.hs:23:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { T17544.hs:24:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -1393,9 +1395,11 @@
(EpTok (EpaSpan { T17544.hs:29:1-8 }))
(EpTok
(EpaSpan { T17544.hs:29:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { T17544.hs:30:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -1787,9 +1791,11 @@
(EpTok (EpaSpan { T17544.hs:35:1-8 }))
(EpTok
(EpaSpan { T17544.hs:35:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { T17544.hs:36:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -2181,9 +2187,11 @@
(EpTok (EpaSpan { T17544.hs:41:1-8 }))
(EpTok
(EpaSpan { T17544.hs:41:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { T17544.hs:42:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -2575,9 +2583,11 @@
(EpTok (EpaSpan { T17544.hs:47:1-8 }))
(EpTok
(EpaSpan { T17544.hs:47:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { T17544.hs:48:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -2969,9 +2979,11 @@
(EpTok (EpaSpan { T17544.hs:53:1-8 }))
(EpTok
(EpaSpan { T17544.hs:53:18-22 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { T17544.hs:54:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
=====================================
testsuite/tests/printer/Test24533.stdout
=====================================
@@ -64,9 +64,10 @@
(EpTok (EpaSpan { Test24533.hs:4:1-8 }))
(EpTok
(EpaSpan { <no location info> }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListNoLayout)
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -451,9 +452,11 @@
(EpTok (EpaSpan { Test24533.hs:14:1-8 }))
(EpTok
(EpaSpan { Test24533.hs:14:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { Test24533.hs:16:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -724,9 +727,10 @@
(EpTok (EpaSpan { Test24533.ppr.hs:3:1-8 }))
(EpTok
(EpaSpan { <no location info> }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListNoLayout)
+ (ListNone)
+ [])))
[]
(L
(EpAnn
@@ -1038,9 +1042,11 @@
(EpTok (EpaSpan { Test24533.ppr.hs:5:1-8 }))
(EpTok
(EpaSpan { Test24533.ppr.hs:5:17-21 }))
- (EpTok (EpaSpan { <no location info> }))
- []
- (EpTok (EpaSpan { <no location info> }))))
+ (AnnList
+ (AnnListLayout
+ (EpaSpan { Test24533.ppr.hs:6:3 }))
+ (ListNone)
+ [])))
[]
(L
(EpAnn
=====================================
utils/check-exact/ExactPrint.hs
=====================================
@@ -2406,18 +2406,17 @@ instance ExactPrint (ClsInstDecl GhcPs) where
getAnnotationEntry _ = NoEntryVal
setAnnotationAnchor a _ _ _ = a
- exact (ClsInstDecl { cid_ext = (mbWarn, AnnClsInstDecl i w oc semis cc)
+ exact (ClsInstDecl { cid_ext = (mbWarn, AnnClsInstDecl i w ann_list)
, cid_poly_ty = inst_ty
, cid_decls = decls
, cid_overlap_mode = mbOverlap
, cid_modifiers = mods })
= do
(mbWarn', i', w', mbOverlap', inst_ty', mods') <- top_matter
- oc' <- markEpToken oc
- semis' <- mapM markEpToken semis
- decls' <- mapM markAnnotated decls
- cc' <- markEpToken cc
- return (ClsInstDecl { cid_ext = (mbWarn', AnnClsInstDecl i' w' oc' semis' cc')
+ (ann_list', decls') <- markAnnListA' ann_list $ \a -> do
+ r <- setLayoutBoth $ mapM markAnnotated decls
+ return (a,r)
+ return (ClsInstDecl { cid_ext = (mbWarn', AnnClsInstDecl i' w' ann_list')
, cid_poly_ty = inst_ty'
, cid_decls = decls'
, cid_overlap_mode = mbOverlap'
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c83c673315407f28209004fc5a1cb2c…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/c83c673315407f28209004fc5a1cb2c…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0
[Git][ghc/ghc][master] 12 commits: Rework LogQueue to be a proper queue
by Marge Bot (@marge-bot) 26 Oct '26
by Marge Bot (@marge-bot) 26 Oct '26
26 Oct '26
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
953e4c7f by sheaf at 2026-10-26T18:19:10-04:00
Rework LogQueue to be a proper queue
Now 'LogQueue' uses a 'TQueue' with a separate 'TVar' to indicate
whether the log queue is finished logging, instead of the previous weird
data representation using a reverse-order '[Maybe Msg]' with 'Nothing'
denoting the end of the queue.
- - - - -
ec29c5fa by Rodrigo Mesquita at 2026-10-26T18:19:10-04:00
Refactor GHC.Driver.MakeAction
Pull out of 'runParPipelines' the logic for creating a 'MakeEnv' ready
to be used by multiple threads, as that will be useful for downsweep as
well (which doesn't fit the 'runPipelines' flow), rather than being just
for upsweep.
The code is moved and re-structured to match the export list, simplify
the sequentiality checks previously both in 'runPipelines' and
'runAllPipelines', which were weirdly similar and confusing; into the
two part step where we need these checks: (1) to construct the MakeEnv,
(2) to run the MakeActions in parallel. These two steps are separate and
used to be too mixed up.
Some additional little simplifications or clean ups here and there.
- - - - -
3fb22073 by Rodrigo Mesquita at 2026-10-26T18:19:11-04:00
Refactor GHC.Driver.Downsweep in preparation for parallel downsweep
Pure refactor to improve the code to facilitate implementing parallel
downsweep in the next commit.
This commit puts a MakeEnv into the DownsweepEnv, gives the fields
proper names and uses RecordWildcards to simplify, rather than passing
around all diagnostic wrappers, driver-message-things and using 10s of
positional fields.
No behavior changes here!
- - - - -
52f385a7 by sheaf at 2026-10-26T18:19:11-04:00
Driver: enableCodeGenForTH in load', not downsweep
enableCodeGenForTH modifies the module graph for planning, creating
fresh temporary paths. So it should only be run when we are about to
execute a build plan (e.g. in load'), so that consumers that want to
know facts about the module graph don't go looking for files that don't
exist yet (in particular 'haddock --no-compilation').
- - - - -
82402d14 by sheaf at 2026-10-26T18:19:11-04:00
2-phase Cache/Search Finder monad
This commit restructures the finder abstraction by introducing the
'FinderM' monad, which splits module lookup operations into two phases:
- a cache-only phase, performing no filesystem access,
- from the first cache miss onwards, a search action which may access
the filesystem.
This allows consumers to distinguish between quick cached results versus
more expensive filesystem search operations.
- - - - -
5c302b40 by sheaf at 2026-10-26T18:19:11-04:00
Separate Home/External finder caches
The caches for home modules and modules from external units have
different lifetimes, needing to be invalidated at different points.
This commit moves the cache for modules from external units into the
'UnitState' type, which keeps the cache correct whenever package flags
or package databases change (setSessionDynFlags, :set -package ...,
Backpack's addUnit).
This also makes it easier to clear the cache of home modules, as they
are now stored separately (obviating the 'isUnitEnvInstalledModule'
check we used to perform).
- - - - -
605fbb96 by sheaf at 2026-10-26T18:19:11-04:00
Add known home modules to the finder cache
The finder looks in the file system for the on-disk source that
corresponds to a Haskell module name. There are two kinds of modules
where we need to bypass this search:
- a file passed directly in the command line, which may not be in any
search path and whose module name may differ from the file name;
- Backpack signatures and modules, which do not exist as files at all.
This commit handles these two situations by adding an immutable
'KnownHomeModules' in the finder cache, which is always consulted first
before doing any search.
This removes the ad-hoc imperative logic which relied on mutating the
finder cache at careful points.
'setModuleGraph' now also takes the known home modules, so that the
module graph and the known home modules are always set consistently.
See Note [Known home modules] in GHC.Unit.Finder.Types.
- - - - -
82718f44 by sheaf at 2026-10-26T18:19:11-04:00
Make 'UnresolvedImport' into a suitable cache key
The goal of this commit is to make 'UnresolvedImport' suitable for use
as a cache key. Specifically, during downsweep we want to be able to
cache module resolution queries. We want to do this using some kind of
map, e.g. (roughly speaking):
Map UnresolvedImport ResolvedImport
For this to work, 'UnresolvedImport' must contain **precisely** the
input data to each resolution computation. In other words:
1. If something changes that materially affects resolution, it must
be stored in the cache key.
2. If changing some input does not materially affect the outcome,
then it must not be stored in the cache key.
To satisfy (1), we change 'UnitNode' to also keep track of the home
unit in whose unit state the unit's dependencies were looked up.
For (2), 'ImportResolution' now stores a 'ModuleLookupScope' instead of an
'UnresolvedImportOrigin'. Plugin imports are expressed with a new
'LookupPlugin' scope. The source location of an import, which is
immaterial to the resolution, is stored out of band outside
'UnresolvedImport', in 'ModSummary'.
- - - - -
d4635c7c by sheaf at 2026-10-26T18:19:11-04:00
Add GHC.Data.Dependent
This commit adds a minimal implementation of dependent sums
('Some', 'DSum') and dependent maps ('DMap').
The implementation is not entirely performance optimal, as there are a
few extraneous allocations compared to the full-blown implementation in
the 'dependent-map' package. For our use case (caching downsweep
computations), this does not matter much.
See GHC.Data.Dependent.
- - - - -
6759533e by sheaf at 2026-10-26T18:19:11-04:00
Driver: structured concurrent worker abstraction
This commit introduces a structured concurrency framework in the style
of the 'ki' library: a collection of threads within a scope.
We implement two kinds of concurrent workers on top of this framework:
- Independent workers cannot wait for one another at all. The only
scheduling operation is to wait for quiescence.
- Coordinating workers declare an STM readiness condition (waiting on
other workers to complete) which gates their start.
See Note [Deterministic concurrent workers] in GHC.Driver.Concurrency.
This commit ports upsweep to this new framework, with downsweep being
left as subsequent work.
Further changes along the way:
- Refactoring of how concurrency is acquired to avoid the footgun of
trying to use a no-op 'AbstractSem' as a lock in the serial case.
- The "re-run with -j1" logic for semaphore opening errors no longer
triggers on late semaphore failures (part-way through a lengthy
computation).
- Logger threads are properly cleaned up on exception, with each
concurrent worker's log queue and local TmpFs properly bracketed.
- The 'GhcMessage -> AnyGhcDiagnostic' and 'Maybe Messager'
arguments of 'depanalE', 'depanalPartial' and 'downsweep', which
were all dead in practice, have been dropped.
- Concurrent logging has been completely overhauled. Each worker has
its own log queue. Workers whose logs are printed as we go are
spawned in the order in which their logs must be printed, now using
a TQueue instead of the old complicated LogQueueQueue mechanism.
'logThread' is replaced by 'withLogPrinter', which runs the thread
that prints the log queues within a concurrent worker scope.
These changes allow us to fix issues with the exception handling:
we now always flush remaining log queues before exiting (even when
the action throws an exception), and exceptions that arise while
printing are properly rethrown. This fixes #28009.
- - - - -
38a99006 by sheaf at 2026-10-26T18:19:11-04:00
Rule-based deterministic concurrent downsweep
This commit rewrites downsweep as a single query-answering rule
(see 'DownsweepRule') that can be executed by concurrent worker threads.
The design allows every expensive operation (preprocessing files with CPP,
parsing headers, reading interfaces) to be performed concurrently
according to the -j<N>/-jsem flags.
See Note [Rules-based downsweep] in GHC.Driver.Downsweep.
The rules are run by "GHC.Driver.Concurrency.runRules" in a demand-driven
way: each worker can demand other workers to run, but never wait on
another worker. Every piece of work is done at most once.
Fixes #27514
Memory usage can increase due to doing more work concurrently:
-------------------------
Metric Increase:
MultiComponentModulesRecomp
MultiComponentModulesRecomp100
mhu-perf
-------------------------
- - - - -
9fa7b7be by sheaf at 2026-10-26T18:19:11-04:00
Acquire/release semaphore tokens more readily
This commit reworks GHC.Driver.MakeSem to use the scoped worker
abstraction of GHC.Utils.Concurrent.Scope. This allows us to get rid of
a lot of the tricky logic in GHC.Driver.MakeSem involving manual
exception handling, thread spawning and lifetime management, etc.
The main user-visible change is that token acquisition is no longer
rate limited (due to a bug, there previously was a 1s rate limit on
acquisition of semaphore tokens), with the release debounce period
shortened from 1s to 10ms.
Other changes:
- With -jsem, the number of capabilities is now capped at the number
of processors, bringing it in line with the -jN behaviour.
- Pending jobs whose wait for a token is interrupted by an exception
are now withdrawn from the jobserver, instead of acquiring a token
that it hung onto without doing useful work.
Fixes #27763
- - - - -
65 changed files:
- + changelog.d/T27763
- + changelog.d/parallel-downsweep
- compiler/GHC.hs
- compiler/GHC/Builtin.hs
- + compiler/GHC/Data/Dependent.hs
- compiler/GHC/Driver/Backpack.hs
- + compiler/GHC/Driver/Concurrency.hs
- + compiler/GHC/Driver/Config/Concurrency.hs
- compiler/GHC/Driver/Downsweep.hs
- compiler/GHC/Driver/Env.hs
- compiler/GHC/Driver/Errors/Ppr.hs
- compiler/GHC/Driver/Errors/Types.hs
- compiler/GHC/Driver/Main/Passes.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/MakeAction.hs
- compiler/GHC/Driver/MakeFile.hs
- compiler/GHC/Driver/MakeSem.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Driver/Pipeline/LogQueue.hs
- compiler/GHC/Iface/Load.hs
- compiler/GHC/Iface/Recomp.hs
- compiler/GHC/Linker/Deps.hs
- compiler/GHC/Parser/Header.hs
- compiler/GHC/Runtime/Interpreter/JS.hs
- compiler/GHC/Runtime/Loader.hs
- compiler/GHC/StgToJS/Linker/Linker.hs
- compiler/GHC/Tc/Gen/Splice.hs
- compiler/GHC/Tc/Module.hs
- compiler/GHC/Tc/Plugin.hs
- compiler/GHC/Tc/Utils/Backpack.hs
- compiler/GHC/Types/Error/Codes.hs
- compiler/GHC/Types/UnresolvedImport.hs
- compiler/GHC/Unit/Finder.hs
- + compiler/GHC/Unit/Finder/Cache.hs
- compiler/GHC/Unit/Finder/Types.hs
- compiler/GHC/Unit/Module/Graph.hs
- compiler/GHC/Unit/Module/ModSummary.hs
- compiler/GHC/Unit/Module/WholeCoreBindings.hs
- compiler/GHC/Unit/State.hs
- compiler/GHC/Unit/Types.hs
- + compiler/GHC/Utils/Concurrent/Scope.hs
- compiler/GHC/Utils/TmpFs.hs
- compiler/ghc.cabal.in
- ghc/GHCi/UI.hs
- ghc/Main.hs
- linters/lint-codes/LintCodes/Static.hs
- testsuite/tests/count-deps/CountDepsParser.stdout
- testsuite/tests/diagnostic-codes/codes.stdout
- testsuite/tests/driver/Makefile
- testsuite/tests/driver/T27461/Makefile
- + testsuite/tests/driver/T27461/T27461c.stderr
- testsuite/tests/driver/T27461/all.T
- + testsuite/tests/driver/T27461/src/Wrong.hs
- + testsuite/tests/driver/T28009.hs
- testsuite/tests/driver/all.T
- testsuite/tests/ghc-api/downsweep/IncrementalDownsweep.hs
- testsuite/tests/ghc-api/downsweep/OldModLocation.hs
- testsuite/tests/ghc-api/downsweep/PartialDownsweep.hs
- testsuite/tests/ghc-api/fixed-nodes/FixedNodes.hs
- testsuite/tests/ghc-api/fixed-nodes/InterfaceModuleGraph.hs
- testsuite/tests/ghc-api/fixed-nodes/ModuleGraphInvariants.hs
- testsuite/tests/plugins/defaulting-plugin/DefaultLifted.hs
- testsuite/tests/splice-imports/SI35.hs
- utils/check-ppr/Main.hs
- utils/haddock/haddock-api/src/Haddock/Interface.hs
The diff was not included because it is too large.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4a3a964b00f2e73b71592161fe7e2…
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a4a3a964b00f2e73b71592161fe7e2…
You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help
1
0