buffer: Use WatermarkFactory to create most WatermarkBuffer instances#14256
Conversation
Also add watermark methods to the Buffer::Instance interface. Signed-off-by: Antonio Vicente <avd@google.com>
alyssawilk
left a comment
There was a problem hiding this comment.
Thanks for driving consistency improvements here!
Couple of thoughts to get you started :-)
include/envoy/buffer/buffer.h
Outdated
| using InstancePtr = std::unique_ptr<Instance>; | ||
|
|
||
| // Informational enum that hints at the buffer's intended use. | ||
| enum class BufferType { |
There was a problem hiding this comment.
Can you comment on what the intended use of this is?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
I wonder if we can reduce the use of the mock buffer factory, and then back this part out. It looks like it's only really "used" in the tcp proxy integration test so I wonder if we could use a normal buffer factory in the base integration test, fix up the tcp proxy test with some comments (it's not likely to change as frequently as the others) and then drop buffertype from this PR. WDYT?
There was a problem hiding this comment.
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
Signed-off-by: Antonio Vicente <avd@google.com>
…fer_factory Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Antonio Vicente <avd@google.com>
antoniovicente
left a comment
There was a problem hiding this comment.
Removed the buffer type argument and figured out how to fix all the tests. PTAL.
include/envoy/buffer/buffer.h
Outdated
| using InstancePtr = std::unique_ptr<Instance>; | ||
|
|
||
| // Informational enum that hints at the buffer's intended use. | ||
| enum class BufferType { |
There was a problem hiding this comment.
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
alyssawilk
left a comment
There was a problem hiding this comment.
Awesome, glad that works out.
All comments optional, so you can merge, or update and will LGTM again.
include/envoy/buffer/buffer.h
Outdated
| */ | ||
| virtual void setWatermarks(uint32_t watermark) PURE; | ||
| /** | ||
| * Returns the configured high watermark. |
There was a problem hiding this comment.
optional, call out the 0 for disabled here as well
| Buffer::InstancePtr write_buffer_; | ||
| // Ensure that if the consumer of the data from this connection isn't | ||
| // consuming, that the connection eventually stops reading from the wire. | ||
| Buffer::InstancePtr read_buffer_; |
There was a problem hiding this comment.
optional, for these new pointers, worth calling out they're never non-null, or overkill?
|
|
||
| std::string toString() const override { return std::string(data_.data() + start_, size_); } | ||
|
|
||
| void setWatermarks(uint32_t) override { |
There was a problem hiding this comment.
followup: maybe worth adding this to the fuzzer when we merge classes.
test/common/buffer/buffer_fuzz.cc
Outdated
| } | ||
| uint32_t highWatermark() const override { return 0; } | ||
| // Returns true if the high watermark callbacks have been called more recently | ||
| // than the low watermark callbacks. |
There was a problem hiding this comment.
optional: can remove this comment given it's an override and commneted in the base class.
Signed-off-by: Antonio Vicente <avd@google.com>
…fer_factory Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Antonio Vicente <avd@google.com>
antoniovicente
left a comment
There was a problem hiding this comment.
Thanks for the review!
| Buffer::InstancePtr write_buffer_; | ||
| // Ensure that if the consumer of the data from this connection isn't | ||
| // consuming, that the connection eventually stops reading from the wire. | ||
| Buffer::InstancePtr read_buffer_; |
|
|
||
| std::string toString() const override { return std::string(data_.data() + start_, size_); } | ||
|
|
||
| void setWatermarks(uint32_t) override { |
include/envoy/buffer/buffer.h
Outdated
| */ | ||
| virtual void setWatermarks(uint32_t watermark) PURE; | ||
| /** | ||
| * Returns the configured high watermark. |
test/common/buffer/buffer_fuzz.cc
Outdated
| } | ||
| uint32_t highWatermark() const override { return 0; } | ||
| // Returns true if the high watermark callbacks have been called more recently | ||
| // than the low watermark callbacks. |
* master: buffer: Optimize the layout of Slices in Buffer::OwnedImpl by removing subclassing and storing slice info directly in the SliceDeque (envoyproxy#14282) gRPC client to be used by ext_proc filter (envoyproxy#14283) http2: Add integration tests for PRIORITY frame flood mitigation for upstream servers (envoyproxy#14328) event: touch watchdog before execution of each post callback and before deferred deletion (envoyproxy#14339) stale: more allowed ops (envoyproxy#14345) stale: more changes (envoyproxy#14344) test: TODO fixup making enable_half_close private envoyproxy#14330) event: Reduce potential for lock contention while executing dispatcher post callbacks. (envoyproxy#14289) stale: fix config (envoyproxy#14337) metrics service sink: generalize the sink and grpc streamer for external use (envoyproxy#13919) wasm: update V8 to v8.8.278.8. (envoyproxy#14298) repo: switch to actions based stale bot (envoyproxy#14335) buffer: Use WatermarkFactory to create most WatermarkBuffer instances (envoyproxy#14256) Signed-off-by: Michael Puncel <mpuncel@squareup.com>
Commit Message:
buffer: Use WatermarkFactory to create most WatermarkBuffer instances
Also add watermark methods to the Buffer::Instance interface.
Risk Level: low, refactoring no functional changes expected.
Testing: covered by existing tests
Docs Changes: n/a
Release Notes: n/a