Copilot commented on code in PR #14034:
URL: https://github.com/apache/trafficserver/pull/14034#discussion_r4530925715
##########
doc/admin-guide/files/records.yaml.en.rst:
##########
@@ -6428,6 +6428,38 @@ removed in the future without prior notice.
Specified the maximum outgoing UDP payload size.
+.. ts:cv:: CONFIG proxy.config.quic.max_stream_send_buffer INT 1048576
+ :units: bytes
+
+ The most stream data, in bytes, that |TS| hands the OpenSSL QUIC stack for
one
+ stream at a time. The count covers data not yet sent and data sent but not
yet
+ acknowledged by the client. It applies to the OpenSSL QUIC backend only.
+
+ This trades throughput against memory. A stream cannot have more than this
much
+ data in flight, so it caps one stream's rate at about this value divided by
the
+ round trip time: the default allows about 840 Mbps per stream at a 10 ms
round
+ trip. OpenSSL grows a stream's send buffer to fit what it is given, up to
its
+ own limit of 6 MB, and does not shrink it again until the stream ends, so
each
+ busy stream can keep up to this much memory for its lifetime. See also
+ :ts:cv:`proxy.config.quic.max_connection_send_buffer`.
+
+.. ts:cv:: CONFIG proxy.config.quic.max_connection_send_buffer INT 4194304
+ :units: bytes
+
+ The most stream data, in bytes, that |TS| hands the OpenSSL QUIC stack for
all
+ the streams of one connection together, counted the same way as
+ :ts:cv:`proxy.config.quic.max_stream_send_buffer`. It applies to the
OpenSSL QUIC
+ backend only.
+
+ This bounds the memory one connection's send buffers can take, which would
+ otherwise grow with the number of streams the client opens. A lower value
saves
+ memory; a value below the per-stream limit times the number of busy streams
on
+ a connection lowers their combined rate. Each stream that has data to send
may
Review Comment:
This limits buffered/unacknowledged data, not allocated send-buffer memory:
the connection counter sums `SSL_get_stream_write_buf_used()`, and grown
buffers do not shrink until their streams end, as documented above. Multiple
still-open streams can therefore retain large buffers after their data is
acknowledged while their combined used count remains below this limit. Please
clarify this distinction so operators do not treat the record as a hard memory
bound.
##########
src/iocore/net/OpenSSLQUICNetVConnection.cc:
##########
@@ -893,12 +988,39 @@ QUICNetVConnection::stream_write_capacity(QUICStreamId
stream_id)
return -1;
}
- uint64_t avail = 0;
- if (SSL_get_stream_write_buf_avail(it->second, &avail) == 1) {
- return std::min<uint64_t>(avail, 16 * 1024);
+ // OpenSSL starts a stream's send buffer small and grows it only when one
write
+ // offers more than the buffer has free. The buffer keeps data until the peer
+ // acknowledges it, so offering no more than the free room would hold the
stream to
+ // one initial buffer in flight. Offer room up to the configured limits for
the
+ // stream and for the connection instead; OpenSSL takes less if the stream's
flow
+ // control window allows less.
+ uint64_t size = 0;
+ uint64_t used = 0;
+ if (SSL_get_stream_write_buf_size(it->second, &size) != 1 ||
SSL_get_stream_write_buf_used(it->second, &used) != 1) {
+ unsigned long const error = ERR_get_error();
+ QUICConDebug("stream %" PRIu64 ": cannot read OpenSSL's send buffer state:
%s", stream_id, ERR_error_string(error, nullptr));
+ return -1;
}
- return 0;
+ // OpenSSL frees the send buffer once the peer has acknowledged everything
up to the
+ // FIN, and when the sending side is reset. Either way nothing more can be
written. A
+ // write can process incoming packets, so the reset may arrive partway
through a pass.
+ if (size == 0) {
+ return this->_openssl_stream_write_closed(stream_id, it->second) ? -1 : 0;
+ }
+
+ // Once the connection limit binds, room frees a little at a time as the
peer acknowledges
+ // data, and every pass offers it to the streams in the same order. Holding
each stream with
+ // data to an equal share of the limit leaves that room to the streams below
their share, so
+ // no stream can take it all while another waits.
+ uint64_t const share = std::max(this->_max_connection_send_buffer /
std::max<uint64_t>(this->_openssl_streams_with_data, 1),
+ OPENSSL_MIN_STREAM_SEND_SHARE);
+ uint64_t const stream_limit = std::min(this->_max_stream_send_buffer,
share);
+ uint64_t const stream_room = used < stream_limit ? stream_limit - used :
0;
+ uint64_t const connection_room = this->_openssl_send_buffered <
this->_max_connection_send_buffer ?
+ this->_max_connection_send_buffer -
this->_openssl_send_buffered :
+ 0;
+ return std::min(stream_room, connection_room);
Review Comment:
A partially accepted block can bypass the new connection limit:
`QUICStream::send_data()` caps retries by the event budget but uses the current
capacity only as a positive/zero check (`QUICStream.cc:170–200`). If other
streams consume room between retries, it can submit and accept more bytes than
this function allows. Cap pending-block submissions by the latest capacity as
well as the event budget, keep FIN off shortened submissions, and add a
regression test where capacity decreases between retries.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]