Port SHM non-GPU transport to cpu_context_pickle branch and fix correctness gaps from #278 review#280
Conversation
Agent-Logs-Url: https://github.com/hlin99/LMCache/sessions/661cbeee-d0d4-40ef-9312-4044e4696a51 Co-authored-by: hlin99 <73271530+hlin99@users.noreply.github.com>
Agent-Logs-Url: https://github.com/hlin99/LMCache/sessions/661cbeee-d0d4-40ef-9312-4044e4696a51 Co-authored-by: hlin99 <73271530+hlin99@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
…//github.com/hlin99/LMCache into copilot/sub-pr-278 # Conflicts: # lmcache/v1/multiprocess/server.py # tests/v1/multiprocess/test_non_cuda_context.py Co-authored-by: hlin99 <73271530+hlin99@users.noreply.github.com>
hlin99
left a comment
There was a problem hiding this comment.
Review: PR #278 + #280 Combined
整体质量不错,#280 修复了大部分 #278 review 中的问题。还有两个残留需要处理:
🟡 Issue 1: prepare_store 空 reserved 时仍存 entry 到 _pending_shm_writes,导致微量内存泄漏
当 reserve_write 返回空 dict(key 全部已存在),reserved_keys = [],slots = []。
当前行为链:
- Server
prepare_store→ 存_pending_shm_writes[transfer_key] = [],返回{"slots": []} - Worker
prepare_store→ 检测到空 slots,返回None(✅ #280 已修复) - Worker 不调用
commit_store - Server 侧
_pending_shm_writes中的空 entry 永远不会被 pop
虽然每个泄漏 entry 很小,但长时间运行 + 大量重复 prompt 会持续累积。
建议修复(server.py prepare_store):
# 在 "transfer_key = ..." 之前加:
if not reserved_keys:
return PrepareStoreResponse(context={})
这样 worker 收到空 context(无 "slots" key),直接返回 None,server 也不存空 entry。同时避免了多余的 reserve_write → 空 dict → 遍历的开销。
🟡 Issue 2: MixedMemoryAllocator(shm_name=...) 参数兼容性未验证
memory_manager.py 中 create_memory_allocator 调用:
Python
return MixedMemoryAllocator(
config.size_in_bytes,
align_bytes=config.align_bytes,
shm_name=shm_name,
)
如果 MixedMemoryAllocator.__init__ 没有 shm_name 参数,SHM 模式初始化时会直接 TypeError crash。请确认 MixedMemoryAllocator 是否已支持该参数,如果不支持需要在本 PR 中添加。When reserve_write returns empty (all object keys already cached),
return PrepareStoreResponse(context={}) immediately without storing
an entry in _pending_shm_writes. This prevents leaked entries that
would never be popped since the worker won't call commit_store.
Agent-Logs-Url: https://github.com/hlin99/LMCache/sessions/182111d5-1737-49c0-be65-0287d5b9d6c5
Co-authored-by: hlin99 <73271530+hlin99@users.noreply.github.com>
Fixed both issues in 338abb7: Issue 1: Restored the early-return in Issue 2: Verified — |
Uh oh!
There was an error while loading. Please reload this page.