- 
                Notifications
    You must be signed in to change notification settings 
- Fork 104
fix(spooler): Reduce number of disk reads #3983
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -5,7 +5,9 @@ use crate::services::buffer::common::ProjectKeyPair; | |
| use crate::services::buffer::envelope_store::sqlite::{ | ||
| SqliteEnvelopeStore, SqliteEnvelopeStoreError, | ||
| }; | ||
| use crate::services::buffer::stack_provider::{InitializationState, StackProvider}; | ||
| use crate::services::buffer::stack_provider::{ | ||
| InitializationState, StackCreationType, StackProvider, | ||
| }; | ||
| use crate::SqliteEnvelopeStack; | ||
|  | ||
| #[derive(Debug)] | ||
|  | @@ -46,13 +48,23 @@ impl StackProvider for SqliteStackProvider { | |
| } | ||
| } | ||
|  | ||
| fn create_stack(&self, project_key_pair: ProjectKeyPair) -> Self::Stack { | ||
| fn create_stack( | ||
| &self, | ||
| stack_creation_type: StackCreationType, | ||
| project_key_pair: ProjectKeyPair, | ||
| ) -> Self::Stack { | ||
| SqliteEnvelopeStack::new( | ||
| self.envelope_store.clone(), | ||
| self.disk_batch_size, | ||
| self.max_batches, | ||
| project_key_pair.own_key, | ||
| project_key_pair.sampling_key, | ||
| // We want to check the disk by default if we are creating the stack for the first time, | ||
| // since we might have some data on disk. | ||
| // On the other hand, if we are recreating a stack, it means that we popped it because | ||
| // it was empty, or we never had data on disk for that stack, so we assume by default | ||
| // that there is no need to check disk until some data is spooled. | ||
| matches!(stack_creation_type, StackCreationType::Initialization), | ||
|          | ||
| ) | ||
| } | ||
|  | ||
|  | ||
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.
Let's make StackCreationType an enum with data and remove
project_key_pairandenvelopeparameters, something likeThere 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.
I think that this is a confusing enumerator since it doesn't depict what is going on. I would rather always create an empty stack and specify the context in which it is created.