Commit Graph

5 Commits

Author SHA1 Message Date
Chuang Zhang 75315dedaf
[Store] Fix stale hot cache reuse after object removal (#2447)
Co-authored-by: Le1zyCatt <148605186+Le1zyCatt@users.noreply.github.com>
Co-authored-by: wangyuqi0429 <82140563+wangyuqi0429@users.noreply.github.com>
2026-06-16 11:56:03 +08:00
Guocheng(Eric) Song d95a93231c
[Store] Fix local hot cache rejecting larger objects after block reuse (#2466)
LocalHotCacheHandler::SubmitPutTask admitted a slice into a recycled block
by comparing slice.size against block->size. But block->size holds the
*logical* length of the last object stored in the block (and is relied upon
as the object length on the read path), and GetFreeBlock() does not reset it
when a block is reused. As a result, once a block had cached a small object
it would permanently reject any larger object, silently shrinking each block
to the smallest size it ever held and degrading hot-cache hit rate on
mixed-size workloads.

Compare against the fixed block capacity (GetBlockSize()) instead. The
logical-size semantics of block->size are unchanged.

Add a regression test (RecycledBlockAcceptsLargerObject) that fills a
single-block cache with a small object, then submits a larger object to force
block reuse and asserts it is admitted.
2026-06-15 16:13:56 +08:00
Wenxiao Chen 3f249c5a72
[STORE] feat: Frequency admission + LRU lock optimization for local hot cache (#1596)
---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 13:50:56 +08:00
EkiRui 8ed67617e8
[Store] Enable dummy client zero-copy get_buffer via shared hot cache (#1535)
* [Store] enable dummy client zero-copy get_buffer via shared hot cache

- Extract ShmHelper into standalone shm_helper.h/cpp for reuse
- Convert LocalHotCache allocation from malloc to memfd (use_shm mode)
- Add IPC protocol for dummy clients to request hot cache fd from real client
- Add acquire/release RPC for hot cache (ref_count based lifecycle)
- Add acquire/release RPC for allocator-backed buffers (dummy path)
- Add batch variants for hot cache and allocator acquire RPCs
- Extend BufferHandle with view mode (non-owning, custom release callback)
- Implement DummyClient::get_buffer with hot cache fast path + allocator fallback
- Unify store_py.cpp get() to use get_buffer for both real and dummy clients
- Remove obsolete get_buffer_info virtual interface

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] enable dummy client get_buffer/batch_get_buffer in Python bindings

Remove use_dummy_client_ guards that blocked get_tensor, batch_get_tensor,
and batch_get_buffer for dummy clients, now that dummy supports these APIs
via shared hot cache + allocator fallback.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] fix batch_get_buffer_internal to use dummy's allocator

batch_acquire_buffer_dummy was calling batch_get_buffer_internal without
passing the dummy's allocator, causing buffers to be allocated in the
real client's memory instead of the dummy's shm region. Add optional
client_buffer_allocator parameter to batch_get_buffer_internal and pass
it from batch_acquire_buffer_dummy.

Also add is_hot_cache_ptr() to DummyClient for verifying whether a
pointer falls within the hot cache shm region.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] add dummy client get_buffer/batch_get_buffer unit tests

Test correctness, hot cache shm path, allocator fallback, and
performance with 500 MB per key, 7 GB batch.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] allow local data into hot cache when shm mode is active

In shm mode the hot cache is shared with dummy clients via IPC, so
local data must also be cached for zero-copy access. Add IsShm()
accessor to LocalHotCache and gate the local-skip filter in
ProcessSlicesAsync on non-shm mode only.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] rename hot cache env vars to MC_STORE_ prefix

Align LOCAL_HOT_CACHE_SIZE, LOCAL_HOT_BLOCK_SIZE, and
LOCAL_HOT_CACHE_USE_SHM with the project-wide MC_STORE_ naming
convention. Also use IsReplicaOnLocalMemory() for correct local
detection under P2PHANDSHAKE mode, and gate hot cache shm mode
behind MC_STORE_LOCAL_HOT_CACHE_USE_SHM=1 (default off).

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] real client: add  bounds check, IPC auth, recv timeout, lambda fix

- Validate offset + size <= hot_cache_size_ in get_buffer/batch_get_buffer
- Authenticate client_id in handle_ipc_shm_fd_request against registered dummies
- Add SO_RCVTIMEO (5s) on IPC server client sockets to prevent blocking
- Fix lambda in batch_get_buffer to capture key directly instead of growing vector

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] reduce test payload sizes for CI memory constraints

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

---------

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>
2026-02-25 14:34:37 +08:00
Shichang Zhang f21b3791ac
[Store] Add Local Cache Mechanism for Mooncake Store Client (#1226)
* feat(Store): add local hot cache for client

* feat(Store): add client local hot cache log to show performance

* fix: local hot cache initialize bug

* fix(Store): Mooncake put slice is max 16MB, so make local hot cache block 16MB

* feat(Store): move local hot cache initialization to Client::Create

* feat(Store):  local hot cache remove unused small block implementation

* feat(Store): add client local hot cache unit test

* fix(Store): modify client local hot cache suit with v0.3.7

* feat(Store): change local hot cache unit tes

* fix: initialize local hot cache with negative value

* feat: use in process master and metadata fro local hot cache unit test.

* feat: update local hot cache to one replica one slice version

* fix: local hot cache unit test use in process master service

* fix: code style fix

* fix: fix dirty read when client wants to read a previously hitted hot block but the hot block is modified by incoming put actions

* fix: local hot cache unit test use in process master service

* fix: code format fix

* fix: fix comment problems for

* feat: add local hot asynchronous queue size limit

* fix: local hot cache task involves the block so that there is no memcpy operation when inserting local hot cache

* fix: code check fix

* fix: update block in_use prop to reference count

---------

Co-authored-by: shichangzhang064 <zhangshichang@h-partners.com>
2026-02-11 15:34:52 +08:00