• Brad Fitzpatrick's avatar
    bufio: make Reader buffer transient · b25a53ac
    Brad Fitzpatrick authored
    Share garbage between different bufio Readers. When a Reader
    has zero buffered data, put its buffer into a pool.
    
    This acknowledges that most bufio.Readers eventually get
    read to completion, and their buffers are then no longer
    needed.
    
    benchmark               old ns/op    new ns/op    delta
    BenchmarkReaderEmpty         2993         1058  -64.65%
    
    benchmark              old allocs   new allocs    delta
    BenchmarkReaderEmpty            3            2  -33.33%
    
    benchmark               old bytes    new bytes    delta
    BenchmarkReaderEmpty         4278          133  -96.89%
    
    Update #5100
    
    R=r
    CC=adg, dvyukov, gobot, golang-dev, rogpeppe
    https://golang.org/cl/8819049
    b25a53ac
bufio_test.go 28.4 KB