Repository navigation
Conversation
… counters (kvcache-ai#5458) Implements Track 1 observability for kvcache-ai#5458: - Track bounded-window prefetch attribution on route::ObjectState (prefetch_usefulness_window_ms, default 300000ms) across NotifyPromotionSuccess, ReadReplicaList/ReadFollowUps (real Get only, counted at most once), ImmediateReclaimer/OpLogReclaimer (evicted before use), and RegisterPrefetchTask/PromotionAllocStart (dropped under pressure). - Export zero-per-key-label Prometheus counters in MasterMetricManager and SsdMetric::serialize(). - Implement OffsetAllocatorStorageBackend::GetObjectDataSize(). Signed-off-by: dhx98 <haox.dai@gmail.com>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27e3b6ed55
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (served_from_prefetched_mem) { | ||
| follow_ups.ConsumePrefetch(tenant_id, key, target_id); |
There was a problem hiding this comment.
Exclude write-side metadata probes from Get attribution
If a duplicate Client::Put targets a prefetched key, healDanglingLocalDiskReplica() unconditionally calls GetReplicaList (client_service.cpp:2322) before checking whether a MEMORY replica exists. That metadata-only lookup reaches this block, increments served_by_get, and clears the attribution even though no Get or data transfer occurred; batch-Put healing has the same problem. This also prevents a subsequent eviction from being counted as unused, biasing the usefulness measurements. Move these non-read callers to the read-only lookup path or otherwise distinguish them before consuming attribution.
Useful? React with 👍 / 👎.
| accessor.GetState().prefetch_attribution = | ||
| route::ObjectState::PrefetchAttribution{ | ||
| .replica_id = staged_replica_id, | ||
| .bytes = completed_bytes, | ||
| .promoted_at = std::chrono::steady_clock::now()}; |
There was a problem hiding this comment.
Expire unused attribution when the usefulness window elapses
For prefetched keys that remain resident but are never read, this record survives indefinitely after the usefulness window expires. Its only processing paths are ConsumePrefetchAttribution and AccountPrefetchEvictedBeforeUse, which require a later lookup or eviction; the background cleanup paths do not expire it. Consequently, master_prefetch_expired_unconsumed_total remains zero for precisely these unused prefetches, and the tracking allocation lasts for the object's lifetime rather than the configured window. Add expiry processing independent of subsequent reads or eviction.
Useful? React with 👍 / 👎.
| const size_t remaining = keys.size() - i - 1; | ||
| int64_t dropped_bytes = size > 0 ? size : 0; |
There was a problem hiding this comment.
Account for pressure-skipped keys in the outer batch
When a multi-key prefetch hits DRAM pressure, the production caller RegisterAndPromote() invokes PrefetchKeys({keys[i]}, {sizes[i]}) one key at a time and then breaks its own loop on pressure. Therefore, remaining here is always zero on that path, and all unattempted keys in the outer batch disappear from the new dropped-count and dropped-byte metrics. An isolated probe using these functions confirmed that a four-key request totaling 10,240 bytes reports only one dropped key and 1,024 bytes when the first allocation fails. Account for the outer batch's remainder where that loop aborts.
Useful? React with 👍 / 👎.
| // 0 disables usefulness attribution. | ||
| uint64_t prefetch_usefulness_window_ms = 300000; |
There was a problem hiding this comment.
Load the usefulness-window setting during master startup
Setting prefetch_usefulness_window_ms: 0 or another window in the master's configuration file has no effect. The standalone master's InitMasterConf() explicitly loads configuration fields but never reads this new one, and LoadConfigFromCmdline() does not assign it either. Normal startup therefore always passes the default 300000 to the service; disabling attribution or tuning the measurement window only works for callers that construct the configuration programmatically. Wire the setting into the production configuration-loading path alongside these struct additions.
Useful? React with 👍 / 👎.
Description
Addresses #5458 ("Measure whether prefetch was useful") with zero RPC wire/signature changes and zero per-key Prometheus labels.
Changes
route::ObjectState,master_config.h,master_service.cpp,master_metric_manager.h/.cpp):prefetch_usefulness_window_ms(default300000 ms, configurable via master config / CLI flag).ObjectState::PrefetchAttributiononNotifyPromotionSuccesswhen the completed task originated from prefetch (from_prefetch), incrementingmaster_prefetch_promoted{_bytes}_total.Getreads inReadReplicaList/ReadFollowUps(excludingExistKeyand read-only admin queries, counted at most once per prefetched promotion), incrementingmaster_prefetch_served_by_get{_bytes}_total(ormaster_prefetch_expired_unconsumed{_bytes}_totalif past the usefulness window).ImmediateReclaimerandOpLogReclaimerto recordmaster_prefetch_evicted_before_use{_bytes}_totalwhen a prefetchedMEMORYreplica is evicted before anyGetconsumes it.master_prefetch_dropped_under_pressure{_bytes}_totalonRegisterPrefetchTask/PromotionAllocStartbackpressure rejections.SsdMetricPrometheus export (client_metric.h):mooncake_ssd_prefetch_{complete,complete_bytes,fail,dropped_pressure,dropped_pressure_bytes}_totalintoSsdMetric::serialize()so holder-side prefetch outcomes are visible on/metrics.OffsetAllocatorStorageBackend::GetObjectDataSize()(storage_backend.h/.cpp):GetObjectDataSize()onOffsetAllocatorStorageBackendso SSD prefetch size discovery works beyondBucketStorageBackend.Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
-DUSE_ASCEND_DIRECT=ONon Ascend 950DT):prefetch_task_master_test(added 4 tests coveringserved_by_getat-most-once +ExistKeyexclusion,evicted_before_use,expired_unconsumed, anddropped_under_pressure) — PASSpromotion_on_hit_test,prefetch_throttle_test,prefetch_teardown_test,ssd_metrics_test,storage_backend_test(49/49OffsetAllocatorStorageBackendtests) — ALL PASS/metricsE2E (Ascend 950DT host,mooncake_master --metrics_port=...+mooncake_client --enable_http_server=true):master_prefetch_promoted_total=1 (1,048,576 B),master_prefetch_served_by_get_total=1 (1,048,576 B)(unchanged byis_existand a secondget),mooncake_ssd_prefetch_complete_total=1, NVMe 1 MiB read latency113 us.master_prefetch_promoted_total=1 (1,048,576 B),master_prefetch_served_by_get_total=0,master_prefetch_evicted_before_use_total=1 (1,048,576 B),mooncake_ssd_prefetch_complete_total=1, NVMe 1 MiB read latency116 us.Test commands:
ctest --test-dir build --output-on-failure -R "^(prefetch_task_master_test|promotion_on_hit_test|prefetch_throttle_test|prefetch_teardown_test|ssd_metrics_test|storage_backend_test)$" ./scripts/code_format.sh --check --changed-lines --base origin/mainTest results:
/metricsverification)Checklist
Signed-off-bytrailer certifying the DCO./scripts/code_format.shAI Assistance Disclosure