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

Add flying_bytes for throttling. #542

Merged
merged 4 commits into from
Oct 17, 2024
Merged

Conversation

ZZhongge
Copy link
Contributor

  1. Add track for flying bytes
  2. Add a new throttling flying bytes

2. Add a new throttling flying bytes
/**
* Current flying bytes of append entry requests.
*/
std::atomic<size_t> flying_bytes;
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also use int64_t.

@@ -329,6 +346,7 @@ private:
ptr<req_msg>& req,
ptr<rpc_result>& pending_result,
bool streaming,
size_t total_size,
Copy link
Contributor

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.

/**
* Max flying bytes we allow. If it is zero, we don't use it as throttling.
*/
ulong max_flying_bytes_;
Copy link
Contributor

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_.

Comment on lines 310 to 312
(last_streamed_log_idx + 1) ||
( params->max_flying_bytes_ &&
p->get_flying_bytes() > params->max_flying_bytes_)) {
Copy link
Contributor

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_)) {

}

void flying_bytes_sub(size_t total_size) {
flying_bytes.fetch_sub(total_size);
Copy link
Contributor

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.

@greensky00 greensky00 merged commit e530af3 into eBay:streaming Oct 17, 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