-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[libbeat] Cache processor docs and memory fixes. #38561
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
6f0019a
Fix write_period option name to match documentation
marc-gr 9a91a1e
Change naming to write_interval
marc-gr f85f559
Merge branch 'main' into fix/cache-docs
marc-gr 09315aa
Fix expiries heap cleanup on partial file writes
marc-gr b329901
Fix expiries infinite growth when large TTLs and recurring keys are c…
marc-gr d881e0e
Fix linting errors
marc-gr 149aa9b
Merge branch 'main' into fix/cache-docs
marc-gr 4d64a50
Add changelog entries
marc-gr dd4c956
Merge branch 'main' into fix/cache-docs
marc-gr 00e7bde
Revert "Fix linting errors"
marc-gr c639c1e
Use heap.Fix instead of heap.Remove+heap.Push
marc-gr 441d9cc
Add tests for the new functionality
marc-gr f0576fe
Merge branch 'main' into fix/cache-docs
marc-gr cd07008
Merge branch 'main' into fix/cache-docs
marc-gr 2bd167c
Merge branch 'main' into fix/cache-docs
marc-gr efbf245
Merge branch 'main' into fix/cache-docs
marc-gr 2e18707
Merge branch 'main' into fix/cache-docs
marc-gr 12346cc
Merge branch 'main' into fix/cache-docs
marc-gr de7f23b
Merge branch 'main' into fix/cache-docs
marc-gr 312fe92
Merge branch 'main' into fix/cache-docs
marc-gr 3a0423a
Merge branch 'main' into fix/cache-docs
marc-gr 4575de0
Merge branch 'main' into fix/cache-docs
andrewkroh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previously logic was obviously written when we were only planning to write out on exit, so the iterator was destructive. It would be nice if the write out also dropped expired elements, but that cannot happen non-destructively within this iterator. It could be done by a mark during this iteration, followed by a sweep in the postamble.
Not for now, but this would look like
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this is super worth it, does not this operation of dropping also happen at every Put?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: not really related, but I noticed the file write can lead to some issues when the cache is really large, since it stops the world until done due to the need of locking the cache. Not sure about how to avoid it, but just pointing it out as it could cause issues if write_interval is on the low end and cache size is on the larger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but only "just enough". This takes a small amount of time relative to the file write to minimize the memory usage.
If this does become an issue, the approach would be to:
This requires adding a new field to the
memStore
type that keeps a track of the front of the heap for this purpose, and a lock tofileStore
.The approach here will potentially write out deleted items, but should never write out invalid items.
However, it's significantly more complex and unless there is actually an issue, I don't think this is worth it; tuning should be a first option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only thing a bit odd to me, unless I got something wrong, is that this memory benefit only applies if using the file write intervals, while when using just memory backend or file without the write intervals, this would just be skipped and the "just enough" effort would be done. That is why I mention that I am not sure is worth it, unless we want to do it somewhere else to benefit all configurations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'm fine with things how they are; the code looks good to me. The only reason I suggested it is that the most common (and likely recommended use would be file-backed) and the cost of this work is small in comparison to the cost of the file write, so it was a reasonable place to insert the work in a way that is routinely run.