-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
Add public API WriteWithCallback
to support custom callbacks
#12603
Conversation
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.
How does the user specify the callback? In WriteOptions
perhaps?
Yeah, that's a good question. |
Yeah, |
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.
LGTM! Thanks for the PR and quick turnaround
Thank you for the quick review! |
9fce675
to
477b6b5
Compare
WriteWithCallback
to support custom callbacks
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.
LGTM. A couple of minor nits.
477b6b5
to
b359e4f
Compare
b359e4f
to
afa1f71
Compare
@jowlyzhang has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@jowlyzhang merged this pull request in fc59d8f. |
This PR adds a
DB::WriteWithCallback
API that does the same things asDB::Write
while takes an argumentUserWriteCallback
to execute custom callback functions during the write.We currently support two types of callback functions:
OnWriteEnqueued
andOnWalWriteFinish
. The former is invoked after the write is enqueued, and the later is invoked after WAL write finishes when applicable.These callback functions are intended for users to use to improve synchronization between concurrent writes, their execution is on the write's critical path so it will impact the write's latency if not used properly. The documentation for the callback interface mentioned this and suggest user to keep these callback functions' implementation minimum.
Although transaction interfaces' writes doesn't yet allow user to specify such a user write callback argument, the
DBImpl::Write*
type of APIs do not differentiate between regular DB writes or writes coming from the transaction layer when it comes to supporting thisUserWriteCallback
. These callbacks works for all the write modes including: default write mode, Options.two_write_queues, Options.unordered_write, Options.enable_pipelined_writeTest plan:
Added unit test in ./write_callback_test