Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,976
    • Issues 4,976
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 479
    • Merge requests 479
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #13825
Closed
Open
Created Jun 13, 2017 by Michal Terepeta@michaltReporter

Allow multiple constructor fields occupy the same word

The main goal is to reduce the overhead of things like:

data Bloated =
  Bloated {-# UNPACK #-} !Word8
          {-# UNPACK #-} !Int8
          {-# UNPACK #-} !Bool

Assuming 64-bit architecture, currently those fields will take 8 bytes each! So for this example we'd need: 8 bytes for header + 3 * 8 bytes for fields = 32 bytes. But we should be able to pack the fields into a single word (a word is 8 bytes and each field really only needs 1 byte) for a total of 16 bytes (8 bytes header + 8 bytes for fields, with the 5 bytes being "overhead" due to heap alignment).

My understanding is that we need a few things to make this happen:

  • Ability to refer to fields that are packed into a single word (currently everything in GHC assumes that each field occupies a single word). Simon Marlow started working on this in https://phabricator.haskell.org/D38
  • Introduce primitives like Word8#, Int8#, ... (currently WordX and IntX are defined as wrappers of Word# and Int# respectively) and change WordX/IntX definitions to use those primitives.
  • ~~Figure out what to do with Bool (should it be just Word8#? should we have Bool#?) and change its definition (using pattern synonyms for True/False)~~ Bool should be handled by #605 (see ticket:13825#comment:138006)

Some additional info:

  • Thread on ghc-devs: https://mail.haskell.org/pipermail/ghc-devs/2017-June/014304.html
Edited Mar 10, 2019 by Michal Terepeta
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking