Repository navigation
[Store] POSIX support read DFS replicas straight into host buffers - #5201
Conversation
5d3aae4 to
d06af54
Compare
|
The scope looks reasonable: removing RealClient staging for host reads through the current buffered POSIX adapter is a useful, self-contained optimization. Extending this to 3FS or adding O_DIRECT support can be handled separately. One non-blocking suggestion: could we query an adapter capability instead of checking GetName() == "posix"? The capability should describe whether reads accept arbitrary writable host addresses, lengths, and file offsets without caller-provided alignment or padding. Only the current POSIX implementation needs to opt in for this PR. This would preserve flexibility for a future O_DIRECT mode, where the adapter name stays the same but buffer requirements may change. The adapter could handle alignment internally or expose the relevant constraints. It would also let other adapters opt in later without adding backend-specific checks to RealClient. |
d06af54 to
6856416
Compare
Thanks, agreed. Switching from the name check to a capability query makes sense. I've added SupportsArbitraryHostReadBuffers() to FileSystemAdapter, and only PosixFsAdapter opts in. |
6856416 to
c278aea
Compare
fcczzz
left a comment
There was a problem hiding this comment.
Thanks, this addresses my suggestion. The capability describes the caller-facing contract, so keeping it true makes sense if the adapter handles alignment internally. An internal staging fallback is compatible with that contract and still avoids redundant staging in RealClient.
LGTM for this PR, pending successful CI.
A separate PR for the direct I/O implementation sounds good. We can review the alignment handling and fallback paths there, including unaligned buffer addresses, lengths, and file offsets.
Signed-off-by: sunbaoshan <sunbaoshan@baidu.com>
c278aea to
b2f827d
Compare
* upstream/main: (28 commits) [Store] Remove unreachable dead code in reserved OpLog paths (kvcache-ai#5043) [Store][BUGFIX]: Avoid repeated NoF cleanup for unregistered buffers (kvcache-ai#5301) [Store] Fence the local disk tier on the first unrecoverable disk error (kvcache-ai#4490) [Store] Add opt-in aligned O_DIRECT bucket writes (kvcache-ai#4820) [Store] posix support Read DFS replicas straight into host buffers (kvcache-ai#5201) [TENT] Pipeline RDMA slice preparation with worker posting (kvcache-ai#5277) [TE] HipTransport: submit copies asynchronously, one stream and event per device (kvcache-ai#4953) [Misc] Add staryxchen as a HIP transport code owner (kvcache-ai#5351) [Doc] nvlink_intra works over PCIe P2P, not only NVLink (kvcache-ai#5266) [Bugfix][TENT] Propagate io_uring staging copy failures (kvcache-ai#5335) [Bugfix][TENT] Make UB batch submission all-or-nothing (kvcache-ai#5274) Add store rs tone tests (kvcache-ai#5282) [EP] Validate XPU Buffer constructor arguments (kvcache-ai#5329) [EP] Decouple PG builds and add TCPStore bootstrap (kvcache-ai#5312) [Bugfix][PG] Serialize RPC socket operations and drain shutdown (kvcache-ai#5098) [EP] Enable the native XPU EP over RDMA (kvcache-ai#5207) [Store] Use the AWS default credential chain when S3 static keys are unset (kvcache-ai#5303) [Bugfix][Store] Register dummy query RPC handlers in mooncake_client (kvcache-ai#5200) [Store] Preserve variadic RPC compatible fields with NDEBUG (kvcache-ai#5269) [TransferEngine] Avoid false CQ timeout diagnostics after idle periods (kvcache-ai#5281) ...
Description
RealClientread APIs (get_into,get_into_range(s),batch_get_into,batch_get_into_multi_buffers) write an object into a caller-owned buffer. How the bytes get there depends on the type of replica thatSelectBestReplicapicks:Client::Get/Client::BatchGetpoint at the caller's buffer and the transfer lands there directly.DistributedStorageBackend) were always staged:RealClientallocated a temporary buffer fromclient_buffer_allocator_, read the object into it, then copied it into the caller's buffer withscatter_host_to_maybe_device.Memory and NOF reads go through the transfer engine. The transport writes each slice to exactly the address and length it is given. It also already handles device memory, either through GPUDirect or through registered buffers. Nothing between the replica and the caller's buffer requires a particular buffer shape.
DFS reads were handled together with DISK replicas as "file-backed" reads. For that whole group, a generic read path cannot assume the backend can write into arbitrary caller memory:
preadv()and the file system SDKs cannot write into GPU or NPU memory. The bytes must land in host memory first and then be copied H2D.file_storage) read withO_DIRECT. That requires aligned buffers and rounds the read up past the object size.batch_get_into_multi_buffers).Staging was the conservative choice that works for all of these cases at once. None of the constraints above apply when the DFS backend uses the POSIX fs adapter and the destination is host memory:
PosixFsAdapteropens shard files withoutO_DIRECT(O_RDWR | O_CLOEXEC).ReadAtis a buffered::preadv()that can target any host address, at any alignment.DistributedStorageBackend::BatchReadbuilds iovecs from the caller's slices and clamps each one tomin(slice.size, remaining). A full read therefore covers exactlyobject_sizebytes, and a ranged read covers exactly the requested window. The request is rejected (INVALID_PARAMS) if the slices do not cover the object, or if any slice has a null pointer with a nonzero size. The on-disk padding up toaligned_sizeis never written into the caller's buffer.TransferAllkeeps issuingpreadv()until the full length has been read, and fails on zero progress.Client::Get/Client::BatchGet/BatchReadFileReplicaRangesentry points as the staged path. Object checksum verification (VerifyObjectChecksum, bounded toobject_sizeand reading host pointers directly) and the lease-expiry check run exactly as before. The read is reported successful only after those checks pass.Two cases still need staging, and this PR keeps it for them:
FindDeviceForPointer.IOV_MAXdestination buffers for one key. Each buffer becomes one iovec, andpreadv()rejects more thanIOV_MAXiovecs withEINVAL.Benchmark. RealClient reads of DFS-only objects into host buffers. Local NVMe, 1 GiB read per pass, 3 passes, batch 16, 8 chunks for multi_buffers, warm page cache, 0 errors. Values are GB/s, baseline → this PR.
1 thread:
8 threads:
Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Test commands:
ninja -C build cd build/mooncake-store/tests ./pybind_client_test ./dfs_posix_test ./object_storage_adapter_test ./dfs_sync_client_test ./real_client_direct_read_testTest results:
Checklist
Signed-off-bytrailer certifying the DCO./scripts/code_format.shAI Assistance Disclosure