-
Notifications
You must be signed in to change notification settings - Fork 54
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
Reduce system call #175
Conversation
ZZhongge
commented
Sep 19, 2024
- for log manifest, remove truncate if the previous size is smaller.
- 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.
src/internal_helper.cc
Outdated
std::string dst_file = filename + ".bak"; | ||
|
||
try { | ||
if (!f_ops->exist(dst_file)) { |
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.
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.
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.
Do you mean if dst_file
does not exist, but *file != nullptr
, all below pwrite
succeeds, but nothing is written? Then yes.
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.
Yes. So, shall we need to rebuild the *file pointer here? Or we can ignore this case?
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.
Yes we should, otherwise backup won't be working.
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.
Looks good to me. Can you answer my reply?
src/internal_helper.cc
Outdated
f_ops->fsync(*file); | ||
} | ||
return s; | ||
} catch (Status s) { |
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.
Should be 4 spaces, currently 3.
*file = nullptr; | ||
} | ||
return s; | ||
} |
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.
Ditto.
src/internal_helper.cc
Outdated
std::string dst_file = filename + ".bak"; | ||
|
||
try { | ||
if (!f_ops->exist(dst_file)) { |
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.
Do you mean if dst_file
does not exist, but *file != nullptr
, all below pwrite
succeeds, but nothing is written? Then yes.
src/internal_helper.cc
Outdated
ctx.data + bytes_to_skip, | ||
length - bytes_to_skip, | ||
bytes_to_skip ) ); |
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.
Indent.