-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
[chttp2] Fix bug in timeout encoding #34751
Conversation
Automated fix for refs/heads/smol
}; | ||
|
||
class TimeoutCompressorImpl { | ||
public: | ||
void EncodeWith(absl::string_view key, Timestamp deadline, Encoder* encoder); | ||
|
||
private: | ||
std::vector<PreviousTimeout> previous_timeouts_; | ||
enum { kNumPreviousValues = 5 }; |
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.
why enum?
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.
in C++98 this was the way to say static constexpr const kNumPreviousValues = 5;
... and:
- old habits are hard to break :)
- having typed that I'm not clear we've made progress
still, updated to the more modern syntax
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.
sorry, i am afraid that this problem is important or not ?i am reall sorry to bother
double ratio = timeout.RatioVersus(it->timeout); | ||
for (size_t i = 0; i < kNumPreviousValues; i++) { | ||
const auto& previous = previous_timeouts_[i]; | ||
if (!table.ConvertableToDynamicIndex(previous.index)) continue; |
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.
will this if condition return if previous_timeouts_[i] has not been populated yet, like if the index is 0? What does ConvertableToDynamicIndex check for?
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.
added some comments around the safety of this
// be considered earlier. | ||
std::swap(*it, *previous_timeouts_.begin()); | ||
if (ratio > -3 && ratio <= 0) { | ||
encoder->EmitIndexed(table.DynamicIndex(previous.index)); |
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.
Will there be any negative effects to emitting these timeouts directly rather than adding to the queue first? What if there are a lot of timeouts like this?
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.
If we hit this sufficiently frequently this could cause some significant hpack table churn... evidence so far says that we'll not hit it frequently, but it'll be something to watch.
Just the right combination of timeout values could lead to a large amount of growth in the timeout cache, leading to high memory usage and high cpu utilization on the client attempting that encoding.
Fix: cap the number of cached timeout values we'll consider to a very small number (I'm choosing five).
Add a fuzzer that ensures that we're actually respecting the limits of inaccuracy we're imposing upon ourselves.