Index: sys/netinet/in_kdtrace.h =================================================================== --- sys/netinet/in_kdtrace.h +++ sys/netinet/in_kdtrace.h @@ -65,6 +65,9 @@ SDT_PROBE_DECLARE(tcp, , , debug__output); SDT_PROBE_DECLARE(tcp, , , debug__user); SDT_PROBE_DECLARE(tcp, , , debug__drop); +SDT_PROBE_DECLARE(tcp, , , receive__autoresize); +SDT_PROBE_DECLARE(tcp, , , receive__autoreset); +SDT_PROBE_DECLARE(tcp, , , xmit__timer); SDT_PROBE_DECLARE(udp, , , receive); SDT_PROBE_DECLARE(udp, , , send); Index: sys/netinet/in_kdtrace.c =================================================================== --- sys/netinet/in_kdtrace.c +++ sys/netinet/in_kdtrace.c @@ -132,6 +132,29 @@ "void *", "void *", "int", "tcplsinfo_t *"); +SDT_PROBE_DEFINE6_XLATE(tcp, , , receive__autoresize, + "u_int32_t", "u_int32_t", + "struct tcpcb *", "csinfo_t *", + "u_int", "u_int", + "struct tcpcb *", "tcpsinfo_t *" , + "struct tcphdr *", "tcpinfoh_t *", + "int", "int"); + +SDT_PROBE_DEFINE6_XLATE(tcp, , , receive__autoreset, + "u_int32_t", "u_int32_t", + "struct tcpcb *", "csinfo_t *", + "u_int", "u_int", + "struct tcpcb *", "tcpsinfo_t *" , + "struct tcphdr *", "tcpinfoh_t *"); + +SDT_PROBE_DEFINE6_XLATE(tcp, , , xmit__timer, + "void *", "pktinfo_t *", + "struct inpcb *", "csinfo_t *", + "uint8_t *", "ipinfo_t *", + "struct inpcb *", "udpsinfo_t *", + "struct udphdr *", "udpinfo_t *", + "int", "int"); + SDT_PROBE_DEFINE5_XLATE(udp, , , receive, "void *", "pktinfo_t *", "struct inpcb *", "csinfo_t *", Index: sys/netinet/tcp_input.c =================================================================== --- sys/netinet/tcp_input.c +++ sys/netinet/tcp_input.c @@ -1885,24 +1885,51 @@ * 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) { + int rtt_check = 0; + uint32_t t = 0; + + if ((to.to_flags & TOF_TS) != 0 && + to.to_tsecr) { + /* Timestamp based RTT. */ + if (TSTMP_GT(to.to_tsecr, + tp->rfbuf_ts) && + to.to_tsecr - tp->rfbuf_ts < hz) + rtt_check = 3; + else + rtt_check = 1; + } else { + /* Estimated RTT. */ + t = tcp_ts_getticks(); + if (tp->t_srtt != 0 && + tp->rfbuf_ts != 0 && + t - tp->rfbuf_ts > + (tp->t_srtt >> TCP_RTT_SHIFT)) + rtt_check = 4; + else + rtt_check = 2; + } + + TCP_PROBE6(receive__autoresize, NULL, + tp, t, tp, th, rtt_check); + + if (rtt_check > 2) { 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 + + newsize = min( + so->so_rcv.sb_hiwat + V_tcp_autorcvbuf_inc, V_tcp_autorcvbuf_max); + TCP_PROBE6(receive__autoresize, + newsize, tp, t, tp, th, + rtt_check); } /* Start over with next RTT. */ tp->rfbuf_ts = 0; tp->rfbuf_cnt = 0; - } else + } else if (rtt_check != 0) tp->rfbuf_cnt += tlen; /* add up */ } @@ -1945,9 +1972,17 @@ win = 0; tp->rcv_wnd = imax(win, (int)(tp->rcv_adv - tp->rcv_nxt)); + /* + * Disabling the reset below gives an extra 20% performance increase + * when testing with 17ms RTT on a 1Gbps line, 80MB/s -> 100MB/s. + * + * So the question is why was this done and is it being triggered + * incorrectly? + */ + TCP_PROBE5(receive__autoreset, NULL, tp, t, tp, th); /* Reset receive buffer auto scaling when not in bulk receive mode. */ - tp->rfbuf_ts = 0; - tp->rfbuf_cnt = 0; + //tp->rfbuf_ts = 0; + //tp->rfbuf_cnt = 0; switch (tp->t_state) { @@ -3492,6 +3527,8 @@ INP_WLOCK_ASSERT(tp->t_inpcb); + TCP_PROBE6(xmit__timer, NULL, tp, NULL, tp, NULL, rtt); + TCPSTAT_INC(tcps_rttupdated); tp->t_rttupdated++; if ((tp->t_srtt != 0) && (tp->t_rxtshift <= TCP_RTT_INVALIDATE)) { Index: sys/netinet/tcp_output.c =================================================================== --- sys/netinet/tcp_output.c +++ sys/netinet/tcp_output.c @@ -829,11 +829,13 @@ to.to_tsval = tcp_ts_getticks() + tp->ts_offset; to.to_tsecr = tp->ts_recent; to.to_flags |= TOF_TS; - /* Set receive buffer autosizing timestamp. */ - if (tp->rfbuf_ts == 0 && - (so->so_rcv.sb_flags & SB_AUTOSIZE)) - tp->rfbuf_ts = tcp_ts_getticks(); } + + /* Set receive buffer autosizing timestamp. */ + if (tp->rfbuf_ts == 0 && + (so->so_rcv.sb_flags & SB_AUTOSIZE)) + tp->rfbuf_ts = tcp_ts_getticks(); + /* Selective ACK's. */ if (tp->t_flags & TF_SACK_PERMIT) { if (flags & TH_SYN)