From 84fc6320880f218061b26eb2afbd987c94b09f95 Mon Sep 17 00:00:00 2001 From: "minke.yu" Date: Sat, 10 Oct 2026 16:42:00 +0800 Subject: [PATCH] =?UTF-8?q?mooncake=5Fstore:=20local=5Fhostname=20?= =?UTF-8?q?=E5=8A=A0=20rank=20=E5=90=8E=E7=BC=80=EF=BC=8C=E8=AE=A9=20maste?= =?UTF-8?q?r=20=E7=9A=84=20preferred-segment=20=E5=88=86=E9=85=8D=E8=90=BD?= =?UTF-8?q?=E5=88=B0=E6=9C=AC=E8=BF=9B=E7=A8=8B=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 两个 rank 进程共用默认 localhost 时,master 按名字匹配无法区分两个段, 副本会落到对方进程段;mooncake 的 local memcpy 快路径要求同进程 endpoint (跨进程虚拟地址无效),于是静默回退 loopback TCP(实测 ~0.78GB/s)。 唯一化后自写自读可命中 memcpy(干净集群探针实测 lo 流量归零)。 注意:memcpy 线程池 kDefaultMemcpyWorkers=1(mooncake 0.3.13 硬编码), 单流 ~1GB/s,进一步提升需改 mooncake 并重编译。 --- .../storage/mooncake_store/mooncake_store.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py b/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py index 25f22fa0b9..0511519a05 100644 --- a/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py +++ b/python/sglang/srt/mem_cache/storage/mooncake_store/mooncake_store.py @@ -515,6 +515,22 @@ class MooncakeStore(HiCacheStorage, MooncakeBaseStore): else: client_hostname = self.config.local_hostname transfer_engine = None + # Each rank embeds its own Mooncake client process. Giving + # every rank the same local_hostname makes the master's + # preferred-segment allocation unable to tell their + # segments apart, so replicas can land on a peer rank's + # segment and the local-memcpy fast path (which requires + # same-process endpoints) silently falls back to TCP. + # Make the hostname unique per rank so own-writes land on + # the own segment and reads can use local memcpy. + if storage_config is not None: + client_hostname = ( + f"{client_hostname}" + f"-d{storage_config.dp_rank}" + f"t{storage_config.tp_rank}" + f"p{storage_config.pp_rank}" + f"c{storage_config.attn_cp_rank}" + ) setup_kwargs = {} if self.config.enable_ssd_offload: