-
Notifications
You must be signed in to change notification settings - Fork 100
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
Avoid boxing arrays #230
Avoid boxing arrays #230
Conversation
59d81ac
to
725c929
Compare
Previously, we used a lot of things that looked like runST (act >>= unsafeFreeze) The trouble is that GHC can't unbox past the `runRW#` primitive that `runST` is based on. So this actually allocates an `Array` constructor which we will then throw away immediately. The way to avoid this is to call `runRW#` manually to produce a raw `SmallArray#`, then apply the `Array` constructor on the outside.
725c929
to
467d161
Compare
I'll be out of town until Tuesday next week, but I can take a look when I get back. |
We need to see if this is still necessary on GHC HEAD. @bgamari just recently implemented and merged a GHC patch to try to fix this sort of thing. |
I'll mark this PR as a draft then to signal that it's not currently waiting for a review. |
I have rebased this PR on my I'll take a look at the perf implications once GHC 9.2.2 is released.
@treeowl In which GHC version was this work released? |
I don't remember. And the new stuff sometimes just defeats what we want to do. So everything needs to be pored over. |
I have opened #375 to finish this. |
Previously, we used a lot of things that looked like
The trouble is that GHC can't unbox past the
runRW#
primitivethat
runST
is based on. So this actually allocates anArray
constructor which we will then throw away immediately.
The way to avoid this is to call
runRW#
manually to producea raw
SmallArray#
, then apply theArray
constructor on theoutside.