[commit: ghc] ghc-parmake-gsoc: Buffer stdout and stderr when we're compiling via GHCi (7f33152)

git at git.haskell.org git at git.haskell.org
Tue Aug 27 16:11:51 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-parmake-gsoc
Link       : http://ghc.haskell.org/trac/ghc/changeset/7f33152529df7bcdc73f8c67a446f984e6cef325/ghc

>---------------------------------------------------------------

commit 7f33152529df7bcdc73f8c67a446f984e6cef325
Author: Patrick Palka <patrick at parcs.ath.cx>
Date:   Mon Aug 26 17:14:50 2013 -0400

    Buffer stdout and stderr when we're compiling via GHCi


>---------------------------------------------------------------

7f33152529df7bcdc73f8c67a446f984e6cef325
 ghc/InteractiveUI.hs |   15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/ghc/InteractiveUI.hs b/ghc/InteractiveUI.hs
index 80032f2..7b7e0a6 100644
--- a/ghc/InteractiveUI.hs
+++ b/ghc/InteractiveUI.hs
@@ -1315,9 +1315,18 @@ doLoad retain_context howmuch = do
   -- turn off breakpoints before we load: we can't turn them off later, because
   -- the ModBreaks will have gone away.
   lift discardActiveBreakPoints
-  ok <- trySuccess $ GHC.load howmuch
-  afterLoad ok retain_context
-  return ok
+
+  -- Enable buffering stdout and stderr as we're compiling. Keeping these
+  -- handles unbuffered will just slow the compilation down, especially when
+  -- compiling in parallel.
+  gbracket (liftIO $ do hSetBuffering stdout LineBuffering
+                        hSetBuffering stderr LineBuffering)
+           (\_ ->
+            liftIO $ do hSetBuffering stdout NoBuffering
+                        hSetBuffering stderr NoBuffering) $ \_ -> do
+      ok <- trySuccess $ GHC.load howmuch
+      afterLoad ok retain_context
+      return ok
 
 
 afterLoad :: SuccessFlag





More information about the ghc-commits mailing list