diff options
| author | Andrew Dunham <andrew@du.nham.ca> | 2024-05-10 11:58:48 -0400 |
|---|---|---|
| committer | Andrew Dunham <andrew@du.nham.ca> | 2024-05-24 14:11:19 -0400 |
| commit | 8e4a29433f48b192f30da3a164e6ac3b6674b0bc (patch) | |
| tree | f1d795db7ade6e9fa9f6c0c849f2dc243cb2b393 /control/controlknobs | |
| parent | 87ee559b6f00cc553679e44a2d42988d1ffcea44 (diff) | |
| download | tailscale-8e4a29433f48b192f30da3a164e6ac3b6674b0bc.tar.xz tailscale-8e4a29433f48b192f30da3a164e6ac3b6674b0bc.zip | |
util/pool: add package for storing and using a pool of items
This can be used to implement a persistent pool (i.e. one that isn't
cleared like sync.Pool is) of items–e.g. database connections.
Some benchmarks vs. a naive implementation that uses a single map
iteration show a pretty meaningful improvement:
$ benchstat -col /impl ./bench.txt
goos: darwin
goarch: arm64
pkg: tailscale.com/util/pool
│ Pool │ map │
│ sec/op │ sec/op vs base │
Pool_AddDelete-10 10.56n ± 2% 15.11n ± 1% +42.97% (p=0.000 n=10)
Pool_TakeRandom-10 56.75n ± 4% 1899.50n ± 20% +3246.84% (p=0.000 n=10)
geomean 24.49n 169.4n +591.74%
Updates tailscale/corp#19900
Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
Change-Id: Ie509cb65573c4726cfc3da9a97093e61c216ca18
Diffstat (limited to 'control/controlknobs')
0 files changed, 0 insertions, 0 deletions
