• Brad Fitzpatrick's avatar
    net/http: don't allocate 0-byte io.LimitedReaders for GET requests · 468851f1
    Brad Fitzpatrick authored
    Save an allocation per GET request and don't call io.LimitedReader(r, 0)
    just to read 0 bytes.  There's already an eofReader global variable
    for when we just want a non-nil io.Reader to immediately EOF.
    
    (Sorry, I know Rob told me to stop, but I was bored on the plane and
    wrote this before I received the recent "please, really stop" email.)
    
    benchmark                         old ns/op    new ns/op    delta
    BenchmarkServerHandlerTypeLen         13888        13279   -4.39%
    BenchmarkServerHandlerNoLen           12912        12229   -5.29%
    BenchmarkServerHandlerNoType          13348        12632   -5.36%
    BenchmarkServerHandlerNoHeader        10911        10261   -5.96%
    
    benchmark                        old allocs   new allocs    delta
    BenchmarkServerHandlerTypeLen            20           19   -5.00%
    BenchmarkServerHandlerNoLen              18           17   -5.56%
    BenchmarkServerHandlerNoType             18           17   -5.56%
    BenchmarkServerHandlerNoHeader           13           12   -7.69%
    
    benchmark                         old bytes    new bytes    delta
    BenchmarkServerHandlerTypeLen          1913         1878   -1.83%
    BenchmarkServerHandlerNoLen            1878         1843   -1.86%
    BenchmarkServerHandlerNoType           1878         1844   -1.81%
    BenchmarkServerHandlerNoHeader         1085         1051   -3.13%
    
    Fixes #5188
    
    R=golang-dev, adg, r
    CC=golang-dev
    https://golang.org/cl/8297044
    468851f1
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
include Loading commit data...
lib Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.hgignore Loading commit data...
.hgtags Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...