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

fix: Try a few slots when there's a buffer collision. #722

Merged
merged 3 commits into from
Jun 20, 2023

Conversation

kentquirk
Copy link
Contributor

@kentquirk kentquirk commented Jun 17, 2023

Which problem is this PR solving?

  • Refinery's trace cache is implemented as a circular buffer. Until this PR, when the buffer wrapped around and tried to re-use a slot that was still in the cache, it would immediately eject it and replace it with the new trace. This PR changes that logic to try the next 5 slots, which means that the occasional long-lived trace won't be ejected just because it's next in line.

I benchmarked this and it's actually slightly faster than the old method, because it ejects traces less often.

For sites where only occasional traces live a long time, this should greatly decrease the number of times that a collect_cache_buffer_overrun occurs.

Short description of the changes

  • Modify the Set() method to try several slots before giving up

@kentquirk kentquirk requested a review from a team as a code owner June 17, 2023 21:51
@kentquirk kentquirk added this to the v2.0 milestone Jun 17, 2023
@TylerHelmuth
Copy link
Contributor

Are there any meaningful tests we can add to cache_test.go?

@kentquirk kentquirk force-pushed the kent.cache_overrun_fix branch from 3bd1c29 to e4b1427 Compare June 20, 2023 18:54
@kentquirk kentquirk requested a review from TylerHelmuth June 20, 2023 20:32
@kentquirk kentquirk merged commit 86c4c53 into main Jun 20, 2023
@kentquirk kentquirk deleted the kent.cache_overrun_fix branch June 20, 2023 21:40
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.

2 participants