-
Notifications
You must be signed in to change notification settings - Fork 241
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 flying_bytes for throttling. #542
Conversation
ZZhongge
commented
Oct 15, 2024
- Add track for flying bytes
- Add a new throttling flying bytes
2. Add a new throttling flying bytes
include/libnuraft/peer.hxx
Outdated
/** | ||
* Current flying bytes of append entry requests. | ||
*/ | ||
std::atomic<size_t> flying_bytes; |
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.
bytes_in_flight_
sounds better. Rename related functions and logs too.
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.
Also use int64_t
.
include/libnuraft/peer.hxx
Outdated
@@ -329,6 +346,7 @@ private: | |||
ptr<req_msg>& req, | |||
ptr<rpc_result>& pending_result, | |||
bool streaming, | |||
size_t total_size, |
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.
The name is ambiguous (total size of what?). I'd rather renaming it req_size_bytes
.
include/libnuraft/raft_params.hxx
Outdated
/** | ||
* Max flying bytes we allow. If it is zero, we don't use it as throttling. | ||
*/ | ||
ulong max_flying_bytes_; |
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.
This parameter will be used for streaming mode only right? then max_bytes_in_flight_in_stream_
.
src/handle_append_entries.cxx
Outdated
(last_streamed_log_idx + 1) || | ||
( params->max_flying_bytes_ && | ||
p->get_flying_bytes() > params->max_flying_bytes_)) { |
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
if (max_gap_in_stream + p->get_next_log_idx() <=
(last_streamed_log_idx + 1) ||
(params->max_flying_bytes_ &&
p->get_flying_bytes() > params->max_flying_bytes_)) {
include/libnuraft/peer.hxx
Outdated
} | ||
|
||
void flying_bytes_sub(size_t total_size) { | ||
flying_bytes.fetch_sub(total_size); |
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.
Can you add the below
assert(flying_bytes >= 0);
right after this line? so as to catch any bug that corrupts this number during the test.