Skip to content

Commit ec218f4

Browse files
committed
readyset-server: Evict much more often, less aggressively
Data from the field revealed some unacceptably large upquery times correlated with evictions. In a prior revision of eviction math, we bumped up the indicated eviction sizes a bit in an attempt to stay diligently within the proscribed memory limit. This had the unwanted side effect of making evictions larger and less frequent, which means when they do happen, the domain blocks for longer, which is not what we want. Instead, we evict only the amount indicated by our heuristic calculation, but we're lowering the period by a factor of ten (to 100 ms). The higher frequency will spread out the evictions more evenly in time so that the individual disruptions to upqueries will be smaller. Release-Note-Core: Evictions are now smaller but more frequent to avoid spikes in upquery latency. Change-Id: I7851daf69f59c11229d6c3f3ca67e2b830cde8d3 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/8498 Tested-by: Buildkite CI Reviewed-by: Marcelo Altmann <marcelo@readyset.io>
1 parent 8314bca commit ec218f4

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

readyset-server/src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl Builder {
6060
if opts.memory_limit > 0 {
6161
builder.set_memory_limit(
6262
opts.memory_limit,
63-
Duration::from_secs(opts.memory_check_freq),
63+
Duration::from_millis(opts.memory_check_freq),
6464
);
6565
}
6666
builder.set_eviction_kind(opts.eviction_kind);

readyset-server/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,10 +545,10 @@ pub struct WorkerOptions {
545545
pub memory_limit: usize,
546546

547547
/// Frequency at which to check the process heap allocation against the memory limit (in
548-
/// seconds)
548+
/// milliseconds)
549549
#[arg(
550550
long = "memory-check-every",
551-
default_value = "1",
551+
default_value = "100",
552552
env = "MEMORY_CHECK_EVERY",
553553
hide = true
554554
)]

readyset-server/src/worker/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ pub struct Worker {
245245
}
246246

247247
impl Worker {
248-
const DEFAULT_EVICT_INTERVAL: Duration = Duration::from_secs(1);
248+
const DEFAULT_EVICT_INTERVAL: Duration = Duration::from_millis(100);
249249

250250
pub fn new(
251251
rx: Receiver<WorkerRequest>,
@@ -618,9 +618,7 @@ async fn evict_check(
618618
(sizes, total_reported)
619619
};
620620

621-
// Evict a little more than necessary to provide some hysteresis.
622-
let limit = (limit as f64 * 0.98f64) as usize;
623-
let actual_over = 2 * (used - limit);
621+
let actual_over = used - limit;
624622

625623
// state sizes are under actual memory usage, but roughly proportional to actual
626624
// memory usage - let's figure out proportionally how much *reported* memory we

0 commit comments

Comments
 (0)