• Miek Gieben's avatar
    cache: move goroutine closure to separate function to save memory (#3353) · f8551df2
    Miek Gieben authored
    The goroutine closure was causing objects to be heap allocated.  Moving
    it to a separate function fixes that.
    
    ```benchmark                                old ns/op     new ns/op     delta
    BenchmarkCacheResponse/NoPrefetch-12     773           713           -7.76%
    BenchmarkCacheResponse/Prefetch-12       878           837           -4.67%
    BenchmarkHash-12                         9.17          9.18          +0.11%
    
    benchmark                                old allocs     new allocs     delta
    BenchmarkCacheResponse/NoPrefetch-12     9              8              -11.11%
    BenchmarkCacheResponse/Prefetch-12       9              8              -11.11%
    BenchmarkHash-12                         0              0              +0.00%
    
    benchmark                                old bytes     new bytes     delta
    BenchmarkCacheResponse/NoPrefetch-12     471           327           -30.57%
    BenchmarkCacheResponse/Prefetch-12       471           327           -30.57%
    BenchmarkHash-12                         0             0             +0.00%
    ```
    Signed-off-by: default avatarCharlie Vieth <charlie.vieth@gmail.com>
    Signed-off-by: default avatarMiek Gieben <miek@miek.nl>
    f8551df2
handler.go 3.72 KB