[GHC] #15980: unpin a mutable byte array
GHC
ghc-devs at haskell.org
Fri Nov 30 21:09:35 UTC 2018
#15980: unpin a mutable byte array
-------------------------------------+-------------------------------------
Reporter: andrewthad | Owner: (none)
Type: task | Status: new
Priority: normal | Milestone: 8.6.3
Component: Compiler | Version: 8.6.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
Sometimes, it necessary to allocate a mutable byte array as pinned. This
commonly happens when the mutable byte array will immidiately be handed
over to a `safe` FFI routine to be initialized. However, after it has been
initialized, it might not be useful for it to be pinned anymore. If it's a
little byte array, it may contribute to a fragmented heap. Even if it's
large, the fact that the user explicitly asked pin it prohibits it from
ever being added to a compact region (pinned bytearrays that were pinned
simply because they are over 3KB can be added to compact regions). A
workaround for either of these problems is to copy the pinned bytearray
into an unpinned byte array afterwards. But that's kind of wasteful. Is it
possible to have a primop
{{{
unpinMutableByteArray :: MutableByteArray s -> State# s -> State# s
}}}
After this, the mutable byte array could be moved in memory. This would
require `isMutableByteArrayPinned#` to undergo a similar transition as
`sizeofMutableByteArray#` (which was superceeded by
`getSizeofMutableByteArray#`) underwent.
Is this possible? Or are pinned things allocated in a special place that
makes unpinning impossible?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15980>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list