Skip to content

buffer: Use WatermarkFactory to create most WatermarkBuffer instances#14256

Merged
antoniovicente merged 9 commits intoenvoyproxy:masterfrom
antoniovicente:use_watermark_buffer_factory
Dec 8, 2020
Merged

buffer: Use WatermarkFactory to create most WatermarkBuffer instances#14256
antoniovicente merged 9 commits intoenvoyproxy:masterfrom
antoniovicente:use_watermark_buffer_factory

Conversation

@antoniovicente
Copy link
Contributor

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

Also add watermark methods to the Buffer::Instance interface.

Signed-off-by: Antonio Vicente <avd@google.com>
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Thanks for driving consistency improvements here!

Couple of thoughts to get you started :-)

using InstancePtr = std::unique_ptr<Instance>;

// Informational enum that hints at the buffer's intended use.
enum class BufferType {
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 comment on what the intended use of this is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

Choose a reason for hiding this comment

The 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.
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

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>
Signed-off-by: Antonio Vicente <avd@google.com>
Signed-off-by: Antonio Vicente <avd@google.com>
Copy link
Contributor Author

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

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

Removed the buffer type argument and figured out how to fix all the tests. PTAL.

using InstancePtr = std::unique_ptr<Instance>;

// Informational enum that hints at the buffer's intended use.
enum class BufferType {
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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

alyssawilk
alyssawilk previously approved these changes Dec 8, 2020
Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Awesome, glad that works out.
All comments optional, so you can merge, or update and will LGTM again.

*/
virtual void setWatermarks(uint32_t watermark) PURE;
/**
* Returns the configured high watermark.
Copy link
Contributor

Choose a reason for hiding this comment

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

optional, call out the 0 for disabled here as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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_;
Copy link
Contributor

Choose a reason for hiding this comment

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

optional, for these new pointers, worth calling out they're never non-null, or overkill?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


std::string toString() const override { return std::string(data_.data() + start_, size_); }

void setWatermarks(uint32_t) override {
Copy link
Contributor

Choose a reason for hiding this comment

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

followup: maybe worth adding this to the fuzzer when we merge classes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO

}
uint32_t highWatermark() const override { return 0; }
// Returns true if the high watermark callbacks have been called more recently
// than the low watermark callbacks.
Copy link
Contributor

Choose a reason for hiding this comment

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

optional: can remove this comment given it's an override and commneted in the base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

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>
Copy link
Contributor Author

@antoniovicente antoniovicente left a comment

Choose a reason for hiding this comment

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

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_;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


std::string toString() const override { return std::string(data_.data() + start_, size_); }

void setWatermarks(uint32_t) override {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TODO

*/
virtual void setWatermarks(uint32_t watermark) PURE;
/**
* Returns the configured high watermark.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
uint32_t highWatermark() const override { return 0; }
// Returns true if the high watermark callbacks have been called more recently
// than the low watermark callbacks.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

@alyssawilk alyssawilk left a comment

Choose a reason for hiding this comment

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

Awesome!

@antoniovicente antoniovicente merged commit 61d80ba into envoyproxy:master Dec 8, 2020
mpuncel added a commit to mpuncel/envoy that referenced this pull request Dec 11, 2020
* 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>
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.

2 participants