mirror of
https://github.com/kvcache-ai/Mooncake.git
synced 2026-11-05 01:17:55 +00:00
[PR #610] [MERGED] [Store]feat: Add 3fs native api plugin for KVCache storage persistence #1688
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#1688
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/610
Author: @SgtPepperr
Created: 7/10/2025
Status: ✅ Merged
Merged: 7/24/2025
Merged by: @stmatengss
Base:
main← Head:3fs_native📝 Commits (10+)
190cf83initial version for 3fs native api1d4c992Merge branch 'main' into 3fs_native20faa75delete redundant code in file_interface and storage_backend. Only keep api in usef110847refactor some problem63c16f2refactor file interface, add lockRAII73c4060fix some problem09b7be7fix conflict049aa8dfix test problem9eb931arm char file interface , edit filemode4c78b01edit cmake file , mkdir hf3fs in store📊 Changes
20 files changed (+1342 additions, -673 deletions)
View changed files
📝
mooncake-common/common.cmake(+5 -0)📝
mooncake-store/include/client.h(+2 -5)➕
mooncake-store/include/file_interface.h(+162 -0)➕
mooncake-store/include/hf3fs/hf3fs.h(+101 -0)➖
mooncake-store/include/local_file.h(+0 -97)📝
mooncake-store/include/storage_backend.h(+66 -29)📝
mooncake-store/src/CMakeLists.txt(+17 -2)📝
mooncake-store/src/client.cpp(+31 -16)➕
mooncake-store/src/hf3fs/CMakeLists.txt(+8 -0)➕
mooncake-store/src/hf3fs/README.md(+42 -0)➕
mooncake-store/src/hf3fs/hf3fs_file.cpp(+363 -0)➕
mooncake-store/src/hf3fs/hf3fs_resource_manager.cpp(+92 -0)➖
mooncake-store/src/local_file.cpp(+0 -224)➕
mooncake-store/src/posix_file.cpp(+151 -0)📝
mooncake-store/src/storage_backend.cpp(+109 -121)📝
mooncake-store/src/transfer_task.cpp(+11 -11)📝
mooncake-store/tests/CMakeLists.txt(+3 -3)➖
mooncake-store/tests/local_file_test.cpp(+0 -165)➕
mooncake-store/tests/posix_file_test.cpp(+174 -0)📝
mooncake-store/tests/stress_cluster_benchmark.py(+5 -0)📄 Description
Background
In the previous PR #437, the initial version of KV cache persistence and tiering functionality was implemented. However, since POSIX interfaces were used for read/write operations, the performance in testing was relatively modest.
Changes Introduced
To improve file read/write performance and make the tiered caching functionality fully viable, this PR introduces the 3fs native API(
USRBIO) into the store project as a plugin, significantly reducing the latency of performance-sensitive operations such asgetandbatchgetwhen reading files.Key Updates:
Enables high-performance read operations in 3fs scenarios
file_interfaceImproved support for both POSIX and 3fs read/write modes
Added batchput mode support for KV cache persistence
Added persistence path specification option to
stress_cluster_benchmark.pyPerformance Testing
Test Setup
stress_cluster_benchmark.py(testingbatch_put_fromandbatch_get_into)file_read_thread: 10 (consistent across tests)Test Results(3fs Native API BatchGet Throughput Comparison)
get: disk
get: disk
Problem
1. Asynchronous Write Performance Issue
Summary: Identified performance degradation in 3FS asynchronous writes and proposed solution.
Currently, persistence is achieved through asynchronous writes, but before asynchronous writing in 3FS, significant performance degradation may occur due to data copying. Profiling reveals that the number of page faults triggered in this scenario is nearly double the normal count. Future plans include introducing a reuse buffer list to address this performance degradation issue.
2. Read Path Copy Overhead
Summary: Existing read path copy mechanism and deferred optimization rationale.
Currently, the read path incurs an additional copy (iov → slice) due to 3FS's native API mechanism. This copy could be eliminated by ensuring the upper-layer slice uses shared memory (shm) and directly reuses it as the iov's address space, enabling zero-copy. However, this optimization has been temporarily postponed because it would require:
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.