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

Pass the order to PreReleaseCallback #5381

Closed

Conversation

maysamyabandeh
Copy link
Contributor

The patch passes to PreReleaseCallback the order among other callbacks in the same write thread. The application could make use of it to reduce the overhead of operations that needs to be done once per write group rather than once per writer. Example is overhead of locking prepared_mutex_ in WritePrepared transactions.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maysamyabandeh has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@maysamyabandeh has updated the pull request. Re-import the pull request

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have an example how these counters are used in the callback? Without an extra use case, I suggest we hold the API change.

total_byte_size = WriteBatchInternal::AppendedByteSize(
total_byte_size, WriteBatchInternal::ByteSize(writer->batch));
if (writer->pre_release_callback) {
pre_release_callback_cnt++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure which one is cheaper, ++, or this branching. I would simplify the code by having a blindly incremented variable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would incorrect because if a writer doesn't have pre_release_callback, then the last pre_release_callback is labeled incorrectly.

size_t total_byte_size = 0;
for (auto* writer : write_group) {
if (writer->CheckCallback(this)) {
total_byte_size = WriteBatchInternal::AppendedByteSize(
total_byte_size, WriteBatchInternal::ByteSize(writer->batch));
if (writer->pre_release_callback) {
pre_release_callback_cnt++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I feel the code will be simpler if we have a blindly incremented counter.

@maysamyabandeh
Copy link
Contributor Author

Do you have an example how these counters are used in the callback? Without an extra use case, I suggest we hold the API change.

I have, but it has a lot of txn details and to be reviewed by someone else. I am currently polishing it. I will submit it as a separate PR soon for you to see how these are used in a real use case.

@maysamyabandeh
Copy link
Contributor Author

Copy link
Contributor

@siying siying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I would wait for the PR of using it to be out before approving it.

@maysamyabandeh
Copy link
Contributor Author

Merged into #5420

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants