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

Using sync.Pool for creating element values #3

Closed
zekroTJA opened this issue May 19, 2020 · 0 comments
Closed

Using sync.Pool for creating element values #3

zekroTJA opened this issue May 19, 2020 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@zekroTJA
Copy link
Owner

Currently, each time a new element is set as value to the map, a new element object is allocated on the heap and the pointer of it then set as value to the map.

This causes a lot of allocations when setting new key-value pairs. This might be bypassed by using a sync.Pool to create and cache element objects so they can be re-used after a value was deleted from the map, which often happens when values are expired.

See this post as "template" on how to implement and use sync.Pool:
https://www.akshaydeo.com/blog/2017/12/23/How-did-I-improve-latency-by-700-percent-using-syncPool

@zekroTJA zekroTJA self-assigned this May 19, 2020
@zekroTJA zekroTJA added the enhancement New feature or request label May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant