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

feat(spooler): Implement eviction algorithm for EnvelopeBuffer #3932

Closed
wants to merge 9 commits into from

Conversation

iambriccardo
Copy link
Member

@iambriccardo iambriccardo commented Aug 14, 2024

This PR implements an eviction algorithm that can be triggered via the evict method call on the EnvelopeBuffer. The eviction policy aims to evict all the envelope stacks that are not ready or have been stale for the longest time.

The PR doesn't include the logic for triggering the eviction, since this is something that we can decide later on. Still, some possibilities include trying eviction via tickers that frequently monitor the capacity of Relay and evict data when in need.

Closes: https://github.com/getsentry/team-ingest/issues/518

@iambriccardo iambriccardo changed the title feat(spooler): Implement eviction policy feat(spooler): Implement eviction algorithm Aug 16, 2024
// elements from each popped stack.
for lru_item in lru {
if let Some(mut stack) = self.pop_stack(lru_item.0) {
stack.evict().await;
Copy link
Member Author

Choose a reason for hiding this comment

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

If we are using disk, it's not the most efficient thing to run a query for each project key pair but we can investigate the performance of this later on.

@@ -105,15 +106,18 @@ struct EnvelopeBuffer<P: StackProvider> {
/// This indirection is needed because different stack implementations might need different
/// initialization (e.g. a database connection).
stack_provider: P,
/// The maximum number of stacks that can be evicted when low on memory.
max_evictable_stacks: usize,
Copy link
Member Author

Choose a reason for hiding this comment

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

We might want to have this defined as a percentage (since the buffer can grow a lot), but for now, we will remain with a static value.

@iambriccardo iambriccardo changed the title feat(spooler): Implement eviction algorithm feat(spooler): Implement eviction algorithm for EnvelopeBuffer Aug 16, 2024
@iambriccardo iambriccardo marked this pull request as ready for review August 16, 2024 08:50
@iambriccardo iambriccardo requested a review from a team as a code owner August 16, 2024 08:50
@iambriccardo
Copy link
Member Author

Closed in favor of #4014.

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.

1 participant