]> Cypherpunks repositories - gostls13.git/commit
bufio: make Reader buffer transient
authorBrad Fitzpatrick <bradfitz@golang.org>
Fri, 17 May 2013 22:16:06 +0000 (15:16 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 17 May 2013 22:16:06 +0000 (15:16 -0700)
commitb25a53acd71a254df54869ecbe76e44c35580ada
tree3bf4eeded1384dcc0573e6d0983e2a66b5831da9
parent249842c8dbb90b9d286499d052ebd8fd633bd132
bufio: make Reader buffer transient

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
src/pkg/bufio/bufio.go
src/pkg/bufio/bufio_test.go