Repository navigation
[Store] Add opt-in bounded local streaming SSD restore and per-client offload read pool - #5788
Open
MaskVulcan wants to merge 11 commits into
Open
MaskVulcan wants to merge 11 commits into
MaskVulcan wants to merge 11 commits into
Conversation
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add portable POSIX pread bounded streaming read pipeline (ReadSource, ReadPipeline, ThreadedPipelineDriver, BoundedExecutor with WaitSubmit backpressure) and wire FileStorage::ReadLocalStreaming into RealClient whole and ranged local CPU restore paths under MOONCAKE_OFFLOAD_LOCAL_STREAMING_READ. Includes ranged read fallback safety for unregistered CPU user buffers, shared-mutex close drain, O_NONBLOCK clearing after regular-file validation, aligned direct short-read continuation, unit/integration tests, and design docs. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Add optional io_uring streaming read executor and pipeline driver (UringReadExecutor, UringPipelineDriver) with fixed-buffer support, EBUSY/EINTR/EAGAIN retry handling, short-read continuation, liburing 2.1 user_data compatibility, atomic WaitForEvent ready/active check, ARM64 SYS_ppoll fallback in fault fixture, and CTest/ASan/UBSan coverage. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
This was referenced Nov 24, 2026
Collaborator
Author
|
@qoder please review this PR |
MaskVulcan
force-pushed
the
ssd/pr2-local-streaming-io
branch
2 times, most recently
from
November 24, 2026 17:51
db4c7d3 to
50e95ed
Compare
Address adversarial review findings across local streaming restore and io_uring: - Guard both can_use_pinned_restore_arena and local streaming under offload_rpc_drain_ in RealClient::execute_ranged_read, avoid holding offload_rpc_drain_ across outbound remote peer RPCs, null-guard file_storage_/client_ in offload RPC handlers, and skip redundant local streaming retries after fallback. - Propagate sys_errno from PosixReadSource and io_uring read completions to NotifyDiskError/OnDiskError, respect disk_fenced_, validate backend type via dynamic_cast, reject overlapping destinations before source acquisition or max_chunks checks, merge multi-object batches into a single multi-source ReadPlan/driver with graceful slot degradation and expired-lease reaping on slot miss, check Start/Drain returns defensively, and map plan limits to NO_AVAILABLE_HANDLE for clean fallback. - Probe IORING_OP_READ/IORING_OP_READ_FIXED via io_uring_get_probe_ring so pre-5.6 kernels cleanly fall back to POSIX pread, expose UringReadExecutor::healthy(), make UringReadExecutor::Impl::Fail() idempotent, flush retries inline in both UringReadExecutor and UringPipelineDriver, keep shutdown drain retrying short reads/EINTR, retry io_uring_unregister_buffers on EINTR, validate O_DIRECT alignment on local-ring reads, clamp Wait() deadlines against signed overflow in both drivers, return kInvalidArgument for null sources, cap read lengths at INT_MAX with saturating object-end arithmetic, and gate UringPipelineDriver::Create cleanly. - Fix uint64_t/size_t deduction on 32-bit/macOS in file_storage_config.cpp, keep the deterministic fault test liburing fixture independent of distro <linux/io_uring.h> versions, and link ssd_uring_read_executor_contract_test standalone for BUILD_SHARED_LIBS=ON. - Harden io_uring and config/storage tests with opcode/RLIMIT_MEMLOCK/ O_DIRECT probes, safe RAII teardown ordering, WaitAccepted synchronization, default config assertions, and regression coverage for unhealthy/unsupported-opcode executors, disk fencing, plan limits, overlap precedence, multi-object uring/degraded-slot batches, and lease GC. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
MaskVulcan
force-pushed
the
ssd/pr2-local-streaming-io
branch
from
November 24, 2026 19:37
50e95ed to
1a86b58
Compare
MaskVulcan
marked this pull request as ready for review
November 25, 2026 03:13
MaskVulcan
requested review from
Aionw,
ShangmingCai,
UNIDY2002,
XucSh,
YiXR,
stmatengss and
ykwd
as code owners
November 25, 2026 03:13
Replace the process-global coro_io::io_context_pool used by offload restore RPC reads with a RealClient-owned asio::thread_pool that is initialized lazily on first use and stopped and joined during teardown after in-flight offload RPCs drain. Lazily initialize FileStorage::streaming_reads_ only when the portable pread driver is needed so io_uring-backed local streaming restores do not spawn idle fallback read workers, and align the SSD offload design doc with per-batch fixed-buffer rings and fallback semantics. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Trim unused zero-caller abstractions and heavy test fixtures from the local streaming restore path while fixing four correctness/usability issues: - Remove unused O_DIRECT, fixed_buffers per-batch io_uring engine, RebindSource, Cancel/attempt_id/region_id fields, and TrySubmit overloads; compile ssd_uring_pipeline.cpp only on Linux with liburing. - Account for OffsetAllocator 3-bit-mantissa bin rounding in StreamingReadConfig::Validate() via OffsetAllocatorSlotBudget() with a lockstep test against OffsetAllocator::normalizedAllocationSize(). - Deduplicate bucket file descriptors and BucketReadGuards per bucket in BucketStorageBackend::AcquireReadSources() so large multi-key batches sharing a few buckets do not hit the open-source limit. - Return NOT_SUPPORTED on overlapping destinations so RealClient falls back to the legacy sequential restore path instead of failing. - Extract pure ClassifyUringReadResult() with table-driven unit tests, probe io_uring_enter via NOP during worker init, log warnings on io_uring init/runtime failure and pread fallback, and remove the fake liburing.h / libc-interposition fault test targets. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
… contracts Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
EL8 wheel-builder containers ship liburing 1.0.7, which provides io_uring_get_probe_ring() and io_uring_opcode_supported() but predates io_uring_free_probe() (introduced in liburing 2.0). Fall back to std::free(probe) when IO_URING_VERSION_MAJOR < 2 (or undefined), matching uring_file.cpp's version guard. Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
Signed-off-by: MaskVulcan <9528071+MaskVulcan@users.noreply.github.com>
This branch has not been deployed
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.
Part 2 of 5 in the SSD Offload streaming & owner-push series tracked in RFC #5768.
Summary
Adds an opt-in bounded local streaming restore path (
MOONCAKE_OFFLOAD_LOCAL_STREAMING_READ=true, defaultfalse) for same-processBucketStorageBackendCPU reads, together with a per-RealClientoffload read thread pool and RPC drain ordering hardening. Objects and ranges larger than theClientBufferstaging arena can be restored directly into caller CPU slices using a fixed set of reusable staging slots.rpc_client_io_context.h,offload_read_executor_config.h,real_client.{h,cpp}):std::memory_order_seq_cstinRpcDrainGuardso teardown never misses concurrent admissions.coro_rpcI/O loop onto a lazily initializedRealClient-ownedasio::thread_pool(MOONCAKE_OFFLOAD_READ_IO_THREADS, default 64, range 1–128), drained and joined beforeFileStorage::Shutdown().ssd_read_pipeline.{h,cpp},ssd_read_source.{h,cpp},ssd_pipeline_io.{h,cpp},ssd_streaming_config.h):BuildReadPlan()splits reads into slot-sized chunks with bounded chunk/fragment limits.OpenPosixReadSource()opens regular files non-blockingly (O_NONBLOCKcleared afterS_ISREG/fstatvalidation) and pins backend lifetime tokens (BucketReadGuard) through the last in-flight read.ReadPipeline,BoundedExecutor, andThreadedPipelineDriverexecute bounded multi-slot reads/copies withWaitSubmitbackpressure and drain all accepted work on return or error.StreamingReadConfig::Validate()accounts forOffsetAllocator3-bit-mantissa bin rounding viaOffsetAllocatorSlotBudget()(verified in lockstep againstOffsetAllocator::normalizedAllocationSize()).FileStorageintegration (storage_backend.{h,cpp},file_storage.{h,cpp}):BucketStorageBackend::AcquireReadSources()resolves a batch under one shared metadata lock, deduplicates open file descriptors andBucketReadGuards perbucket_id, and charges open-source credits against unique bucket count before callingopen()— allowing large multi-key batches sharing a few buckets to stream cleanly.FileStorage::ReadLocalStreaming()validates destinations before opening files, returnsNOT_SUPPORTEDon overlapping destinations soRealClientfalls back to the sequential restore path, reaps expired remote staging leases on allocation pressure, and lazily initializes thepreadfallback pool only when needed.RealClient::execute_ranged_read()with safe fallback topartial_disk_read).io_uringread workers (Linux +liburingonly) (ssd_uring_pipeline.{h,cpp}):MOONCAKE_OFFLOAD_STREAM_USE_URING=truealongside local streaming; compiled only on Linux whenMooncake::liburingis available.io_uringring, probesIORING_OP_READandio_uring_enter(via NOP) during init, uses pureClassifyUringReadResult()for short reads and bounded-EINTR/-EAGAINretries, logs warnings on init/runtime failure, and falls back toThreadedPipelineDriver(pread) on subsequent batches.docs/source/design/store/ssd-offload.md):Series Overview (RFC #5768)
tcp_proto_versioninSegmentDesc::operator==main)main)TransferEngine::submitReceiverVisibleWrite()&Status::ProtocolUnsupported(classic TCP v2 opt-in)main)io_uringworkersmain)FileStorage::ReadOwnerStreamingRealClient& Python_storemain)Local Validation
liburingenabled: 8/8 targets passed (ssd_read_pipeline_test[incl. table-drivenClassifyUringReadResulttests],ssd_read_source_test,ssd_pipeline_io_test,ssd_uring_read_executor_contract_test[real kernel 1/2/4-worker reuse, isolation, drain, startup cleanup],file_storage_config_test[incl.OffsetAllocatorbin-rounding lockstep test],offload_read_executor_config_test,file_storage_test --gtest_filter='*LocalStreaming*'11/11 [incl. 80-key single-bucket deduplication & distinct-bucket cap],real_client_shutdown_test7/7) +mooncake_clientlink check.liburingdisabled (-- io_uring: Disabled): 7/7 non-uring targets +file_storage_test --gtest_filter='*LocalStreaming*'11/11 +real_client_shutdown_test7/7 +mooncake_clientpassed cleanly.clang-format 20.1.80 diff,typos 1.30.20 issues, DCO verified.