-
Notifications
You must be signed in to change notification settings - Fork 46
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
Avoid duplicate writes in Batch #18
Comments
Sorry, hit the wrong button and accidentally closed this issue. |
It sounds like a nice optimisation, but I'm not sure what this entails code-wise yet. But, if we don't have anything more urgent to do - it's going to be interesting to tackle. On the other hand, logically, when we have a batch transaction which has a cost of sum of all the transactions - the i/o expenses have already been paid for :) |
This was a note-to-self over a year ago. |
Make a new batch type that optimizes on write.
It is often that multiple operations may write to the same key (eg. deduct fee from account X, move coin from account X). We want to allow the code to be independent, but do not want to write twice to the underlying merkle tree (which is expensive).
We can add a
DedupBatch
, that on write will first remove all duplicates, leaving only the last set/delete that effects a given key. It can scan from the last operation, and copy operations into a clean buffer. If the key was not yet seen, add to clean buffer from the end. Then slice the clean buffer to size.The text was updated successfully, but these errors were encountered: