mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
On my laptop these changes speed up the full build of the RGL and example grammars with 'cabal build' from ~95s to ~43s and the zero build from ~18s to ~5s. The main change is the introduction of the module GF.CompileInParallel that replaces GF.Compile and the function GF.Compile.ReadFiles.getAllFiles. At present, it is activated with the new -j flag, and it is only used when combined with --make or --batch. In addition, to get parallel computations, you need to add GHC run-time flags, e.g., +RTS -N -A20M -RTS, to the command line. The Setup.hs script has been modified to pass the appropriate flags to GF for parallel compilation when compiling the RGL and example grammars, but you need a recent version of Cabal for this to work (probably >=1.20). Some additonal refactoring were made during this work. A new monad is used to avoid warnings/error messages from different modules to be intertwined when compiling in parallel, so some functios that were hardiwred to the IO or IOE monads have been lifted to work in arbitrary monads that are instances in the appropriate classes.
24 lines
1.1 KiB
Haskell
24 lines
1.1 KiB
Haskell
-- | Isolate backwards incompatible library changes to 'getModificationTime'
|
|
-- and provide lifted versions of some directory operations
|
|
module GF.System.Directory(module GF.System.Directory,module D) where
|
|
import Control.Monad.Trans(MonadIO(..))
|
|
import qualified System.Directory as D
|
|
import System.Directory as D
|
|
hiding (canonicalizePath,createDirectoryIfMissing,
|
|
doesDirectoryExist,doesFileExist,getModificationTime,
|
|
getCurrentDirectory,getDirectoryContents,getPermissions,
|
|
removeFile)
|
|
import Data.Time.Compat
|
|
|
|
canonicalizePath path = liftIO $ D.canonicalizePath path
|
|
createDirectoryIfMissing b = liftIO . D.createDirectoryIfMissing b
|
|
doesDirectoryExist path = liftIO $ D.doesDirectoryExist path
|
|
doesFileExist path = liftIO $ D.doesFileExist path
|
|
getModificationTime path = liftIO $ fmap toUTCTime (D.getModificationTime path)
|
|
getDirectoryContents path = liftIO $ D.getDirectoryContents path
|
|
|
|
getCurrentDirectory :: MonadIO io => io FilePath
|
|
getCurrentDirectory = liftIO D.getCurrentDirectory
|
|
getPermissions path = liftIO $ D.getPermissions path
|
|
|
|
removeFile path = liftIO $ D.removeFile path |