Skip to content

Avoid UArray when indexing is not required

UnlinkedBCO's can occur many times in the heap. Each UnlinkedBCO references two UArray's but never indexes them. They are only needed to encode the elements into a ByteArray#. The three words for the lower bound, upper bound and number of elements are essentially unused, thus we replace UArray with a wrapper around ByteArray#. This saves us up to three words for each UnlinkedBCO.

Further, to avoid re-allocating these words for ResolvedBCO, we repeat the procedure for ResolvedBCO and add custom Binary and Show instances.

For example, agda's repl session has around 360_000 UnlinkedBCO's, so avoiding these three words is already saving us around 8MB residency.

Thank you for your contribution to GHC!

Please read the checklist below to make sure your contribution fulfills these expectations. Also please answer the following question in your MR description:

Where is the key part of this patch? That is, what should reviewers look at first?

Please take a few moments to address the following points:

  • if your MR may break existing programs (e.g. touches base or causes the compiler to reject programs), please describe the expected breakage and add the user-facing label. This will run ghc/head.hackage> to characterise the effect of your change on Hackage.
  • ensure that your commits are either individually buildable or squashed
  • ensure that your commit messages describe what they do (referring to tickets using #NNNN syntax when appropriate)
  • have added source comments describing your change. For larger changes you likely should add a Note and cross-reference it from the relevant places.
  • add a testcase to the testsuite.
  • updates the users guide if applicable
  • mentions new features in the release notes for the next release

If you have any questions don't hesitate to open your merge request and inquire in a comment. If your patch isn't quite done yet please do add prefix your MR title with WIP:.

By default a minimal validation pipeline is run on each merge request, the full-ci label can be applied to perform additional validation checks if your MR affects a more unusual configuration.

Once your change is ready please remove the WIP: tag and wait for review. If no one has offered a review in a few days then please leave a comment mentioning @triagers and apply the Blocked on Review label.

Merge request reports