mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #4271] [RFC]: SSD Prefetch-on-Exist — Design and Implementation #1070
Labels
No labels
ascend
auto-closed
bug
bug
CI/Build
Common
documentation
enhancement
feature request
good first issue
help wanted
high priority
MetaX
nightly-failure
pull-request
PyTorch Backend
question
RFC
Roadmap
stale
Store
Tests
Transfer Engine
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/Mooncake#1070
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DHX98 on GitHub (Sep 22, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/4271
TL;DR
When a prefix-cache probe (
exist) hits a key that only survives on SSD, Mooncake can start a best-effort SSD→DRAM promotion inside the probe→get queueing window, so the follow-upget()reads DRAM instead of SSD on the critical path. This RFC presents the implementation design: trigger throttling, master-side task registration, a promotion execution chain shared with promotion-on-hit, and the exist/get wiring. Concept RFC: #2213. Builds on the implementation pioneered in #2646. Several design decisions here (commit-time lease, shared in-flight quota, trigger-immediate execution) directly follow the critique in #3417, whose router-side explicit trigger remains the complementary next step on top of this machinery.Measured: DSv4-Flash + vllm-ascend (A2), offload-only vs offload+prefetch, same dataset/seed,
promotion_on_hit=false. Numbers are TTFT decrease relative to the offload-only baseline of the same round, computed as (baseline − prefetch) / baseline.Concurrency 2 (store DRAM comfortably sized):
Concurrency 4 (deliberately DRAM-constrained store, ~97.5% full):
NVIDIA H20:
Without prefetch, a queued request pays serial SSD reads on the critical path, so the baseline's TTFT grows roughly linearly with queue depth; with prefetch those reads happen inside the queueing window and TTFT stays flat. The decrease scales with queue depth and with the SSD-read share of TTFT; an idle, serial workload sees ≈ 0 decrease by design.
Scope and non-goals
In: per-client trigger throttle, master
RegisterPrefetchTaskRPC, holder-local promotion execution, exist/get wiring, C/Python bindings, tests and CI. Out (follow-ups): router-side explicit trigger RPC (#3417's surface), dedicated prefetch buffer / soft partition, watermark-gate at admission (cooldown backoff is used instead; see discussion).Architecture
End-to-end trigger flow
Component 1 — PrefetchThrottle
Sharded (16) per-key state machine with lazy expiry: a hot probe is O(batch), never O(table).
Per-state dedup windows: healthy states block for
ssd_prefetch_dedup_ttl_sec(default 30 s),kFailedonly forssd_prefetch_cooldown_sec(default 5 s). The memory-pressure cooldown opens onNO_AVAILABLE_HANDLE: while active, prefetch yields to eviction/offload by design. Measured on a saturated store: promotion completed 503 / failed 860, cooldown yielded ~2.1k times.Component 2 — Master: RegisterPrefetchTask
Skips promotion-on-hit admission (an explicit probe is the hotness signal — aligning with #3417's own framing) but shares the in-flight cap and per-key task entry with promotion-on-hit, so double promotion is impossible. Commit-time lease on
from_prefetchtasks closes the evicted-before-use gap quoted in #3417 (no dangling lease on failure).Component 3 — Shared promotion execution chain
One chain, one failure-handling posture, shared verbatim with promotion-on-hit (
ProcessPromotionTasks).Component 4 — exist/get wiring
ExistOptions.prefetch_to_memory+enable_ssd_prefetch→ trigger. Sync cost: dedup lookup + pool enqueue. No RPC on the probe.ssd_get_wait_ms > 0, default off): one deadline shared by the whole batch; wait only on live local promotions (kInFlight/kCompleted); read-only re-queries. A batch headed for SSD also gets one demand-side promotion attempt for its disk keys (ignore_cooldownbypasses only the client-side throttle backoff — never a master-side gate: the shared in-flight cap, holder check, and dedup TTL still apply); SSD fallback is immediate.Relationship and differences (code level)
This RFC is the implementation design for the concept in #2213 and is
complementary to the router-side proposal in #3417. Concretely, at the
level of the code that ships:
ExistOptionsAPI shape (suggested by @LujhCoconut). No implementation design.existprobe (engine SDK)BatchPrefetchToMemoryRPC from the routerexistprobe — the RFC's own "engine SDK without a router" rowNotifyPromotionSuccess); a failed promotion never leaves a dangling leasepromotion_tasksentry + sharedpromotion_in_flight_cap — prefetch and promotion-on-hit cannot double-promoteTwo diagrams above carry the substance: the trigger flow shows the exist-probe path (no router, no pull thread), and the throttle state machine shows the dedup/cooldown semantics that replace the sketch and watermark gates. Where #3417's router RPC wants to land later,
RegisterPrefetchTaskplus the shared chain is exactly the enqueue-and-execute machinery it needs — the two are stages of one design, not competitors.Compatibility
No existing RPC signature changes; new RPCs are additive (old peers reject → no-op); read-only queries reuse pre-existing admin RPCs; all knobs default off (
enable_ssd_prefetch=false,ssd_get_wait_ms=0).Testing
Unit: throttle state machine (11), master RPC semantics (5), read-only query wrappers (4). Integration:
test_prefetch_on_exist.pywith a negative control, wired intoscripts/ci/run_ssd_offload_smoke.shwith its own master (promotion_on_hit=false). Benchmark: A/B methodology (fill → overflow → settle → measure), numbers above.@github-actions[bot] commented on GitHub (Sep 22, 2026):
Thanks for opening this issue, @DHX98!
46540437A maintainer will triage this when possible. To help us respond faster, please include:
Useful links: Documentation · Contributing guide