From 00667237125d0483e671776dc83d4a1322615514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Wed, 7 Aug 2013 11:34:56 +0900 Subject: [PATCH 1/2] GHC: Build normal and profiling libraries in parallel. Yields almost 2x speed increase. --- Cabal/Distribution/Simple/GHC.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index d0f44b4d0c7..2e1d88938ad 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -126,6 +126,7 @@ import Distribution.Text import Language.Haskell.Extension (Language(..), Extension(..) ,KnownExtension(..)) +import Control.Concurrent ( forkIO, newEmptyMVar, putMVar, takeMVar ) import Control.Monad ( unless, when ) import Data.Char ( isSpace ) import Data.List @@ -759,11 +760,16 @@ buildOrReplLib forRepl verbosity pkg_descr lbi lib clbi = do (forceVanillaLib || withVanillaLib lbi) && (forceSharedLib || withSharedLib lbi) && null (ghcSharedOptions libBi) - if useDynToo + + -- MVar for building (vanilla/shared) and profiling in parallel + -- TODO: We probably need to add a bit of terminate-early code. + m <- newEmptyMVar + _ <- forkIO $ if useDynToo then runGhcProg vanillaSharedOpts - else if isGhcDynamic then do shared; vanilla - else do vanilla; shared + else if isGhcDynamic then do shared; vanilla; putMVar m () + else do vanilla; shared; putMVar m () whenProfLib (runGhcProg profOpts) + takeMVar m -- build any C sources unless (null (cSources libBi)) $ do From aba6d17235b02685115942ebbad24d4af247ac74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Thu, 12 Sep 2013 20:37:39 +0900 Subject: [PATCH 2/2] GHC: Also build prof version of C sources in parallel. --- Cabal/Distribution/Simple/GHC.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 2e1d88938ad..5369fb3de45 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -788,9 +788,11 @@ buildOrReplLib forRepl verbosity pkg_descr lbi lib clbi = do } odir = fromFlag (ghcOptObjDir vanillaCcOpts) createDirectoryIfMissingVerbose verbosity True odir - runGhcProg vanillaCcOpts + m <- newEmptyMVar + _ <- forkIO $ runGhcProg vanillaCcOpts >> putMVar m () whenSharedLib forceSharedLib (runGhcProg sharedCcOpts) whenProfLib (runGhcProg profCcOpts) + takeMVar m | filename <- cSources libBi] -- TODO: problem here is we need the .c files built first, so we can load them