• E
    tcp: refine TSO autosizing · 605ad7f1
    Eric Dumazet 提交于
    Commit 95bd09eb ("tcp: TSO packets automatic sizing") tried to
    control TSO size, but did this at the wrong place (sendmsg() time)
    
    At sendmsg() time, we might have a pessimistic view of flow rate,
    and we end up building very small skbs (with 2 MSS per skb).
    
    This is bad because :
    
     - It sends small TSO packets even in Slow Start where rate quickly
       increases.
     - It tends to make socket write queue very big, increasing tcp_ack()
       processing time, but also increasing memory needs, not necessarily
       accounted for, as fast clones overhead is currently ignored.
     - Lower GRO efficiency and more ACK packets.
    
    Servers with a lot of small lived connections suffer from this.
    
    Lets instead fill skbs as much as possible (64KB of payload), but split
    them at xmit time, when we have a precise idea of the flow rate.
    skb split is actually quite efficient.
    
    Patch looks bigger than necessary, because TCP Small Queue decision now
    has to take place after the eventual split.
    
    As Neal suggested, introduce a new tcp_tso_autosize() helper, so that
    tcp_tso_should_defer() can be synchronized on same goal.
    
    Rename tp->xmit_size_goal_segs to tp->gso_segs, as this variable
    contains number of mss that we can put in GSO packet, and is not
    related to the autosizing goal anymore.
    
    Tested:
    
    40 ms rtt link
    
    nstat >/dev/null
    netperf -H remote -l -2000000 -- -s 1000000
    nstat | egrep "IpInReceives|IpOutRequests|TcpOutSegs|IpExtOutOctets"
    
    Before patch :
    
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/s
    
     87380 2000000 2000000    0.36         44.22
    IpInReceives                    600                0.0
    IpOutRequests                   599                0.0
    TcpOutSegs                      1397               0.0
    IpExtOutOctets                  2033249            0.0
    
    After patch :
    
    Recv   Send    Send
    Socket Socket  Message  Elapsed
    Size   Size    Size     Time     Throughput
    bytes  bytes   bytes    secs.    10^6bits/sec
    
     87380 2000000 2000000    0.36       44.27
    IpInReceives                    221                0.0
    IpOutRequests                   232                0.0
    TcpOutSegs                      1397               0.0
    IpExtOutOctets                  2013953            0.0
    Signed-off-by: NEric Dumazet <edumazet@google.com>
    Signed-off-by: NNeal Cardwell <ncardwell@google.com>
    Acked-by: NYuchung Cheng <ycheng@google.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    605ad7f1
tcp.h 11.7 KB