• Tom Bergan's avatar
    crypto/tls: implement dynamic record sizing · ae00df12
    Tom Bergan authored
    Currently, if a client of crypto/tls (e.g., net/http, http2) calls
    tls.Conn.Write with a 33KB buffer, that ends up writing three TLS
    records: 16KB, 16KB, and 1KB. Slow clients (such as 2G phones) must
    download the first 16KB record before they can decrypt the first byte.
    To improve latency, it's better to send smaller TLS records. However,
    sending smaller records adds overhead (more overhead bytes and more
    crypto calls), which slightly hurts throughput.
    
    A simple heuristic, implemented in this change, is to send small
    records for new connections, then boost to large records after the
    first 1MB has been written on the connection.
    
    Fixes #14376
    
    Change-Id: Ice0f6279325be6775aa55351809f88e07dd700cd
    Reviewed-on: https://go-review.googlesource.com/19591
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarTom Bergan <tombergan@google.com>
    Reviewed-by: 's avatarAdam Langley <agl@golang.org>
    ae00df12
conn_test.go 8.98 KB