[Store] Add multi-level parallel read via shared ThreadPool - #3199
Conversation
|
Thanks for the contribution. Before diving into the design, two things need to be addressed first. 1. This PR does not compile. A ready-for-review PR should at least build locally — please make sure the code compiles and passes basic tests (e.g. a 2. The intra-bucket path is incompatible with io_uring + O_DIRECT. With The design would hold up much better as: within a bucket, use |
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
hi @LujhCoconut thanks for thorough review, both points were spot on. Compilation and constructor: The duplicate constructor has been removed. Intra-bucket path and io_uring: You were right — threading within a bucket made no sense for the URing backend. The revised design follows your suggestion:
The two pools are independent, so when both env vars are set bucket-level dispatch and intra-bucket POSIX chunking compose into true 2-level concurrency. URing files are never dispatched to either pool for When both env vars are 0 (the default), the code falls through to the original sequential path with zero change. Happy to iterate further if anything still looks off. |
- Add MC_BATCH_LOAD_THREADS env var for bucket-level parallelism. When > 1 and multiple buckets, dispatch each bucket to a thread. - Add MC_BUCKET_READ_THREADS env var for intra-bucket POSIX read parallelism. When > 1, split read plans into chunks and dispatch to threads sharing the same fd (pread is thread-safe). - Shared ThreadPool sized = max(batch, bucket), created once in BucketStorageBackend constructor. Default 0 preserves original sequential behavior for both paths. - Error handling: first error wins, all tasks complete, results collected via std::packaged_task + std::future. Signed-off-by: tan changzhi <544463199@qq.com>
Read MC_BATCH_LOAD_THREADS / MC_BUCKET_READ_THREADS once in BucketStorageBackend constructor, store as const members, and use those instead of calling std::getenv on every BatchLoad invocation. Signed-off-by: tan changzhi <544463199@qq.com>
Replace the single-shared-pool design with two independent ThreadPools
so that bucket-level and intra-bucket parallelism can compose into
true 2-level concurrency for POSIX (pread) backends.
MC_BATCH_LOAD_THREADS — bucket-level pool (independent files)
MC_BUCKET_READ_THREADS — intra-bucket pool (POSIX pread chunking)
• Both 0 (default): original sequential path, zero change.
• Only batch > 1: buckets dispatched to bucket pool; URing uses
batch_read() (one io_uring submission, queue
depth 32), POSIX stays sequential per-bucket.
• Only bucket > 1: buckets sequential, POSIX plans split across
intra-bucket pool. URing uses batch_read().
• Both > 1: bucket pool dispatches buckets, within each
POSIX plans further split across intra-bucket
pool — true 2-level concurrency.
URing batch_read() is enabled when either env var > 0.
Extract UringBatchReadBucket (URing alignment + batch_read +
zero-copy) and IntraBucketReadChunked (POSIX chunk-dispatch)
to eliminate duplication. Promote ReadPlan to private struct.
Signed-off-by: tan changzhi <544463199@qq.com>
- Fix 'UringFile was not declared' error in the #else branch when USE_URING is not defined: use void* as placeholder since the variable is [[maybe_unused]] and never dereferenced in that path. - Add 5 integration tests covering all concurrency combinations via MC_BATCH_LOAD_THREADS / MC_BUCKET_READ_THREADS: 0/0, 4/0, 0/4, 4/4, and 2/8. Each seeds 100 keys across 10 buckets, calls BatchLoad, and verifies data byte-for-byte. Timing is logged at INFO level for manual comparison across scenarios. Signed-off-by: tan changzhi <544463199@qq.com>
Description
Add MC_BATCH_LOAD_THREADS env var for bucket-level parallelism. When > 1 and multiple buckets, dispatch each bucket to a thread.
Add MC_BUCKET_READ_THREADS env var for intra-bucket POSIX read parallelism. When > 1, split read plans into chunks and dispatch to threads sharing the same fd (pread is thread-safe).
MC_BATCH_LOAD_THREADS — bucket-level pool (independent files)
MC_BUCKET_READ_THREADS — intra-bucket pool (POSIX pread chunking)
• Both 0 (default): original sequential path, zero change.
• Only batch > 1: buckets dispatched to bucket pool; URing uses
batch_read() (one io_uring submission, queue
depth 32), POSIX stays sequential per-bucket.
• Only bucket > 1: buckets sequential, POSIX plans split across
intra-bucket pool. URing uses batch_read().
• Both > 1: bucket pool dispatches buckets, within each
POSIX plans further split across intra-bucket
pool — true 2-level concurrency.
• URing batch_read() is enabled when either env var > 0
Extract UringBatchReadBucket (URing alignment + batch_read + zero-copy) and IntraBucketReadChunked (POSIX chunk-dispatch) to eliminate duplication
Module
mooncake-transfer-engine)mooncake-store)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:
# Example: bash scripts/run_ci_test.shTest results:
Checklist
./scripts/code_format.shpre-commit run --all-filesand all hooks passAI Assistance Disclosure