Skip to content

Commit

Permalink
reduce default queue len and set seen cache to same size
Browse files Browse the repository at this point in the history
  • Loading branch information
somtochiama committed Nov 28, 2024
1 parent 35fce7a commit 1ed2c2a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions crates/corro-agent/src/agent/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,8 +750,8 @@ pub async fn handle_changes(
agent.config().perf.apply_queue_timeout as u64,
));

const MAX_SEEN_CACHE_LEN: usize = 10000;
const KEEP_SEEN_CACHE_SIZE: usize = 1000;
let max_seen_cache_len: usize = max_changes_chunk;
let keep_seen_cache_size: usize = cmp::max(10, max_seen_cache_len / 10);
let mut seen: IndexMap<_, RangeInclusiveSet<CrsqlSeq>> = IndexMap::new();

let mut drop_log_count: u64 = 0;
Expand Down Expand Up @@ -819,9 +819,9 @@ pub async fn handle_changes(
buf_cost = 0;
}

if seen.len() > MAX_SEEN_CACHE_LEN {
if seen.len() > max_seen_cache_len {
// we don't want to keep too many entries in here.
seen = seen.split_off(seen.len() - KEEP_SEEN_CACHE_SIZE);
seen = seen.split_off(seen.len() - keep_seen_cache_size);
}
continue
},
Expand Down
2 changes: 1 addition & 1 deletion crates/corro-types/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const fn default_wal_threshold() -> usize {
10
}
const fn default_processing_queue() -> usize {
50000
20000
}

/// Used for the apply channel
Expand Down

0 comments on commit 1ed2c2a

Please sign in to comment.