aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Soheil Hassas Yeganeh <soheil@cs.toronto.edu>2018-10-12 11:39:25 -0400
committerGravatar GitHub <noreply@github.com>2018-10-12 11:39:25 -0400
commit5b7c0933867f05ce94b0f373224b4fb3ed15d3c2 (patch)
tree7f3579a5fcb8775a2dce68a129d6f1c2a672d14b
parent8510e7f7d2410fa7e1d6abbfca7bfe320bc7a46d (diff)
parent78434ad30360583ab4f71c1aca1dc3e850a31e98 (diff)
Merge pull request #16838 from soheilhy/worktree-tcp-read
Simple optimizations in TCP read
-rw-r--r--src/core/lib/iomgr/tcp_posix.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc
index e40bf81c90..aa2704ce26 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),
@@ -498,7 +500,7 @@ static void tcp_read_allocation_done(void* tcpp, grpc_error* error) {
static void tcp_continue_read(grpc_tcp* tcp) {
size_t target_read_size = get_target_read_size(tcp);
- if (tcp->incoming_buffer->length < target_read_size &&
+ if (tcp->incoming_buffer->length < target_read_size / 2 &&
tcp->incoming_buffer->count < MAX_READ_IOVEC) {
if (grpc_tcp_trace.enabled()) {
gpr_log(GPR_INFO, "TCP:%p alloc_slices", tcp);