• Tom Bergan's avatar
    http2: replace fixedBuffer with dataBuffer · 10c134ea
    Tom Bergan authored
    fixedBuffer was a bad idea for two reasons:
    
    1. It was fixed at a constant 64KB (the current default flow-control
       window) which wastes memory on the server when clients upload many
       small request bodies.
    
    2. A follow-up CL will allow configuring the server's connection and
       stream receive windows. We want to allow individual streams to use
       varying amounts of the available connection window. This is not
       possible when each stream uses a fixedBuffer.
    
    dataBuffer grows and shrinks based on current usage. The worst-case
    fragmentation of dataBuffer is 32KB wasted memory per stream, but I
    expect that worst-case will be rare. In particular, if the declared
    size of a stream's request body is under 1KB, then the server will not
    allocate more than 1KB to process that stream's request body.
    
    Updates golang/go#16512
    Fixes golang/go#18509
    
    Change-Id: Ibcb18007037e82518a65848ef3baf4937955ac9d
    Reviewed-on: https://go-review.googlesource.com/37400
    Run-TryBot: Tom Bergan <tombergan@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
    10c134ea
databuffer_test.go 4.28 KB