m3x icon indicating copy to clipboard operation
m3x copied to clipboard

[WIP] Add a P-sharded Object Pool

Open prateek opened this issue 7 years ago • 1 comments

Benchmark results for ShardedPool v ObjectPool on my laptop look quite promising: 9x better with GOMAXPROCS=4 for concurrent gets/puts, very similar in other categories

❯ go test -bench=Pool -cpu 1,2,4 -run '^$' ./pool
goos: darwin
goarch: amd64
pkg: github.com/m3db/m3x/pool
BenchmarkObjectPoolGetPut                	10000000	       111 ns/op
BenchmarkObjectPoolGetPut-2              	20000000	       102 ns/op
BenchmarkObjectPoolGetPut-4              	20000000	        93.9 ns/op
BenchmarkShardedPoolGetPut               	20000000	        93.4 ns/op
BenchmarkShardedPoolGetPut-2             	20000000	        90.6 ns/op
BenchmarkShardedPoolGetPut-4             	20000000	        91.3 ns/op
BenchmarkShardedPoolConcurrentGetPut     	50000000	        38.0 ns/op
BenchmarkShardedPoolConcurrentGetPut-2   	100000000	        20.4 ns/op
BenchmarkShardedPoolConcurrentGetPut-4   	100000000	        16.3 ns/op
BenchmarkChannelPoolConcurrentGetPut     	20000000	        91.0 ns/op
BenchmarkChannelPoolConcurrentGetPut-2   	10000000	       142 ns/op
BenchmarkChannelPoolConcurrentGetPut-4   	10000000	       175 ns/op
BenchmarkShardedPoolOverflow             	  300000	      5866 ns/op
BenchmarkShardedPoolOverflow-2           	  500000	      3979 ns/op
BenchmarkShardedPoolOverflow-4           	  500000	      2783 ns/op
BenchmarkChannelPoolOverflow             	  200000	      5852 ns/op
BenchmarkChannelPoolOverflow-2           	  500000	      3233 ns/op
BenchmarkChannelPoolOverflow-4           	  500000	      2669 ns/op

prateek avatar Sep 27 '18 11:09 prateek

What do you think of following the example of drwmutex to make the pool per-CPU instead of per-P so we don't have to call into the runtime?

jeromefroe avatar Sep 27 '18 12:09 jeromefroe