Add fragmentation-aware allocation strategy for Mooncake Store#2797
Add fragmentation-aware allocation strategy for Mooncake Store#2797Lorry1024 wants to merge 4 commits into
Conversation
|
Warning Gemini encountered an error creating the review. You can try again by commenting |
|
Thanks for the proposal. One concern is that production workloads usually have only one or two object sizes, so the object-size distribution is much narrower than the mixed-size workload assumed here. Given that, fragmentation pressure may be limited in practice, so maybe it's not necessary to add and maintain a separate |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in Mooncake Store allocation strategy (fragmentation_aware) that favors segments with a fit-capable largest contiguous free region (to reduce allocation failures under fragmentation), while preserving the existing bounded sampling + fallback behavior.
Changes:
- Introduces
AllocationStrategyType::FRAGMENTATION_AWAREandFragmentationAwareAllocationStrategy, and wires it through config/CLI and strategy factory. - Adds unit tests and benchmark coverage for the new strategy.
- Documents the strategy’s intended use cases, ranking logic, and deployment flag.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mooncake-store/include/allocation_strategy.h | Implements FragmentationAwareAllocationStrategy and registers it in CreateAllocationStrategy. |
| mooncake-store/include/types.h | Adds AllocationStrategyType::FRAGMENTATION_AWARE. |
| mooncake-store/include/master_config.h | Parses allocation_strategy=fragmentation_aware and updates validation messaging. |
| mooncake-store/src/master.cpp | Updates --allocation_strategy flag help text to include fragmentation_aware. |
| mooncake-store/tests/allocation_strategy_test.cpp | Expands parameterized coverage and adds targeted fragmentation/preferred-segment tests. |
| mooncake-store/benchmarks/allocation_strategy_bench.cpp | Adds the new strategy to benchmark naming and benchmark matrices. |
| docs/source/design/mooncake-store.md | Documents the new strategy’s design and selection guidance. |
| docs/source/deployment/mooncake-store-deployment-guide.md | Documents the deployment flag usage for fragmentation_aware. |
| .github/workflows/ci.yml | Adds a disk-reclaim step before Go store binding integration tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| SSD_FREE_RATIO_FIRST, // SSD free-ratio-first allocation | ||
| LOCAL_FIRST // Prefer local host before ordered remote fallback | ||
| LOCAL_FIRST, // Prefer local host before ordered remote fallback | ||
| FRAGMENTATION_AWARE // Fragmentation-aware allocation | ||
| }; |
| A fragmentation-aware variant for mixed-size KV cache workloads. It uses the same bounded candidate sampling shape as `free_ratio_first`, but adds a contiguous-fit signal before ranking by score: | ||
|
|
||
| 1. **Preferred segment phase**: Same as `random` and `free_ratio_first`; explicit preferred segments are tried before sampled candidates. | ||
| 2. **Sampling phase**: Randomly picks a starting index and takes `min(6*remaining_replicas, total_segments)` consecutive segments as candidates. |
yokinoshitayoki
left a comment
There was a problem hiding this comment.
Thanks for continuing to work on this, but I don’t think we should merge this PR as-is.
My main concern from the previous comment still stands: our production workloads typically use only one or two object sizes, so the mixed-size fragmentation scenario targeted by fragmentation_aware does not match our current production workload well.
Also, the CI disk cleanup change seems unrelated to the allocation strategy itself and should not be bundled into this PR.
Given the current evidence, I’d prefer not to add another allocation strategy. If we want to revisit this later, I think we may need to first provide representative production traces or benchmarks showing a concrete fragmentation problem under our workload.
Summary
This PR adds an opt-in Mooncake Store allocation strategy named
fragmentation_awarefor mixed-size KVCache workloads. The strategy keeps bounded candidate sampling, but ranks sampled segments by whether their largest contiguous free region can satisfy the current request before considering aggregate free ratio.Why
In long-running Store pools, aggregate free space can be split into fragmented holes. A segment may report a higher total free ratio while failing a large allocation because no contiguous region is large enough. This creates avoidable allocation attempts and fallback pressure.
Changes
AllocationStrategyType::FRAGMENTATION_AWARE.FragmentationAwareAllocationStrategy.--allocation_strategy=fragmentation_aware.allocation_strategy_bench.Validation
git diff --checkgit apply --checkagainst current upstreamBoundaries
The default allocation strategy remains unchanged. This PR does not redesign SGLang HiCache, RDMA transport, or Mooncake HA. Full upstream CI, RDMA validation, and real SGLang HiCache benchmark should still be run in a production-like environment before claiming end-to-end throughput gains.