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

Reduce system call #175

Merged
merged 2 commits into from
Sep 24, 2024
Merged

Reduce system call #175

merged 2 commits into from
Sep 24, 2024

Conversation

ZZhongge
Copy link
Contributor

  1. for log manifest, remove truncate if the previous size is smaller.
  2. for backup log manifest, not open and close file in each call.

1. for log manifest, remove truncate if the previous size is smaller.
2. for backup log manifest, not open and close file in each call.
std::string dst_file = filename + ".bak";

try {
if (!f_ops->exist(dst_file)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Shall we need to check whether the file exist in each call? I tested it and even if the file is removed, all system call will success, but no file is persisted.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean if dst_file does not exist, but *file != nullptr, all below pwrite succeeds, but nothing is written? Then yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. So, shall we need to rebuild the *file pointer here? Or we can ignore this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes we should, otherwise backup won't be working.

Copy link
Contributor

@greensky00 greensky00 left a comment

Choose a reason for hiding this comment

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

Looks good to me. Can you answer my reply?

f_ops->fsync(*file);
}
return s;
} catch (Status s) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 4 spaces, currently 3.

*file = nullptr;
}
return s;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

std::string dst_file = filename + ".bak";

try {
if (!f_ops->exist(dst_file)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean if dst_file does not exist, but *file != nullptr, all below pwrite succeeds, but nothing is written? Then yes.

Comment on lines 386 to 388
ctx.data + bytes_to_skip,
length - bytes_to_skip,
bytes_to_skip ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Indent.

@greensky00 greensky00 merged commit fe88825 into eBay:master Sep 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants