@@ -872,14 +872,14 @@ fn spool_envelopes_unspool_interval() -> u64 {
872
872
100
873
873
}
874
874
875
- /// Default batch size for the stack .
876
- fn spool_envelopes_stack_disk_batch_size ( ) -> usize {
875
+ /// Default number of envelope to read from disk at once .
876
+ fn spool_envelopes_read_batch_size ( ) -> usize {
877
877
200
878
878
}
879
879
880
- /// Default maximum number of batches for the stack .
881
- fn spool_envelopes_stack_max_batches ( ) -> usize {
882
- 2
880
+ /// Default number of encoded envelope bytes to cache before writing to disk .
881
+ fn spool_envelopes_write_batch_bytes ( ) -> ByteSize {
882
+ ByteSize :: kibibytes ( 10 )
883
883
}
884
884
885
885
fn spool_envelopes_max_envelope_delay_secs ( ) -> u64 {
@@ -927,13 +927,16 @@ pub struct EnvelopeSpool {
927
927
/// The interval in milliseconds to trigger unspool.
928
928
#[ serde( default = "spool_envelopes_unspool_interval" ) ]
929
929
unspool_interval : u64 ,
930
- /// Number of elements of the envelope stack that are flushed to disk.
931
- #[ serde( default = "spool_envelopes_stack_disk_batch_size" ) ]
932
- disk_batch_size : usize ,
933
- /// Number of batches of size [`Self::disk_batch_size`] that need to be accumulated before
934
- /// flushing one batch to disk.
935
- #[ serde( default = "spool_envelopes_stack_max_batches" ) ]
936
- max_batches : usize ,
930
+ /// Number of envelopes that are read from disk at once.
931
+ ///
932
+ /// Defaults to 10.
933
+ #[ serde( default = "spool_envelopes_read_batch_size" ) ]
934
+ read_batch_size : usize ,
935
+ /// Number of encoded envelope bytes that are spooled to disk at once.
936
+ ///
937
+ /// Defaults to 10 KiB.
938
+ #[ serde( default = "spool_envelopes_write_batch_bytes" ) ]
939
+ write_batch_bytes : ByteSize ,
937
940
/// Maximum time between receiving the envelope and processing it.
938
941
///
939
942
/// When envelopes spend too much time in the buffer (e.g. because their project cannot be loaded),
@@ -953,7 +956,7 @@ pub struct EnvelopeSpool {
953
956
/// This value should be lower than [`Health::max_memory_percent`] to prevent flip-flopping.
954
957
///
955
958
/// Warning: this threshold can cause the buffer service to deadlock when the buffer itself
956
- /// is using too much memory (influenced by [`Self::max_batches `] and [`Self::disk_batch_size `]).
959
+ /// is using too much memory (influenced by [`Self::read_batch_size `] and [`Self::write_batch_bytes `]).
957
960
///
958
961
/// Defaults to 90% (5% less than max memory).
959
962
#[ serde( default = "spool_max_backpressure_memory_percent" ) ]
@@ -989,9 +992,9 @@ impl Default for EnvelopeSpool {
989
992
min_connections : spool_envelopes_min_connections ( ) ,
990
993
max_disk_size : spool_envelopes_max_disk_size ( ) ,
991
994
max_memory_size : spool_envelopes_max_memory_size ( ) ,
992
- unspool_interval : spool_envelopes_unspool_interval ( ) , // 100ms
993
- disk_batch_size : spool_envelopes_stack_disk_batch_size ( ) ,
994
- max_batches : spool_envelopes_stack_max_batches ( ) ,
995
+ unspool_interval : spool_envelopes_unspool_interval ( ) ,
996
+ read_batch_size : spool_envelopes_read_batch_size ( ) ,
997
+ write_batch_bytes : spool_envelopes_write_batch_bytes ( ) ,
995
998
max_envelope_delay_secs : spool_envelopes_max_envelope_delay_secs ( ) ,
996
999
disk_usage_refresh_frequency_ms : spool_disk_usage_refresh_frequency_ms ( ) ,
997
1000
max_backpressure_envelopes : spool_max_backpressure_envelopes ( ) ,
@@ -2174,22 +2177,21 @@ impl Config {
2174
2177
self . values . spool . envelopes . max_memory_size . as_bytes ( )
2175
2178
}
2176
2179
2177
- /// Number of batches of size `stack_disk_batch_size` that need to be accumulated before
2178
- /// flushing one batch to disk.
2179
- pub fn spool_envelopes_stack_disk_batch_size ( & self ) -> usize {
2180
- self . values . spool . envelopes . disk_batch_size
2180
+ /// Number of envelopes to read from disk at once.
2181
+ pub fn spool_envelopes_read_batch_size ( & self ) -> usize {
2182
+ self . values . spool . envelopes . read_batch_size
2181
2183
}
2182
2184
2183
- /// Number of batches of size `stack_disk_batch_size` that need to be accumulated before
2185
+ /// Number of encoded envelope bytes that need to be accumulated before
2184
2186
/// flushing one batch to disk.
2185
- pub fn spool_envelopes_stack_max_batches ( & self ) -> usize {
2186
- self . values . spool . envelopes . max_batches
2187
+ pub fn spool_envelopes_write_batch_bytes ( & self ) -> usize {
2188
+ self . values . spool . envelopes . write_batch_bytes . as_bytes ( )
2187
2189
}
2188
2190
2189
2191
/// Returns `true` if version 2 of the spooling mechanism is used.
2190
2192
pub fn spool_v2 ( & self ) -> bool {
2191
2193
matches ! (
2192
- self . values. spool. envelopes. version,
2194
+ & self . values. spool. envelopes. version,
2193
2195
EnvelopeSpoolVersion :: V2
2194
2196
)
2195
2197
}
0 commit comments