Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shortlivedpool does 1 allocation on the heap per Put/Get #2

Open
erikdubbelboer opened this issue Aug 22, 2018 · 0 comments
Open

shortlivedpool does 1 allocation on the heap per Put/Get #2

erikdubbelboer opened this issue Aug 22, 2018 · 0 comments

Comments

@erikdubbelboer
Copy link

Running the new simple benchmark from #1 you can see that shortlivedpool heap allocates while sync.Pool doesn't.

goos: darwin
goarch: amd64
pkg: github.com/gallir/shortlivedpool
BenchmarkSyncPoolSimple-8         	300000000      5.16 ns/op      0 B/op	       0 allocs/op
BenchmarkShortLivedPoolSimple-8   	10000000	       185 ns/op	      32 B/op	       1 allocs/op
PASS
ok  	github.com/gallir/shortlivedpool	4.116s

Heap allocations are exactly the thing you try to avoid by using a pool so shortlivedpool heap allocating kinda defeats the purpose 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant