[GHC] #8647: Reduce allocations in `integer-gmp`
GHC
ghc-devs at haskell.org
Tue Jan 7 21:07:39 UTC 2014
#8647: Reduce allocations in `integer-gmp`
--------------------------------------------+------------------------------
Reporter: hvr | Owner:
Type: task | Status: patch
Priority: normal | Milestone: 7.8.1
Component: libraries (other) | Version: 7.6.3
Resolution: | Keywords: integer-
Operating System: Unknown/Multiple | gmp
Type of failure: Runtime performance bug | Architecture: x86_64
Test Case: | (amd64)
Blocking: | Difficulty: Unknown
| Blocked By:
| Related Tickets: #8638
--------------------------------------------+------------------------------
Comment (by hvr):
Replying to [comment:6 hvr]:
> I attached the patch instead of pushing to Git, as I'm not satisfied yet
with it. It's works stable here (passes `validate` & `nofib`), but I'm not
sure about the `unsafeCoerce#`.
>
> In my first version of this patch, I used a 3-tuple `(# Int#,
ByteArray#, Word# #)` as return value, but that wasted 1 return register
per `Integer` result, and still had to return a NULL pointer for
`ByteArray#` for the case it wasn't used.
After a conversation with Duncan, I'm now convinced that the `(# Int#,
ByteArray# #)` + `unsafeCoerce#` hack is really bad, as the GC could try
to follow the `ByteArray#` pointer even though it was really just a
`Word#` in disguise.
Otoh, passing a 0-pointer for the 3-tuple variant has the same danger.
So now I'm left wondering if I can somehow statically allocate a dummy
`ByteArray#` I can return in Cmm when there's no need to allocate a proper
`ByteArray#` in order to avoid confusing the GC.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8647#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list