Skip to content

Commit

Permalink
setupEnv: Run some processes concurrently
Browse files Browse the repository at this point in the history
This should make most commands slightly faster.
On my machine, `stack path` takes ~20% less time than before, a no-op
`stack build` in a single-package project ~15%.
  • Loading branch information
sjakobi committed Jul 21, 2016
1 parent 8f03a88 commit 875954c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module Stack.Setup
) where

import Control.Applicative
import Control.Concurrent.Async.Lifted (Concurrently(..))
import Control.Exception.Enclosed (catchIO, tryAny)
import Control.Monad (liftM, when, join, void, unless)
import Control.Monad.Catch
Expand Down Expand Up @@ -214,10 +215,13 @@ setupEnv mResolveMissingGHC = do
menv0 <- getMinimalEnvOverride
env <- removeHaskellEnvVars
<$> augmentPathMap (maybe [] edBins mghcBin) (unEnvOverride menv0)

menv <- mkEnvOverride platform env
compilerVer <- getCompilerVersion menv wc
cabalVer <- getCabalPkgVer menv wc

(compilerVer, cabalVer, globaldb) <- runConcurrently $ (,,)
<$> Concurrently (getCompilerVersion menv wc)
<*> Concurrently (getCabalPkgVer menv wc)
<*> Concurrently (getGlobalDB menv wc)

$logDebug "Resolving package entries"
packages <- mapM
(resolvePackageEntry menv (bcRoot bconfig))
Expand All @@ -240,7 +244,6 @@ setupEnv mResolveMissingGHC = do
createDatabase menv wc deps
localdb <- runReaderT packageDatabaseLocal envConfig0
createDatabase menv wc localdb
globaldb <- getGlobalDB menv wc
extras <- runReaderT packageDatabaseExtra envConfig0
let mkGPP locals = mkGhcPackagePath locals localdb deps extras globaldb

Expand Down
1 change: 1 addition & 0 deletions stack.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ library
, http-client-tls >= 0.3.0
, http-conduit >= 2.2.0
, http-types >= 0.8.6 && < 0.10
, lifted-async
-- https://github.com/basvandijk/lifted-base/issues/31
, lifted-base < 0.2.3.7 || > 0.2.3.7
, microlens >= 0.3.0.0
Expand Down

0 comments on commit 875954c

Please sign in to comment.