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

Avoid duplicate writes in Batch #18

Closed
ethanfrey opened this issue Feb 11, 2018 · 3 comments
Closed

Avoid duplicate writes in Batch #18

ethanfrey opened this issue Feb 11, 2018 · 3 comments

Comments

@ethanfrey
Copy link
Contributor

ethanfrey commented Feb 11, 2018

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.

@alpe
Copy link
Contributor

alpe commented Apr 2, 2019

Sorry, hit the wrong button and accidentally closed this issue.

@ruseinov
Copy link
Contributor

ruseinov commented Apr 2, 2019

It sounds like a nice optimisation, but I'm not sure what this entails code-wise yet.
I'm imagining it might turn out quite hectic, because we have so many different things we could be writing at the same time, but really hard for me to estimate before I start touching this code.

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 :)

@ethanfrey
Copy link
Contributor Author

This was a note-to-self over a year ago.
I'd tackle it in a day if I had time to focus on the orm layer

@ruseinov ruseinov mentioned this issue Apr 4, 2019
5 tasks
@husio husio added the 🚧 label Aug 12, 2019
@husio husio removed the 🚧 label Oct 21, 2019
@husio husio closed this as completed Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants