Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make singleton return a slice of a static buffer #480

Merged
merged 3 commits into from
Feb 3, 2022

Conversation

clyring
Copy link
Member

@clyring clyring commented Feb 1, 2022

This has the effect of making newly-created singletons only require 4 rather than 9 words of heap space. Additionally, since the body of singleton now simplifies to a constructor application without any runRW# noise, this change enables GHC to perform more optimizations when singleton gets inlined than were previously possible.

Copy link
Contributor

@Bodigrim Bodigrim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice trick!

Data/ByteString.hs Outdated Show resolved Hide resolved
Data/ByteString.hs Show resolved Hide resolved
@Bodigrim Bodigrim requested a review from sjakobi February 2, 2022 00:48
@Bodigrim Bodigrim added this to the 0.11.3.0 milestone Feb 3, 2022
@Bodigrim Bodigrim merged commit 8861354 into haskell:master Feb 3, 2022
@Bodigrim
Copy link
Contributor

Bodigrim commented Feb 3, 2022

Thanks!

sjakobi pushed a commit that referenced this pull request Feb 15, 2022
* Make 'singleton' return a slice of a static buffer

* Tweak formatting, update internal documentation

* Elaborate on comment about heap space usage

(cherry picked from commit 8861354)
Bodigrim pushed a commit that referenced this pull request Feb 15, 2022
* Make 'singleton' return a slice of a static buffer

* Tweak formatting, update internal documentation

* Elaborate on comment about heap space usage

(cherry picked from commit 8861354)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants