Repository navigation
perf(kv-router): index selection reservations by partition - #11
Closed
ishandhanani wants to merge 1 commit into
Closed
ishandhanani wants to merge 1 commit into
ishandhanani wants to merge 1 commit into
Conversation
prefill_complete, free_reservation, and add_output_block arrive with only a selection id, so SelectionCore scanned every partition scheduler on each call. With two embedded services (prefill + decode pools) and encoder/fallback partitions this becomes a per-request O(partitions) walk on the lifecycle path. Add a selection_id -> RoutingPartitionId index populated by both booking paths (select_and_reserve and create_reservation). Lifecycle calls try the indexed partition first and fall back to the full scan, which keeps bookings mirrored from replica peers working. Entries are removed on free, on a NotFound that exhausts every partition, and by a periodic sweep that drops ids whose booking was released out of band (force-expiry). The sweep task starts lazily from the first ensure_entry so construction does not require a runtime. Adds LocalScheduler::has_request for the sweep. Tests: index population by both paths, indexed-first ordering, removal on free/NotFound, and sweep of an out-of-band release. Existing later-entry fallback test unchanged. Signed-off-by: Ishan Dhanani <[email protected]>
ishandhanani
had a problem deploying
to
external_collaborator
September 3, 2026 06:26 — with
GitHub Actions
Failure
This was referenced Sep 3, 2026
Owner
Author
This branch had an error being deployed
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.
Phase 0 (selection-core parity), item 3. Stacked on #10.
Summary
prefill_complete,free_reservation, andadd_output_block(core/mod.rs:1043-1098on main) walked every partition scheduler per call because a selection id carries no partition. That is a per-request cost that scales with partitions, which Phase 3 doubles (two embedded services) and extends (encoder/fallback pools).reservation_index: RwLock<HashMap<String, RoutingPartitionId>>onSelectionCore(standard hasher: ids are caller-controlled, perlib/kv-router/AGENTS.md). Populated by both booking paths:schedule_selectionwhenbook == trueandfinalize_reservation.lifecycle_entries(id)returns the indexed partition first, then the rest, so the existing full-scan fallback still covers bookings mirrored from replica peers (which never pass through this core's booking paths).free, on aNotFoundthat exhausted every partition, and by a periodic sweep (period =active_request_expiry_duration()) that drops ids whose booking the scheduler no longer holds (force-expiry). The sweep is spawned lazily from the firstensure_entrysonew_localstill works without a runtime.LocalScheduler::has_request(&str) -> booladded for the sweep.Validation
cargo test -p dynamo-kv-router --features standalone-selection --lib: 1055 passed. New:reservation_index_tracks_bookings_until_freed(both booking paths, indexed-first ordering, free/NotFound removal) andreservation_index_sweep_drops_bookings_released_out_of_band(release straight through the scheduler, sweep removes exactly that id).lifecycle_operations_find_reservation_in_later_entrystill passes (fallback path).cargo clippy --features standalone-selection --all-targets: only the pre-existingregistry.rsdead-code warning.cargo fmtclean.