-
Notifications
You must be signed in to change notification settings - Fork 132
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
Refactor write batching #143
Conversation
Avoid holding transaction-specific state in the handler, which must then be protected by multiple locks. This is error prone and is a potential performance bottleneck. Instead, extract batch writes to a separate struct for clarity, and maintain the batch write state in the stub, which is unique to a specific transaction so requires no locking. The stub (and associated batch write state) is also discarded after a transaction invocation so there is no risk of memory leaks due to redundant batch write state being left in the shared handler. Signed-off-by: Mark S. Lewis <[email protected]>
I'm not sure I trust the unit tests enough to be confident this refactor maintains exactly the previous behaviour. It needs a good eyeball and perhaps trying out in actual use. Presented for review at least to get feedback on the significantly simplified implementation approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far, some important functionality has been lost. Requires very careful testing.
I've have pushed an additional commit to address the bugs you highlighted and the key issue that I identified. I think the fact that significant functional differences are not caught by the unit tests while refactoring the implementation highlights that the unit tests are insufficient. |
- Check whether batching is supported when starting a batch. - Better keying of batched writes. Signed-off-by: Mark S. Lewis <[email protected]>
ab11b92
to
ce5a571
Compare
Signed-off-by: Mark S. Lewis <[email protected]>
f8cfe3c
to
126c4a8
Compare
When I wrote, I added some by analogy. Probably not enough. Can you prepare a list of those unit tests that you would like to see. And as soon as we finish with your pr, I will implement them. |
Every comment you have raised on this PR identifying a behavioural issue really should have been caught by unit tests. That would be a good list to work with. |
- Preallocate writes slice. Signed-off-by: Mark S. Lewis <[email protected]>
Avoid holding transaction-specific state in the handler, which must then be protected by multiple locks. This is error prone and is a potential performance bottleneck. Instead, extract batch writes to a separate struct for clarity, and maintain the batch write state in the stub, which is unique to a specific transaction so requires no locking.
The stub (and associated batch write state) is also discarded after a transaction invocation so there is no risk of memory leaks due to redundant batch write state being left in the shared handler.