summaryrefslogtreecommitdiff
path: root/src/compiler/GF/System
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2014-08-25 09:56:00 +0000
committerhallgren <hallgren@chalmers.se>2014-08-25 09:56:00 +0000
commitd84c5ef1715c3e4aed4098ee9c847e2dcc86cba4 (patch)
treefd7961f7db787ae4cefce4cccca4912ffcdfc999 /src/compiler/GF/System
parent9253d54b7e4d6f496124fcc1c3e6f852213e7d84 (diff)
Experimental: parallel batch compilation of grammars
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.
Diffstat (limited to 'src/compiler/GF/System')
-rw-r--r--src/compiler/GF/System/Directory.hs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/compiler/GF/System/Directory.hs b/src/compiler/GF/System/Directory.hs
index 3cd8a8ef6..306c5fbcb 100644
--- a/src/compiler/GF/System/Directory.hs
+++ b/src/compiler/GF/System/Directory.hs
@@ -4,10 +4,14 @@ 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 (doesDirectoryExist,doesFileExist,getModificationTime,
- getCurrentDirectory,getDirectoryContents,removeFile)
+ 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)
@@ -15,5 +19,6 @@ 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 \ No newline at end of file