-
Notifications
You must be signed in to change notification settings - Fork 5.5k
buffer: Use WatermarkFactory to create most WatermarkBuffer instances #14256
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
Changes from 1 commit
7b61dd5
df96525
095228d
cb73e07
8c68c12
5b5a99a
8be2847
a16a68f
9c66978
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -393,10 +393,42 @@ class Instance { | |
| template <typename T, size_t Size = sizeof(T)> void writeBEInt(T value) { | ||
| writeInt<ByteOrder::BigEndian, T, Size>(value); | ||
| } | ||
|
|
||
| /** | ||
| * Set the buffer's high watermark. The buffer's low watermark is implicitly set to half the high | ||
| * watermark. Setting the high watermark to 0 disables watermark functionality. | ||
| * @param watermark supplies the buffer high watermark size threshold, in bytes. | ||
| */ | ||
| virtual void setWatermarks(uint32_t watermark) PURE; | ||
| /** | ||
| * Returns the configured high watermark. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. optional, call out the 0 for disabled here as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| */ | ||
| virtual uint32_t highWatermark() const PURE; | ||
| /** | ||
| * Determine if the buffer watermark trigger condition is currently set. The watermark trigger is | ||
| * set when the buffer size exceeds the configured high watermark and is cleared once the buffer | ||
| * size drops to the low watermark. | ||
| * @return true if the buffer size once exceeded the high watermark and hasn't since dropped to | ||
| * the low watermark. | ||
| */ | ||
| virtual bool highWatermarkTriggered() const PURE; | ||
| }; | ||
|
|
||
| using InstancePtr = std::unique_ptr<Instance>; | ||
|
|
||
| // Informational enum that hints at the buffer's intended use. | ||
| enum class BufferType { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you comment on what the intended use of this is?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a comment. If you're curious, here is the first followup change that depends on this. The end goal is to use this in e2e tests for the fix to #11370 master...antoniovicente:e2e_h2_high_buffering__pre_shared_ptr_factory
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, so the intended use is to avoid a bunch of nasty test changes and potentially nasty test maintenance issues by switching more buffers to mocks? I'd like to avoid this if we can.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm really not a fan of mock buffers, so no - I am not planning to increase mock buffer use. I removed the BufferType argument and made the necessary changes to fix broken tests, see 5b5a99a The change to the default behavior of the mock watermark factory created by the mock dispatcher fixes a bunch of small tests that use MockConnection |
||
| // Per-connection input buffer used to read directly from an IoHandle. | ||
| Read, | ||
|
antoniovicente marked this conversation as resolved.
Outdated
|
||
| // Per-connection output buffer used to write directly to an IoHandle. | ||
| Output, | ||
| // Per-stream HTTP output buffer. In the case of HTTP2 and HTTP3/QUIC, this buffer participates in | ||
| // per-stream flow control. | ||
| HttpStreamOutput, | ||
| // Internal buffers used for internally by filters or other components of the IO pipeline. | ||
| Internal, | ||
| }; | ||
|
|
||
| /** | ||
| * A factory for creating buffers which call callbacks when reaching high and low watermarks. | ||
| */ | ||
|
|
@@ -412,7 +444,7 @@ class WatermarkFactory { | |
| * high watermark. | ||
| * @return a newly created InstancePtr. | ||
|
antoniovicente marked this conversation as resolved.
|
||
| */ | ||
| virtual InstancePtr create(std::function<void()> below_low_watermark, | ||
| virtual InstancePtr create(BufferType buffer_type, std::function<void()> below_low_watermark, | ||
| std::function<void()> above_high_watermark, | ||
| std::function<void()> above_overflow_watermark) PURE; | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.