[MINOR] read optimizations based on the MSS
Generally, if a recv() returns less bytes than the MSS, it means that
there is nothing left in the system's buffers, and that it's not worth
trying to read again because we are very likely to get nothing. A
default read low limit has been set to 1460 bytes below which we stop
reading.
This has brought a little speed boost on small objects while maintaining
the same speed on large objects.
diff --git a/src/stream_sock.c b/src/stream_sock.c
index 4e08117..f9e5627 100644
--- a/src/stream_sock.c
+++ b/src/stream_sock.c
@@ -95,6 +95,15 @@
}
b->total += ret;
+
+ /* generally if we read something smaller than the 1 or 2 MSS,
+ * it means that it's not worth trying to read again.
+ */
+ if (ret < MIN_RET_FOR_READ_LOOP)
+ break;
+ if (!read_poll)
+ break;
+
/* we hope to read more data or to get a close on next round */
continue;
}