-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
[Proposal] Use Bitmapped Vector Tries for ImmutableList #25775
Comments
Interesting. @AArnott are you familiar with these? |
I'm not familiar with the proposed data structure myself, but we've heard feedback around trie's being significantly better performers than AVL trees a few times. https://github.com/dotnet/corefx/issues/15413 tracks one such discussion. I can't find it now, but there was another discussion where someone had implemented and given a lot of metrics about their rewrite that looks really promising. |
The bitmapped array trie can have a builder too (I am thinking the use of transient). It doesn't have 0 GC pressure, but it reuses the objects when it can while maintaining the data structure's integrity when using transient. The sets and gets on the trie will be around O(log32 N), and O(1) for push and pop operation. I haven't done an extensive profiling yet, but I have a feeling the trie will have faster access time for most cases, and slightly higher GC. |
@stevenguh Do I understand it correctly that with that implementation, |
See #14477 for an alternate proposal, and tunnelvisionlabs/dotnet-trees#58 for the implementation basis. The baseline implementation is not yet optimized; performance (time) is roughly equivalent to the current AVL trees but memory overhead is dramatically reduced. Aside from avoiding the large object heap, AVL trees are extremely memory-inefficient for these collections. |
@svick Yes, you are correct that insert/remove in general will re-index and re-reallocate the tree. However, there can be some tricks for shifting. |
That may be a non-starter then. Incremental updates of the immutable structures are |
@AArnott "Changing that to O(log n)" did you mean "O(n)" ? |
Yes, thanks. Corrected above. |
Yeah, I think this data structure cannot replace the existing implementation because of its poor insert and remove. I have an implementation here that provide an API compatible alternative to Do you guys think this issue should be close? |
Yes, thanks. |
I'm wondering why aren't we using bitmapped Vector Tries for ImmutableList? Forgive me if this question has been asked.
As far as I know, this data structure is used in Closure's PersistentVector, and ImmutableJS's List. I have a preliminary implementation and it shows that it's faster than the current implementation of the current ImmutableList. For getting sequential or random elements in the list, the trie is about 4 times faster, and for adding elements, it about 3 times faster. Of course, these numbers are the preliminary findings.
For those who don't know what Bitmapped Vector Tries is:
Understanding Clojure's Persistent Vectors
Immutable.js
The text was updated successfully, but these errors were encountered: