#2289: Needless reboxing of values when returning from a tight loop
----------------------------------------+-----------------------------------
Reporter: dons | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Milestone: 6.10 branch
Component: Compiler | Version: 6.8.2
Severity: normal | Resolution:
Keywords: boxing, loops, performance | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
----------------------------------------+-----------------------------------
Comment (by simonpj):
Don't hold your breath for unboxed sum types. For example, if the `Bool`
is `True`, the other two fields may be uninitialised, and should not be
followed by the GC. I suppose if you were prepared to stubs initialised to
`(error "Bad")`, then you could do this worker/wrapper split for `go`:
{{{
readInt :: String -> Maybe (Int, String)
readInt s = case readInt_w s of
(# True, n, s #) -> Nothing
(# False, n, s #) -> Just (n,s)
readInt_w :: String -> (# Bool, Int, String #)
readInt_w s = case <readInt_body> of
Just (n,s) -> (# False, n, s #)
Nothing -> (# True, error "BAD", error "BAD" #)
}}}
Things get harder if there are more constructors in the sum type, or the
constructors have more arguments.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2289#comment:10>
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