[Git][ghc/ghc][master] [base] Document the memory overhead of ByteArray

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Thu May 23 01:57:41 UTC 2024



Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC


Commits:
4bb2a7cc by Hécate Moonlight at 2024-05-22T21:55:59-04:00
[base] Document the memory overhead of ByteArray

Add a diagram that shows the constituent parts of a ByteArray and their
memory overhead.

- - - - -


1 changed file:

- libraries/base/src/Data/Array/Byte.hs


Changes:

=====================================
libraries/base/src/Data/Array/Byte.hs
=====================================
@@ -41,6 +41,22 @@ import Prelude
 -- but wrap and unwrap 'ByteArray' internally as they please
 -- and use functions from "GHC.Exts".
 --
+-- The memory representation of a 'ByteArray' is:
+--
+-- > ╭─────────────┬───╮  ╭────────┬──────┬─────────╮
+-- > │ Constructor │ * ┼─➤│ Header │ Size │ Payload │
+-- > ╰─────────────┴───╯  ╰────────┴──────┴─────────╯
+--
+-- And its overhead is the following:
+--
+-- * 'ByteArray' constructor: 1 word
+-- * Pointer to 'ByteArray#': 1 word
+-- * 'ByteArray#' Header: 1 word
+-- * 'ByteArray#' Size: 1 word
+--
+-- Where a word is the unit of heap allocation,
+-- measuring 8 bytes on 64-bit systems, and 4 bytes on 32-bit systems.
+--
 -- @since 4.17.0.0
 data ByteArray = ByteArray ByteArray#
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bb2a7ccd431a8655ef96b6fa430e98da9baa7be

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/4bb2a7ccd431a8655ef96b6fa430e98da9baa7be
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240522/17481b4c/attachment-0001.html>


More information about the ghc-commits mailing list