aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/iomgr/tcp_posix.cc
diff options
context:
space:
mode:
authorGravatar Soheil Hassas Yeganeh <soheil@google.com>2018-10-11 15:27:27 -0400
committerGravatar Soheil Hassas Yeganeh <soheil@google.com>2018-10-11 15:27:27 -0400
commitc8d5db17173318ff5efe3e0721bca3340251f738 (patch)
treead870acecce5b60eb1f17d70d9f5ab97c07c75de /src/core/lib/iomgr/tcp_posix.cc
parent73c99f890a42479bc82e2c0ab132a97cbcf8434a (diff)
Update TCP read estimates as soon as we read the whole buffer.
If we have a continous stream of bytes on the socket, we will never grow the buffer, because we will never get EAGAIN, and call finish. This is a serious performance issue, which can be misued. As soon as we have a full buffer, update the estimate.
Diffstat (limited to 'src/core/lib/iomgr/tcp_posix.cc')
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index e40bf81c90..7fd0e91346 100644
--- a/src/core/lib/iomgr/tcp_posix.cc
+++ b/src/core/lib/iomgr/tcp_posix.cc
@@ -468,7 +468,9 @@ static void tcp_do_read(grpc_tcp* tcp) {
GRPC_STATS_INC_TCP_READ_SIZE(read_bytes);
add_to_estimate(tcp, static_cast<size_t>(read_bytes));
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
- if (static_cast<size_t>(read_bytes) < tcp->incoming_buffer->length) {
+ if (static_cast<size_t>(read_bytes) == tcp->incoming_buffer->length) {
+ finish_estimate(tcp);
+ } else if (static_cast<size_t>(read_bytes) < tcp->incoming_buffer->length) {
grpc_slice_buffer_trim_end(
tcp->incoming_buffer,
tcp->incoming_buffer->length - static_cast<size_t>(read_bytes),