perf+obs(store): reuse exists→get directory lookup; count L3 prefetch probes (0.6.4) - #22
Merged
flymysql merged 2 commits intoJun 2, 2026
Conversation
SGLang's HiCache prefetch resolves a prefix in two steps -- batch_exists() to find the hit length, then batch_get() to pull those pages -- which issued two directory RPCs for the same keys. batch_exists() now fetches full locations and primes the resident hit prefix into a one-shot handoff cache; the imminent batch_get() consumes (pops) them, skipping the second lookup. Primes are popped on use and short-TTL (1s), so a consumed location is only ever as stale as the exists->get gap -- always on, never serving a location older than one prefetch handoff (unlike the opt-in directory_read_cache_ttl). Adds a directory_lookups_saved counter and a contract test asserting the get reuses primed locations and re-resolves once they are consumed. Co-authored-by: 兰州小红鸡 <flyphp@outlook.com>
read_requests==0 alone can't distinguish 'SGLang never probed L3' from 'probed but didn't fetch'. Add exists_requests (batch_exists calls) and exists_pages_found (pages reported present) so the prefetch path is observable end to end: - exists_requests==0 -> prefetch never reached the backend - exists_pages_found==0 -> probing but directory miss (key/shard) - found>0 but read_requests==0 -> found, not fetched (local hit/policy) Co-authored-by: 兰州小红鸡 <flyphp@outlook.com>
flymysql
marked this pull request as ready for review
June 2, 2026 06:14
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.
1. perf: reuse directory lookup across exists→get
SGLang's HiCache prefetch resolves a prefix in two steps —
batch_exists()(hit length) thenbatch_get()(pull pages) — which issued two directory RPCs for the same keys (theexistsbooleans were thrown away, thengetre-resolved locations). The owner lookup itself is a local consistent-hash computation (no network) and is already batched per owner, so this removes the redundant second RPC.batch_exists()now fetches full locations (non-None== present, pool or disk — same semantics as the olddirectory.exists()) and primes the resident hit prefix into a one-shot handoff cache. The imminentbatch_get()→_fetch()pops those primed locations, skipping the second lookup.Correctness: primes are popped on use and short-TTL (1s), so a consumed location is only ever as stale as the
exists→getgap (sub-ms). Always on, never older than one prefetch handoff — distinct from the opt-indirectory_read_cache_ttl(unchanged, default off). Size-capped with an expired-entry sweep. Covers v1, v2 (batch_exists_v2extra pools), and single-keyexists().New counter:
peercache_directory_lookups_saved_total.2. obs: make the L3 prefetch path observable
read_requests == 0alone can't tell why there are no reads. Added:peercache_exists_requests_total—batch_existscalls (SGLang L3 prefetch probes)peercache_exists_pages_found_total— pages reported present by those probesDecision table:
exists_requests == 0exists_pages_found == 0(probes > 0)found > 0butread_requests == 0Tests
test_exists_get_handoff_saves_directory_lookup: the get reuses all primed locations (counter += hits) and re-resolves once consumed (one-shot).Version → 0.6.4.