• Brad Fitzpatrick's avatar
    http2: optimize server frame writes · e7b14352
    Brad Fitzpatrick authored
    Don't do async frame writes when the write is known to be small enough
    to definitely fit in the write buffer and not cause a flush (which
    might block). This avoids starting a new goroutine and doing a channel
    send operation for many frame writes.
    
    name                  old time/op    new time/op    delta
    ServerGets-4             146µs ± 2%     144µs ± 1%  -1.46%        (p=0.000 n=14+14)
    ServerPosts-4            162µs ± 1%     160µs ± 1%  -1.15%        (p=0.000 n=15+15)
    Server_GetRequest-4      145µs ± 1%     143µs ± 0%  -1.26%        (p=0.000 n=15+15)
    Server_PostRequest-4     160µs ± 1%     158µs ± 1%  -1.32%        (p=0.000 n=15+15)
    
    The headers frame is the main last one which might show some benefit
    if there's a cheap enough way to conservatively calculate its size.
    
    Change-Id: I9be2ddbf04689340819d8701ea671fff378d9e79
    Reviewed-on: https://go-review.googlesource.com/31495
    Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    e7b14352
write.go 8.42 KB