mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[PR #1212] [CLOSED] [Store] feat: introduce tiered backend #2075
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#2075
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?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/Mooncake/pull/1212
Author: @YiXR
Created: 12/15/2025
Status: ❌ Closed
Base:
main← Head:xinyi/tiered-backend📝 Commits (1)
92e557e[Store] feat: introduce tired backend📊 Changes
8 files changed (+986 additions, -0 deletions)
View changed files
➕
mooncake-store/include/tiered_cache/cache_tier.h(+86 -0)➕
mooncake-store/include/tiered_cache/copier_registry.h(+86 -0)➕
mooncake-store/include/tiered_cache/data_copier.h(+90 -0)➕
mooncake-store/include/tiered_cache/tiered_backend.h(+197 -0)📝
mooncake-store/src/CMakeLists.txt(+3 -0)➕
mooncake-store/src/tiered_cache/copier_registry.cpp(+41 -0)➕
mooncake-store/src/tiered_cache/data_copier.cpp(+116 -0)➕
mooncake-store/src/tiered_cache/tiered_backend.cpp(+367 -0)📄 Description
Description
This PR introduce the abstract base classes for cache tier management.
CacheTier
mooncake-store/include/tiered_cache/cache_tier.hResponsibilities
This is an abstract base class that defines the unified interface a single cache tier (e.g., DRAM, SSD) must implement. It is responsible for managing the data lifecycle on a specific storage medium.
Core Interface:
Allocate: Finds free space ofsizebytes. Does NOT copy data.Free: Releases space at offset. Used when writes fail or explicitly freeing anonymous blocks.DataCopier
mooncake-store/include/tiered_cache/data_copier.hResponsibilities:
Responsible for efficiently copying data between different memory types (
MemoryType). This is a core utility class that decouples the data movement logic.Core Functionality:
DataCopierBuilder, allowing for the registration of direct copy functions between different memory types (e.g., DRAM -> VRAM).Copyinterface. When a direct copy path is unavailable, it automatically employs a fallback mechanism using DRAM as an intermediate buffer (e.g., VRAM -> DRAM -> SSD) (when implementing a new type, compilation requires copy functions between the new type and DRAM). This greatly simplifies the integration of new storage media.TieredBackendandCacheTierhold and use aDataCopierinstance to execute all data copy operations, whether it's writing new data or moving data between tiers.TieredBackend
mooncake-store/include/tiered_cache/tiered_backend.hResponsibilities:
Serves as the Data Plane for the tiered cache. It does not contain any complex caching policies (e.g., LRU) and is solely responsible for faithfully executing data operation instructions.
Core Data Structures
DataSourceA generic descriptor for source data.
TieredLocationDescribes the physical location of a data segment.
AllocationHandleDecomposed APIs
The traditional atomic Put operation is broken down into three granular steps:
AllocateReserves storage space locally without writing data.
Usage: Called by the AllocationStrategy to find free space.
Returns: true if space is reserved; false otherwise.
Write (local operation)Writes data to a specific, reserved location.
Usage: Performs local write operation. If need remote write, please tranfer data into AllocationHandle by using TE.
Returns: true on success. If failed, the caller must free the allocated space.
CommitRegisters the key in the local metadata index.
Usage: Called after data is successfully written.
Behavior: It binds the key to the offset internally. This operation is designed to be infallible (must succeed). If an internal error occurs (e.g., OOM), it raises a fatal error.
DeleteDelete the key in the local metadata index.
If
tier_idis specified, removes only the replica on that tier. If nullopt, removes ALL replicas for this key.Allocation Workflows
This decoupled design supports two distinct allocation patterns required by the new architecture.
Each backend can only use one allocation strategy after mooncake store start up. If the backend wants to use Master-Centric Allocation, it must realize all the func to register it's info and allocator to Master.
Pattern A: Client-Centric Allocation (Local Decision)
In this mode, the Client decides where to place data (e.g., "Try DRAM first, then SSD") and later informs the Master.
Workflow
Decision
The ClientCentricStrategy calls
Allocate(size, preferred_tier=xxx).TieredBackend checks local capacity and returns a
AllocationHandle.Execution
The strategy calls
Write(data, AllocationHandle), this is a local write operation.Please use TE to transfer data if you want to do remote write.
Local Commit
The strategy calls
Commit(key, AllocationHandle).The key is now visible to local
Get()requests.Global Sync
The Client sends an asynchronous RPC
RegisterAllocationto the Master.Master updates its directory: "Key X is located at Client Y, Tier Z".
Pattern B: Master-Centric Allocation (Global Decision)
In this mode, the Master manages all resources globally (Client should still call
MountSegment()to register all the resources to Master) and tells the Client exactly where to write.Client doesn't need to save metadata for this backend anyway.
Workflow:
Request
The Client sends an RPC
PutStartto the Master.Decision
Master checks its global resource view and returns
{tier_id: 1, offset: 0x2000}.Execution
Data can be write by TE into tier directly.
Data Migration & Consistency
Migrates a key between tiers using a "Make-Before-Break" protocol to ensure strong consistency.
If DataSource is Master-Centric Allocation, Master must 'tell' Client where the data is.
Workflow:
Allocate & Write
Data is copied to the destination tier.
Sync Callback
sync_cb is invoked.
Action
The Client sends an RPC to the Master: "Update Key location to Tier New".
Safety
If this RPC fails, CopyData returns false and rolls back the new copy. The old data remains valid.
Commit
Local metadata is updated to point to the new tier.
Delete
Only after the Master is updated and local commit succeeds, the old replica need to be deleted.
If DataSource is Master-Centric Allocation, Master will delete the key by itself.
If DataSource is Client-Centric Allocation, Client must call
Delete(key)afterCopyData.Type of Change
How Has This Been Tested?
Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.