From 78434ad30360583ab4f71c1aca1dc3e850a31e98 Mon Sep 17 00:00:00 2001 From: Soheil Hassas Yeganeh Date: Thu, 11 Oct 2018 15:28:49 -0400 Subject: [PATCH] Do not wait for allocation if buffer is less than half the target. We overallocate by 2x for target. Unless buffer is more than half full, we should not delay read for more allocation. --- src/core/lib/iomgr/tcp_posix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/iomgr/tcp_posix.cc b/src/core/lib/iomgr/tcp_posix.cc index 7fd0e91346d..aa2704ce263 100644 --- a/src/core/lib/iomgr/tcp_posix.cc +++ b/src/core/lib/iomgr/tcp_posix.cc @@ -500,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);