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

plutus-tx: add red-black tree implementation for Maps, again #5697

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michaelpj
Copy link
Contributor

It still sucks. It manages to sometimes be better, which is cool, but overall it's quite a lot worse and it uses a lot of space. So still not worth it unless we somehow figure out a way to make it much faster.

Amusingly, with this version the dumb equality function is almost as good as @effectfully 's clever one. Also toList produces an ordered list, so maybe we could optimize equality further, IDK.

I spent a bit of time on it to get it this fast, mostly fusing things together so we don't do multiple passes. biFoldr is the workhorse.

Some things I have not tried:

  • Pass around k -> k -> Ordering instead of Ord k, since apparently our Ord class has a ton of members
  • Manually specialise to ByteString keys
  • Come up with a fast way to iterate through the entries of two maps in order without either materializing them into lists or doing lots of lookups (which is what the current biFoldr does effectively by calling split)
  • Actually profiling to see what's happening instead of just looking at it.

This can also be used for Set, I'll add an implementation in due course.

Deletion is still unimplemented, since it's quite non-trivial.
@michaelpj michaelpj added the EXPERIMENT Experiments that we probably don't want to merge label Jan 3, 2024
@michaelpj michaelpj marked this pull request as draft January 3, 2024 15:20
@zeme-wana zeme-wana force-pushed the master branch 2 times, most recently from a161078 to db5cabb Compare July 9, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EXPERIMENT Experiments that we probably don't want to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant