Repository navigation
[perf] Reuse Mooncake buffer pool for non-tensor RDMA gets - #252
Merged
0oshowero0 merged 2 commits intoDec 2, 2026
Merged
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
Signed-off-by: 0oshowero0 <o0shower0o@outlook.com>
0oshowero0
force-pushed
the
perf/mooncake-nontensor-get-buffer-pool
branch
from
December 2, 2026 10:47
b22fd50 to
304b827
Compare
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Extend the pre-registered
BufferPoolreceive path introduced for tensors in #175 to non-tensor RDMA reads (MooncakeStoreClient._get_bytes_thread_worker).Previously,
_get_bytes_thread_workerallocated a freshuint8region and calledregister_buffer/unregister_bufferaround every 400-key batch, paying repeated kernel page-pinning and multi-HCA MR setup/teardown cost on mixed workloads (e.g.,NonTensorStackfields).Implementation
MooncakeStoreClient._get_bytes_thread_workerdirectly toself._get_tensors_thread_workerover 1-Dtorch.uint8buffers, then decode viaserial_utils.batch_decode_from(batch_buffer_tensors)after the read completes._get_tensors_thread_worker(shared by_get_bytes_thread_worker) and update the missing-BufferPoolwarning text to cover all CPU reads and puts.serial_utils.batch_decode_fromreturns zero-copy views (torch.frombuffer/np.frombuffer) for tensors and NumPy arrays embedded inside non-tensor values. Because_get_tensors_thread_workercopies from the leasedBufferPoolslab into caller-owneduint8tensors and releases the lease before returning, decoded zero-copy views never reference pooled memory, cannot blocklease.release()/BufferPool.close(), and survive subsequent buffer reuse.split_by_bytesper-worker share bounding, vectorized strided copy-out for uniform sizes, merged direct-registration fallback for oversized payloads or pool exhaustion, and unpooled behavior on TCP ormooncake-transfer-enginebuilds withoutBufferPool. No configuration or public API changes.Evaluation
Setup
Both baseline (
ffde754) and candidate (b22fd50, functionally identical to the rebased304b827which only adds a docstring and updates the missing-pool warning text) were benchmarked on the same 2-node cluster usingscripts/performance_test/perftest.pywith the cross-nodeMooncakeStoreplacement fix shipped in #251 (296250c,use_inter_node = self.backend == "Yuanrong" or (self.backend == "MooncakeStore" and self.worker_node_ip is not None)):protocol: rdma,metadata_server: P2PHANDSHAKE,device: cpu,use_gdr: falseglobal_segment_size: 80 GB,local_buffer_size: 80 GBper client (use_put_buffer_pool: true)mooncake-transfer-engine-cuda13==0.3.14, Rust Controller (--controller_backend=rust)--use_complex_case(1/3 regular tensors, 1/3 jagged nested tensors, 1/3NonTensorStackstrings; 4 iterations per size)Command (identical for baseline and candidate):
Placement log confirmed on both baseline and candidate runs:
Complex Case GET Performance
mainTop-3 GETmainAll-4 GETTop-3 excludes the single slowest GET iteration out of 4; All-4 includes the cold first iteration.
Per-iteration GET latency (seconds):
[1.913, 0.453, 0.523, 0.518]→[0.523, 0.392, 0.397, 0.395](cold iteration cut by 72.7%)[5.922, 5.297, 6.415, 5.868]→[6.235, 5.528, 5.288, 5.661][30.441, 29.688, 26.653, 27.903]→[25.865, 25.011, 26.143, 25.367]Key observations & known workload boundaries:
msgspecstring decoding (~19.66 GB of strings) andTensorDictassembly rather than RDMA MR registration; eliminating dynamic MR registration still reduces steady-state Large GET latency by ~9.5–10.7% and removes multi-HCA MR registration tail spikes.--use_complex_casegenerates equal-lengthNonTensorStackstrings that hit the vectorizeduniform=Truecopy-out fast path in_copy_between_buffer_and_tensors; real variable-length non-tensors take the per-item ragged copy loop (inherited from [optim] Lease pre-registered receive buffers on the MooncakeStore read path #175)._pool_share_bytes) or mid-batch pool exhaustion occur in a variable-length batch,split_by_bytesreorders by size so fallback slots can be non-contiguous in the backing buffer, resulting in multipleregister_buffercalls rather than one (also shared with ragged tensors in_get_tensors_thread_worker). Both workload boundaries will be tracked as dedicated follow-ups.Validation
tests/test_mooncake_buffer_pool.pycovering:client.get()with zeroregister_buffercalls;torch.Tensor/np.ndarraysurviving pool arena reuse andclient.close();split_by_bytesslicing, oversized-item direct-registration fallback, and single-pass fallback on pool exhaustion;BufferPoolfallback paths;python -m compileall -q transfer_queue tutorial tests.pytest -q tests/test_mooncake_buffer_pool.py(38 passed) after rebasing ontomain(296250c).ruff,ruff format,mypy, license header check, docstring check).