]> Cypherpunks repositories - gostls13.git/commit
internal/poll: implement a pipe pool for splice() call
authorAndy Pan <panjf2000@gmail.com>
Thu, 19 Nov 2020 11:09:14 +0000 (19:09 +0800)
committerIan Lance Taylor <iant@golang.org>
Wed, 10 Mar 2021 03:52:48 +0000 (03:52 +0000)
commit643d240a11b2d00e1718b02719707af0708e7519
tree5883c80c4f42f17ea1c924e62f3dd00c88449422
parentd33e2192a71c33a604af247161ba1d2c1969e4c7
internal/poll: implement a pipe pool for splice() call

In scenarios where splice() is called, splice() is usually called not just once, but many times,
which means that a lot of pipes will be created and destroyed frequently, costing an amount of system resources
and slowing down performance, thus I suggest that we add a pipe pool for reusing pipes.

Benchmark tests:

goos: linux
goarch: amd64
pkg: internal/poll
cpu: AMD EPYC 7K62 48-Core Processor

name                  old time/op    new time/op    delta
SplicePipe-8            1.36µs ± 1%    0.02µs ± 0%   -98.57%  (p=0.001 n=7+7)
SplicePipeParallel-8     747ns ± 4%       4ns ± 0%   -99.41%  (p=0.001 n=7+7)

name                  old alloc/op   new alloc/op   delta
SplicePipe-8             24.0B ± 0%      0.0B       -100.00%  (p=0.001 n=7+7)
SplicePipeParallel-8     24.0B ± 0%      0.0B       -100.00%  (p=0.001 n=7+7)

name                  old allocs/op  new allocs/op  delta
SplicePipe-8              1.00 ± 0%      0.00       -100.00%  (p=0.001 n=7+7)
SplicePipeParallel-8      1.00 ± 0%      0.00       -100.00%  (p=0.001 n=7+7)

Fixes #42740

Change-Id: Idff654b7264342084e089b5ba796c87c380c471b
Reviewed-on: https://go-review.googlesource.com/c/go/+/271537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
src/internal/poll/export_linux_test.go [new file with mode: 0644]
src/internal/poll/splice_linux.go
src/internal/poll/splice_linux_test.go [new file with mode: 0644]