mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[GH-ISSUE #2491] [Store] Add shard-grouped BatchPutStart fast path and benchmark shard traversal order #661
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#661
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 @bitborne on GitHub (Jun 16, 2026).
Original GitHub issue: https://github.com/kvcache-ai/Mooncake/issues/2491
Originally assigned to: @bitborne on GitHub.
Describe your performance question
Background
#2221, #2272, and #2405 showed that Mooncake Store batch metadata paths should avoid behaving like N independent single-key operations.
#2405 optimized
BatchExistKeyby grouping keys by metadata shard, batching group-route lookup, routing the RPC wrapper to the real batch path, and scanning lookup shards in the opposite direction fromBatchEvict.BatchPutStartstill does not have a comparable master-side batch fast path.WrappedMasterService::BatchPutStartcurrently loops over keys and calls single-keyMasterService::PutStart.Problem
For a batch of N puts, the current implementation effectively performs N independent
PutStartoperations.This repeats:
snapshot_mutex_shared-lock acquisition;getMetadataShardIndex(...);When many keys in a batch touch the same shard, this creates avoidable lock churn. It can also contend with lookup, remove, and eviction paths during refill/put-heavy workloads.
Implementation Plan
Add a real
MasterService::BatchPutStartpath and routeWrappedMasterService::BatchPutStartto it.The batch path should:
group_routing_mutex_once while routing the batch, following the #2405 pattern;AllocateAndInsertMetadata(...)instead of duplicating allocation and insertion logic.For grouped keys where
lookup_shard != target_shard, keep the existing single-key behavior: check and clean up the lookup shard first, then insert/check again under the target shard.Shard traversal order should be benchmarked, not assumed. #2405 uses reverse shard traversal for lookup because it interacts with
BatchEvict's forward scan.BatchPutStarttakes write locks, so natural touched-shard order and randomized reverse shard order should be compared before choosing one.Tests
Follow the test style used in #2405:
./scripts/code_format.shcmake --build build --target master_service_test mooncake_master -j$(nproc)ctest --test-dir build -R '^master_service_test$' --output-on-failureSuggested unit coverage:
OBJECT_ALREADY_EXISTS;MasterService::BatchPutStart;prefer_alloc_in_same_nodebehavior remains compatible.Benchmark
The PR should add or extend a master-side benchmark for
BatchPutStart.Existing benchmarks are not enough to isolate this path:
master_benchmeasuresBatchPutStart + BatchPutEndand only reports ops/s;store_kv_bench.pymeasures end-to-end put, including transfer and PutEnd.The benchmark should measure
BatchPutStartstart-only latency and throughput.Suggested benchmark dimensions:
Acceptance Criteria
WrappedMasterService::BatchPutStartuses a real master-side batch path.group_routing_mutex_acquisition.BatchPutStartand compares shard traversal order.Before submitting a new issue...
@github-actions[bot] commented on GitHub (Jun 16, 2026):
Thanks for opening this issue, @bitborne!
177341921A maintainer will triage this when possible. To help us respond faster, please include:
Useful links: Documentation · Contributing guide