summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_stacks
diff options
context:
space:
mode:
authorsmh <smh@FreeBSD.org>2017-04-24 11:34:02 +0000
committersmh <smh@FreeBSD.org>2017-04-24 11:34:02 +0000
commit45105004da0b6dd9f5da6cee0872480d6bf94446 (patch)
treee240f53621d2090330fbe868feaef2d3908fbae0 /sys/netinet/tcp_stacks
parent1b91cdf6c751258b0a2f9f99147e054bb7c16af0 (diff)
downloadFreeBSD-src-45105004da0b6dd9f5da6cee0872480d6bf94446.zip
FreeBSD-src-45105004da0b6dd9f5da6cee0872480d6bf94446.tar.gz
MFC r316676:
Use estimated RTT for receive buffer auto resizing instead of timestamps Relnotes: Yes Sponsored by: Multiplay
Diffstat (limited to 'sys/netinet/tcp_stacks')
-rw-r--r--sys/netinet/tcp_stacks/fastpath.c62
1 files changed, 2 insertions, 60 deletions
diff --git a/sys/netinet/tcp_stacks/fastpath.c b/sys/netinet/tcp_stacks/fastpath.c
index 061c811..375a098 100644
--- a/sys/netinet/tcp_stacks/fastpath.c
+++ b/sys/netinet/tcp_stacks/fastpath.c
@@ -390,62 +390,8 @@ tcp_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so,
(void *)tcp_saveipgen, &tcp_savetcp, 0);
#endif
TCP_PROBE3(debug__input, tp, th, m);
- /*
- * Automatic sizing of receive socket buffer. Often the send
- * buffer size is not optimally adjusted to the actual network
- * conditions at hand (delay bandwidth product). Setting the
- * buffer size too small limits throughput on links with high
- * bandwidth and high delay (eg. trans-continental/oceanic links).
- *
- * On the receive side the socket buffer memory is only rarely
- * used to any significant extent. This allows us to be much
- * more aggressive in scaling the receive socket buffer. For
- * the case that the buffer space is actually used to a large
- * extent and we run out of kernel memory we can simply drop
- * the new segments; TCP on the sender will just retransmit it
- * later. Setting the buffer size too big may only consume too
- * much kernel memory if the application doesn't read() from
- * the socket or packet loss or reordering makes use of the
- * reassembly queue.
- *
- * The criteria to step up the receive buffer one notch are:
- * 1. Application has not set receive buffer size with
- * SO_RCVBUF. Setting SO_RCVBUF clears SB_AUTOSIZE.
- * 2. the number of bytes received during the time it takes
- * one timestamp to be reflected back to us (the RTT);
- * 3. received bytes per RTT is within seven eighth of the
- * current socket buffer size;
- * 4. receive buffer size has not hit maximal automatic size;
- *
- * This algorithm does one step per RTT at most and only if
- * we receive a bulk stream w/o packet losses or reorderings.
- * Shrinking the buffer during idle times is not necessary as
- * it doesn't consume any memory when idle.
- *
- * TODO: Only step up if the application is actually serving
- * the buffer to better manage the socket buffer resources.
- */
- if (V_tcp_do_autorcvbuf &&
- (to->to_flags & TOF_TS) &&
- to->to_tsecr &&
- (so->so_rcv.sb_flags & SB_AUTOSIZE)) {
- if (TSTMP_GT(to->to_tsecr, tp->rfbuf_ts) &&
- to->to_tsecr - tp->rfbuf_ts < hz) {
- if (tp->rfbuf_cnt >
- (so->so_rcv.sb_hiwat / 8 * 7) &&
- so->so_rcv.sb_hiwat <
- V_tcp_autorcvbuf_max) {
- newsize =
- min(so->so_rcv.sb_hiwat +
- V_tcp_autorcvbuf_inc,
- V_tcp_autorcvbuf_max);
- }
- /* Start over with next RTT. */
- tp->rfbuf_ts = 0;
- tp->rfbuf_cnt = 0;
- } else
- tp->rfbuf_cnt += tlen; /* add up */
- }
+
+ newsize = tcp_autorcvbuf(m, th, so, tp, tlen);
/* Add data to socket buffer. */
SOCKBUF_LOCK(&so->so_rcv);
@@ -520,10 +466,6 @@ tcp_do_slowpath(struct mbuf *m, struct tcphdr *th, struct socket *so,
win = 0;
tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt));
- /* Reset receive buffer auto scaling when not in bulk receive mode. */
- tp->rfbuf_ts = 0;
- tp->rfbuf_cnt = 0;
-
switch (tp->t_state) {
/*
OpenPOWER on IntegriCloud