feat: doc semaphore as runtime PATCH + per-trace cache hit/miss#206
Merged
feat: doc semaphore as runtime PATCH + per-trace cache hit/miss#206
Conversation
Two changes for live-tuning the miss-path doc read bottleneck: 1. Semaphore permits tunable via PATCH doc_disk_read_permits. Default 64 (was removed to fix 14.5s convoy, but caused OOM). Uses ArcSwap to atomically replace the semaphore — in-flight permits on the old one drain naturally; new acquires hit the new. Not persisted — experiment lever. 2. QueryTrace gains docs_cache_hits + docs_cache_misses fields. Populated from both the inline path (all hits → hits=batch_size) and the spawn_blocking path (hits=total-miss_count). Enables per-query correlation of doc cache behavior with latency. Together these let us tune the convoy/OOM tradeoff live and measure the doc cache hit rate distribution per query shape. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Summary
doc_disk_read_permits) — default 64, atomic swap via ArcSwap, not persisteddocs_cache_hits+docs_cache_missesper query for correlationProblem
Session history:
Traces have
docs_us+docs_counttotal but no per-query cache hit/miss, so slow queries can't be correlated with their cache behavior.Changes
src/server.rs:DOC_DISK_READ_SEMAPHOREasArcSwap<Semaphore>, acquire viaload_full. PATCH handler swaps atomically. Per-queryAtomicU64hits/misses populated in both inline and spawn_blocking paths.src/query_metrics.rs: Two new fields onQueryTrace,#[serde(default)]for back-compat.Test plan
curl -X PATCH /indexes/civitai/config -d '{"doc_disk_read_permits": 32}'— tune down under memory pressuredocs_cache_missescount🤖 Generated with Claude Code