[GHC] #9447: Add support for resizing `MutableByteArray#`s

#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

#9447: Add support for resizing `MutableByteArray#`s
-------------------------------------+-------------------------------------
Reporter: hvr | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | 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 |
-------------------------------------+-------------------------------------
Comment (by Herbert Valerio Riedel

#9447: Add support for resizing `MutableByteArray#`s -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D133 -------------------------------------+------------------------------------- Changes (by thomie): * failure: None/Unknown => Runtime performance bug * type: bug => feature request -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9447#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9447: Add support for resizing `MutableByteArray#`s -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D133 -------------------------------------+------------------------------------- Comment (by bgamari): See Phab:D1139 for an implementation of `getSizeofMutableByteArray#`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9447#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9447: Add support for resizing `MutableByteArray#`s -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D133, | Phab:D1139 -------------------------------------+------------------------------------- Changes (by bgamari): * status: new => patch * differential: Phab:D133 => Phab:D133, Phab:D1139 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9447#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9447: Add support for resizing `MutableByteArray#`s
-------------------------------------+-------------------------------------
Reporter: hvr | Owner:
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions: Phab:D133,
| Phab:D1139
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#9447: Add support for resizing `MutableByteArray#`s -------------------------------------+------------------------------------- Reporter: hvr | Owner: Type: feature request | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime | Unknown/Multiple performance bug | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: Phab:D133, | Phab:D1139 -------------------------------------+------------------------------------- Comment (by bgamari): hvr, I discussed this briefly with Simon Marlow in the meeting last week and he indicated that it may not be too tricky to implement efficient growing of ByteArrays. Perhaps you'd like to discuss this with him (assuming you still believe this is a worthwhile optimization)? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9447#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC