[GHC] #9447: Add support for resizing `MutableByteArray#`s
GHC
ghc-devs at haskell.org
Sat Aug 16 13:49:52 UTC 2014
#9447: Add support for resizing `MutableByteArray#`s
-------------------------------------+-------------------------------------
Reporter: hvr | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Keywords: | Operating System:
Architecture: Unknown/Multiple | Unknown/Multiple
Difficulty: Unknown | Type of failure:
Blocked By: | None/Unknown
Related Tickets: | Test Case:
| Blocking:
| Differential Revisions: Phab:D133
-------------------------------------+-------------------------------------
This is motivated by #9281 which changes how memory is allocated, and
gives rise to the need to be able to efficiently shrink or grow
`MutableByteArray#`s before they're frozen into `ByteArray#` while
retaining their original byte content to avoid a major bottle-neck.
This ticket is for tracking/documenting all changes related to this new
facility.
Here's the current road-map:
1. Implement
{{{#!hs
shrinkMutableByteArray# :: MutableByteArray# s -> Int# -> State# s ->
State# s
resizeMutableByteArray# :: MutableByteArray# s -> Int# -> State# s ->
(# State# s, MutableByteArray# s #)
}}}
(see Phab:D133)
2. As suggested by Johan,
{{{#!hs
getSizeofMutableByteArray# :: MutableByteArray# s -> State# s -> (#
State# s Int# #)
}}}
This is similar in spirit to `numCapabilities` and
`getNumCapabilities`.
Add a deprecate pragma (or equivalent) for `sizeofMutableByteArray#`.
Add a note to `sizeofMutableByteArray#` stating that it's unsafe in
the presence of calls to resize-operations on the same MBA.
3. Submit patches to upstream libraries replacing calls to
`sizeofMutableByteArray#` with `getSizeofMutableByteArray#`
4. Investigate how to provide in-place (zero-copy) growing of MBAs (step
1. only implements in-place shrinking).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9447>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list