Repository navigation
fix(cache): preserve affinity on suitable prefix owners - #46
Merged
Merged
Conversation
Signed-off-by: David <12414531+DavidBellamy@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem
Cache-aware routing treated
max_cached_owners_per_prefixas a replication target. While a prefix had fewer owners than the configured value, any fleet-wide load or KV imbalance could route the next turn to an uncached worker after the cooldown. A single unrelated worker above the overload threshold could also make every prefix abandon a usable cached owner.In the production K3 workload this caused trajectory churn: most requests with a suitable cached owner were intentionally spilled, creating repeated cold copies and heavy cache eviction instead of reusing the longest prefix.
Solution
Evaluate longest-prefix ownership before fleet-wide imbalance:
Missing or stale engine telemetry fails open to known owners. Authoritative KV-event ownership is never pruned to enforce the configured ceiling.
Refs #11
Changes
Test Plan
Validation:
cargo +nightly fmt --all -- --checkcargo clippy --offline -p smg --lib --no-deps -- -D warnings -A clippy::ignored-unit-patternscargo check --offline --manifest-path bindings/python/Cargo.tomlruff checkandruff format --checkon touched binding filesgit diff --checkChecklist
cargo +nightly fmtpassescargo clippy --all-targets --all-features -- -D warningswas not run because local OpenCV is unavailable; the productionsmglibrary target passes with warnings denied, allowing only the unrelated pre-existing current-nightlyignored-unit-patternslint