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

Better mapper cache interface #363

Merged
merged 7 commits into from
Mar 26, 2021

Conversation

glightfoot
Copy link
Contributor

@glightfoot glightfoot commented Feb 7, 2021

Kind of fixes #295 and kind of fixes #362 by removing the lru code from the mapper package.

First stab at moving this to a better interface. The noop cache is now default (was lru), and the rr and lru mapper caches have been moved to a different package. This makes it easier for users of the packages to implement their own caches as the interface is much simpler.

Instead of calling InitCache, there is a UseCache method on mapper to set a cache.

I still want to rework the metrics, but need to think about a better way to do so. I wanted to get some feedback before spending any more time on it.

@matthiasr

Signed-off-by: glightfoot glightfoot@rsglab.com

…che a better an interface for implementing externally`

Signed-off-by: glightfoot <glightfoot@rsglab.com>
Signed-off-by: glightfoot <glightfoot@rsglab.com>
glightfoot added 3 commits February 6, 2021 23:03
Signed-off-by: glightfoot <glightfoot@rsglab.com>
Signed-off-by: glightfoot <glightfoot@rsglab.com>
Signed-off-by: glightfoot <glightfoot@rsglab.com>
@glightfoot
Copy link
Contributor Author

I just now realized the mapper cache issue was actually to wrap the mapper with a cache. I didn’t actually read that issue in detail, but I think having the mapper use a cache is important enough of a performance improvement to keep in there. Thoughts?

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aesthetically I would find the wrapping approach more pleasing, but this is definitely an improvement, and I am happy with it! I left a few comments but nothing major stands out.

@glightfoot
Copy link
Contributor Author

@matthiasr I removed the noop cache entirely and hid the cache calls behind if m.cache != nil checks, which seems simpler. Also added a helper function for the tests

Copy link
Contributor

@matthiasr matthiasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! What is missing to take it out of Draft?

Signed-off-by: glightfoot <glightfoot@rsglab.com>
Signed-off-by: glightfoot <glightfoot@rsglab.com>
@glightfoot glightfoot marked this pull request as ready for review March 23, 2021 13:43
@glightfoot
Copy link
Contributor Author

Ahh sorry about that! Got busy with a job change. Should be ready for review

@matthiasr
Copy link
Contributor

Thanks a lot!

@matthiasr matthiasr merged commit 12281a9 into prometheus:master Mar 26, 2021
matthiasr pushed a commit that referenced this pull request Mar 26, 2021
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

Successfully merging this pull request may close these issues.

License Issue for github.com/hashicorp/golang-lru Factor out mapper caches into their own package
2 participants