-
Notifications
You must be signed in to change notification settings - Fork 8
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
Removing multiple keys for MapM with >= 1024 entries panics #4
Comments
Thank you very much for taking the time to report this and provide a test case. I think I have found the bug, and I am working on adding a test to the automated test suite to check for this case. As soon as I'm satisfied that I've actually found and fixed the bug I will release a new version. |
None of the keys in your update actually exist in the map, and that is why the bug was triggered, the model check never considered that case 🤦 .
My sincere apologies for this bug. |
Thanks, it works now. FYI, as a side-note, it turned out that in my use-case (avg number of elements in map ~6000 and average update - sorted sequence of removals and modifications of ~22 elements) |
It's unlikely it would be much faster. update_cow uses mutation, and for your case there isn't going to be anything faster than that. update_many can really fly when it's able to replace entire chunks at a time, but if elements in chunks are being updated then mutation will always be faster. BTreeMap is pretty much the lower bound of performance for this kind of data structure (it's very very well optimized), and update_cow is within 2 or 3x of it, so there isn't much more performance to get. I wish I could grind it down such that it's as fast as BTreeMap for every operation, but there is some overhead involved in making it immutable, and so I'm pretty happy with 2-3x for COW operations. |
I should also mention that if update/insert performance matters to you more than lookup performance then you should try a smaller chunk size. MapS is a good place to start, however you can try any chunk size you like. |
I found a scenario of initializing map content and updating it (just removals) that causes panic, the repo scenario is here:
https://github.com/kskalski/snippets/blob/master/immutable_chunklist_bug/src/main.rs
roughly the code like that:
ends up with
feeding it with any shorter initial set or update list or modifying the keys widely seem to no longer cause the panic.
The text was updated successfully, but these errors were encountered: