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

Remove one level of indirection for boxed ChaseLev #74

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

treeowl
Copy link

@treeowl treeowl commented Jul 21, 2018

Previously, we had an IORef (holding an MVector. We can
remove one level of indirection by sticking an Array# directly into an IORef.
That's not officially supported, but it does work (Edward Kmett has used a similar trick).

Before:

 ChaseLevDeque -> MutVar# -> MVector -> Array#

Now:

 ChaseLevDeque -> MutVar# -> Array#

Note: we previously got the vector size from the MVector; now
we get it from the Array#. In many applications MVectors 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.

@treeowl
Copy link
Author

treeowl commented Jul 21, 2018

Note: if this looks like a good idea, we should also do the same for the Unboxed version.

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.
@treeowl treeowl force-pushed the less-indirection branch from 1cbe99a to e583c61 Compare July 21, 2018 22:37
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.
@treeowl treeowl force-pushed the less-indirection branch 2 times, most recently from 574d8cc to ecc85f4 Compare July 22, 2018 20:08
@treeowl treeowl force-pushed the less-indirection branch from ecc85f4 to 45eb2ab Compare July 22, 2018 20:16
@treeowl
Copy link
Author

treeowl commented Jul 22, 2018

I'm having trouble working out how to update the CI with the necessary primitive version. Any help would be appreciated.

@treeowl
Copy link
Author

treeowl commented Jul 22, 2018

@RyanGlScott , can you maybe help me figure out this CI issue?

@treeowl
Copy link
Author

treeowl commented Aug 8, 2018

@wangbj, Ryan Scott thought you might be able to review this.

@wangbj
Copy link
Contributor

wangbj commented Aug 8, 2018

@treeowl I’ll try, btw the ci issue should be fixed if you merge master branch

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.

2 participants