
#14741: High-memory usage during compilation using Template Haskell -------------------------------------+------------------------------------- Reporter: donatello | Owner: sighingnow Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Compile-time | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D4384 Wiki Page: | -------------------------------------+------------------------------------- Comment (by sighingnow): Further optimization for `pprASCII` needs change `CmmString [Word8]` to `CmmString ByteString`. I have test the performance of unpacking `ByteString` to [Word8]: {{{ embedFile :: FilePath -> IO [Word8] embedFile fp = do print fp B.unpack <$> B.readFile fp main :: IO () main = do x' <- {-# SCC "forceRead" #-} (force <$> embedFile "3mb") print (length x') }}} It generates the following prof result: {{{ foldr-test.exe +RTS -p -RTS total time = 0.07 secs (74 ticks @ 1000 us, 1 processor) total alloc = 130,807,344 bytes (excludes profiling overheads) COST CENTRE MODULE SRC %time %alloc forceRead Main foldr-test.hs:44:35-61 67.6 100.0 MAIN MAIN <built-in> 32.4 0.0 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14741#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler