rrnewton / haskell-lockfree

A collection of different packages for CAS based data structures.
106 stars 25 forks source link

Remove one level of indirection for boxed ChaseLev #74

Open treeowl opened 6 years ago

treeowl commented 6 years ago

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 commented 6 years ago

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

treeowl commented 6 years ago

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

treeowl commented 6 years ago

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

treeowl commented 6 years ago

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

wangbj commented 6 years ago

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