-
Notifications
You must be signed in to change notification settings - Fork 25
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
Remove one level of indirection for boxed ChaseLev #74
base: master
Are you sure you want to change the base?
Conversation
Note: if this looks like a good idea, we should also do the same for the |
Previously, we had an `IORef` holding a mutable vector. We can remove one level of indirection by using an `UnliftedArray` (i.e., an `ArrayArray#`) to hold the array instead. Before: ChaseLevDeque -> MutVar# -> MVector -> Array# Now: ChaseLevDeque -> ArrayArray# -> Array# Note: we previously got the vector size from the `MVector`; now we get it from the `Array#`. In many applications `MVector`s unbox, so getting sizes from them is faster than getting them from `Array#`s. However, this is *not* such an application: we're continually storing and retrieving the vectors.
1cbe99a
to
e583c61
Compare
The `ArrayArray#` solution was fairly pretty, but `ArrayArray#`s have card-marking logic we really don't need. We can `unsafeCoerce#` our way into using a `MutVar#` instead. It would be much nicer if GHC exposed a proper unlifted `MutVar#`, but this way seems to work.
574d8cc
to
ecc85f4
Compare
ecc85f4
to
45eb2ab
Compare
I'm having trouble working out how to update the CI with the necessary |
@RyanGlScott , can you maybe help me figure out this CI issue? |
@wangbj, Ryan Scott thought you might be able to review this. |
@treeowl I’ll try, btw the ci issue should be fixed if you merge master branch |
Previously, we had an
IORef
(holding anMVector
. We canremove one level of indirection by sticking an
Array#
directly into anIORef
.That's not officially supported, but it does work (Edward Kmett has used a similar trick).
Before:
Now:
Note: we previously got the vector size from the
MVector
; nowwe get it from the
Array#
. In many applicationsMVector
s unbox,so getting sizes from them is faster than getting them from
Array#
s.However, this is not such an application: we're continually storing
and retrieving the vectors. I expect the array size checks will be cost the same
as they did before, but array indexing should be faster.