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

Introduce listener TCP connection buffer configuration and implement … #558

Merged
merged 6 commits into from
Mar 13, 2017

Conversation

htuch
Copy link
Member

@htuch htuch commented Mar 10, 2017

…read buffer limits (#150).

Baby steps towards flow control. This patch plumbs the TCP connection buffer limits to the listener
and enforces it on the read buffer only. Later patches will also plumb to the upstream cluster
connection and cover the write buffer (which requires the watermark API).

…read buffer limits (envoyproxy#150).

Baby steps towards flow control. This patch plumbs the TCP connection buffer limits to the listener
and enforces it on the read buffer only. Later patches will also plumb to the upstream cluster
connection and cover the write buffer (which requires the watermark API).
@mattklein123
Copy link
Member

I'm trying to unbury myself. I will look at this later today or this weekend.

@@ -52,6 +52,9 @@ use_original_dst
destination port. If there is no listener associated with the original destination port, the
connection is handled by the listener that receives it. Default is false.

per_connection_buffer_limit_bytes
*(optional, integer)* Soft limit on size of the listener's new connection read and write buffers. If unspecified, an implementation defined default is applied.
Copy link
Contributor

Choose a reason for hiding this comment

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

Please specify the default value here.

return read_buffer_limit_ > 0 && read_buffer_.length() >= read_buffer_limit_;
}
// Mark read buffer ready to read in the event loop. This is used when yielding following
// shouldDrainReadBuffer(). TODO(htuch): While this is the basis for also yielding to other
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: put todo on new line.

Copy link
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

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

Looks good. A few (annoying, sorry) comments.

@@ -52,6 +52,9 @@ use_original_dst
destination port. If there is no listener associated with the original destination port, the
connection is handled by the listener that receives it. Default is false.

per_connection_buffer_limit_bytes
*(optional, integer)* Soft limit on size of the listener's new connection read and write buffers. If unspecified, an implementation defined default is applied (1MB).
Copy link
Member

Choose a reason for hiding this comment

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

nit: 100 col line break

* @return Network::ListenerPtr a new listener that is owned by the caller.
*/
virtual Network::ListenerPtr createListener(Network::ConnectionHandler& conn_handler,
Network::ListenSocket& socket,
Network::ListenerCallbacks& cb,
Stats::Store& stats_store, bool bind_to_port,
bool use_proxy_proto, bool use_orig_dst) PURE;
bool use_proxy_proto, bool use_orig_dst,
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, to ask you to do this, but I have a feeling we are going to keep adding params/options here. (I know soon we will split use_original_dst into use_orginal_port/use_original_address, etc.). Can we define a struct ListenerOptions and just pass that. That way we don't have to change a gazillion mocks and callsites the next time we add a param.

* @return Network::ListenerPtr a new listener that is owned by the caller.
*/
virtual Network::ListenerPtr createListener(Network::ConnectionHandler& conn_handler,
Network::ListenSocket& socket,
Network::ListenerCallbacks& cb,
Stats::Store& stats_store, bool bind_to_port,
bool use_proxy_proto, bool use_orig_dst) PURE;
bool use_proxy_proto, bool use_orig_dst,
size_t per_connection_buffer_limit_bytes) PURE;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of size_t, can we be specific with either uint32_t or uint64_t (probably uint32_t). Same applies all the other places we reference this.

@@ -42,7 +42,12 @@ const std::string Json::Schema::LISTENER_SCHEMA(R"EOF(
"ssl_context" : {"$ref" : "#/definitions/ssl_context"},
"bind_to_port" : {"type": "boolean"},
"use_proxy_proto" : {"type" : "boolean"},
"use_original_dst" : {"type" : "boolean"}
"use_original_dst" : {"type" : "boolean"},
"per_connection_buffer_limit_bytes" : {
Copy link
Member

Choose a reason for hiding this comment

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

"per_connection_read_buffer_limit_bytes" ? Next we will have write high/low watermark so might get confusing?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was planning on using per_connection_buffer_limit_bytes to drive both the watermark for the write buffer (automatically setting low watermark at a fraction like 0.5) and the read buffer, under the assumption that we want to keep config simple and that read/write buffer limits should be somewhat symmetric in general. I know there are scenarios where this isn't true, but this could be reasonable for v1.

Copy link
Member

Choose a reason for hiding this comment

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

OK sounds good.

* Set a soft limit on the size of the read buffer prior to flushing to further stages in the
* processing pipeline.
*/
virtual void setReadBufferLimit(size_t limit) PURE;
Copy link
Member

Choose a reason for hiding this comment

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

uint32_t

return {.bind_to_port_ = true,
.use_proxy_proto_ = false,
.use_original_dst_ = false,
.per_connection_buffer_limit_bytes_ = false};
Copy link
Member

Choose a reason for hiding this comment

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

= 0

@@ -87,6 +98,7 @@ class ConnectionImpl : public virtual Connection,
Address::InstancePtr local_address_;
Buffer::OwnedImpl read_buffer_;
Buffer::OwnedImpl write_buffer_;
size_t read_buffer_limit_ = 0;
Copy link
Member

Choose a reason for hiding this comment

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

uint32_t

@@ -63,6 +63,7 @@ class ConnectionImpl : public virtual Connection,
Ssl::Connection* ssl() override { return nullptr; }
State state() override;
void write(Buffer::Instance& data) override;
void setReadBufferLimit(size_t limit) override { read_buffer_limit_ = limit; }
Copy link
Member

Choose a reason for hiding this comment

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

uint32_t

@@ -47,6 +47,7 @@ class ListenerImpl : public Listener {
const bool use_proxy_proto_;
ProxyProtocol proxy_protocol_;
const bool use_original_dst_;
const size_t per_connection_buffer_limit_bytes_;
Copy link
Member

Choose a reason for hiding this comment

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

Just have a ListenerOptions as a member var and then you can just copy it in via passed in options.

@mattklein123 mattklein123 merged commit fd58242 into envoyproxy:master Mar 13, 2017
@htuch htuch deleted the flow-control-config branch March 14, 2017 15:09
lambdai pushed a commit to lambdai/envoy-dai that referenced this pull request Jul 21, 2020
Signed-off-by: Shikugawa <Shikugawa@gmail.com>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Because we shared the `release` bazel config between both iOS and
Android, Android builds were incorrectly having llvm bitcode enabled for
them.

Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.com>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
Because we shared the `release` bazel config between both iOS and
Android, Android builds were incorrectly having llvm bitcode enabled for
them.

Signed-off-by: Keith Smiley <keithbsmiley@gmail.com>
Signed-off-by: JP Simard <jp@jpsim.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.

3 participants