#4979: IO performance regression in 7.0.2
---------------------------+------------------------------------------------
Reporter: simonpj | Owner: simonmar
Type: bug | Status: closed
Priority: normal | Milestone:
Component: Compiler | Version: 7.0.1
Resolution: wontfix | Keywords:
Testcase: | Blockedby:
Difficulty: | Os: Unknown/Multiple
Blocking: | Architecture: Unknown/Multiple
Failure: None/Unknown |
---------------------------+------------------------------------------------
Changes (by simonmar):
* status: new => closed
* resolution: => wontfix
Comment:
Yes, this was my fault. The change was:
{{{
Thu Nov 25 10:25:20 GMT 2010 Simon Marlow <[email protected]>
* Encode immediately in hPutStr and hPutChar
This means that decoding errors will be detected accurately, and can
be caught and handled. Overall the implementation is simpler this way
too.
It does impose a performance hit on small hPutStrs, although larger
hPutStrs seem to be unaffected. To compensate somewhat, I optimised
hPutStrLn.
M ./GHC/IO/Handle.hs -24 +4
M ./GHC/IO/Handle/Internals.hs -52 +60
M ./GHC/IO/Handle/Text.hs -128 +78
M ./GHC/IO/Handle/Types.hs -17 +47
M ./System/IO.hs -10 +2
}}}
So small `hPutStr`s incur an overhead, and if we look at the code for
sphere:
{{{
> ppm :: Int -> [((Int, Int),Vector)] -> IO ()
> ppm winsize matrix = do putStrLn "P3"
> putStr (show winsize); putStr " "
> putStrLn (show winsize)
> putStrLn "255"
> pixels matrix
> pixels :: [((Int, Int),Vector)] -> IO ()
> pixels [] = putStr ""
> pixels ((point,colour):ps) = do rbg colour
> putStrLn ""
> pixels ps
> rbg :: Vector -> IO ()
> rbg (r,g,b) = do putStr (eight_bit r); putStr " "
> putStr (eight_bit g); putStr " "
> putStr (eight_bit b)
> where eight_bit = show . round . (255*)
}}}
It's made of tiny `putStr`s. Not much we can do here, just advise people
not to write code like this.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4979#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs