Repository navigation
[core] Bound queued BLOB split batches by a shared byte budget - #1508
XiaoHongbo-Hope wants to merge 19 commits into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
Bounding queued BLOB payloads has end-to-end value for slow consumers. I ran the 7 parallel-read tests and 174 REST catalog tests on the merge with current main. The additional primary-key write, commit, plan and read probe below passes on main and reproduces a default-path concurrency regression on this PR.
| } | ||
| } | ||
| if unknown || bytes == 0 { | ||
| budget.max_bytes |
There was a problem hiding this comment.
[P1] Preserve split concurrency for ordinary managed primary-key BLOBs
Every normal PK Parquet file has write_cols = None, and its managed BLOBs are referenced through the sidecar rather than listed as .blob entries in the split. This fallback therefore assigns every group the full budget, even for tiny native BLOBs. I wrote 5- and 6-byte values to two PK partitions, then delayed the first Parquet read using FileBlockCache. With parallelism=2 and the default budget, the second split opened independently on main. On this head it only started after the first was released. The existing parallel read setting becomes ineffective for this path, which can amplify object-storage latency across partitions. Keep split preparation concurrent and reserve bytes when the decoded descriptors expose their lengths, or make the serialized fallback opt-in until it has representative throughput coverage.
8424448 to
dbb4f59
Compare
Use a shared per-read budget for queued managed BLOB batches. Keep descriptor reads and unknown-size PK BLOB splits concurrent by default; make conservative reservation opt-in for unknown sizes. Avoid Parquet prefetch budget cycles and cover ordered and unordered reads.
dbb4f59 to
ed6d5dd
Compare
JingsongLi
left a comment
There was a problem hiding this comment.
Reviewed b26fc715 against cd2b15af and verified these findings with end-to-end table reads.
| yield batch; | ||
| } | ||
| // A paused caller keeps the permit and the current batch. | ||
| drop(_permit); |
There was a problem hiding this comment.
[P1] Keep the budget permit while the split retains decoded BLOBs
In unordered reads, this releases the permit and puts the open split back in the queue. The Data Evolution merge can yield a slice of a source batch and keep the remaining decoded BLOBs in source_cursors. The next split can then decode while the previous one still holds payloads that have yet to be returned.
I reproduced this on b26fc715 by writing, committing, planning, and reading three partitions. Each partition contained 1,024 one-byte values followed by a 1.5 MiB value, and each .blob file was smaller than 2 MiB. I read with split parallelism 3, read.batch-size=2048, and read.blob.output.max-buffered-bytes=2mb. After consuming the first batch from each split, Arrow buffer reference counts showed the reader still held all three unreturned 1.5 MiB values, 4.5 MiB in total. Two splits had already returned their permits.
Keep each reservation until the split releases the decoded output buffers it covers, or tie the reservation directly to those buffers.
| .as_ref() | ||
| .is_none_or(|cols| cols.iter().any(|col| budget.fields.contains(col))) | ||
| { | ||
| unknown = true; |
There was a problem hiding this comment.
[P2] Resolve the physical write columns before marking a split as unknown-size
With data-evolution.write-cols-optimization.enabled=true, the writer can omit write_cols on the Parquet file that stores the ordinary columns. This branch treats that file as an unknown-size BLOB source, so an explicit budget gives the split a full-budget reservation even when all of its BLOBs are in known-size .blob files.
I wrote and planned two partitions with two tiny BLOB values each, set read.blob.output.max-buffered-bytes=4mb, and read with split parallelism 2. Each .blob file was smaller than 1 MiB. A FileBlockCache gate held the first split's Parquet read until the second split opened. On cd2b15af, both splits opened and the read completed. On b26fc715, the second split never opened before the 2-second timeout. The same probe passed on the PR head with write-column optimization disabled.
Use the file schema's effective physical columns to decide whether the split has an unknown-size BLOB source. For this layout, TableSchema::data_file_fields(None) already reconstructs the omitted columns.
| .iter() | ||
| .map(|split| blob_group_cost(std::slice::from_ref(split), budget)) | ||
| .collect::<Vec<_>>(); | ||
| if costs.iter().any(Option::is_some) { |
There was a problem hiding this comment.
[P2] Keep a single ordered split on the caller's executor
This branch can enter merge_items_budgeted when the requested parallelism is greater than one and the plan contains just one known-size BLOB split. That sends the read through a Tokio JoinSet and bypasses the existing single-stream path.
I wrote and planned an in-memory Data Evolution table with one managed BLOB split and an explicit 4 MiB budget. I consumed the read with futures::executor::block_on outside Tokio, using with_ordered(true) and with_parallelism(8). The same read returned both rows on cd2b15af and failed on b26fc715 with Parallel table reads require a Tokio runtime. With with_ordered(false), the PR head returned both rows.
Require splits.len() > 1 before enabling the ordered budget scheduler so a single split keeps the existing executor behavior.
Resolve implicit file columns with their schema before reserving unknown BLOB bytes. Preserve the caller executor for a single ordered split.
JingsongLi
left a comment
There was a problem hiding this comment.
The shared budget has clear value for slow BLOB consumers. On ddfd3127 integrated with ebcff9f1, 191 table, REST and resource integration tests and 26 executor tests passed. A separate write/plan/read case exposed one projection that bypasses the budget.
| && uses(&views)); | ||
| let resolves_view = | ||
| self.table.rest_env().is_some() && options.blob_view_resolve_enabled() && uses(&views); | ||
| let resolves_blob = (!options.blob_as_descriptor() && uses(&blob_fields)) || resolves_view; |
There was a problem hiding this comment.
[P2] Apply the BLOB output budget to field-ID projections with aliases. I wrote two Data Evolution splits with one 1.5 MB managed BLOB each, set a 2 MiB budget, and held the first split's Parquet read. A projection named payload kept the second split waiting. The same DataField ID and BLOB type with the output name aliased_payload opened both splits concurrently and returned both payloads correctly. The reader resolves the aliased projection by field ID, while uses and the reservation fields only match the output name. Resolve projection fields back to their table field IDs before determining the BLOB read set.
JingsongLi
left a comment
There was a problem hiding this comment.
I reran the split executor, table-read, parallel-read, REST catalog, and scan-planning suites on f4206fe1. All 266 tests passed. A separate write/commit/plan/read test reproduced a scheduling regression with skewed BLOB sizes.
| let permit = match *cost { | ||
| Some(cost) => { | ||
| let Ok(permit) = Arc::clone(permits).try_acquire_many_owned(cost) else { | ||
| break; |
There was a problem hiding this comment.
[P2] Let a smaller split use available budget in unordered reads. I wrote, committed, and planned three Data Evolution partitions with BLOB payloads of 2.5 MiB, 2.5 MiB, and 0.5 MiB, then read them with parallelism=3, ordered=false, and a 4 MiB budget. With the first partition’s Parquet read gated, requesting [large, large, small] returned no batch until I released that gate. On the same commit, [large, small, large] returned the small partition while the first was still gated. All payloads matched after both reads completed. The reservation for the first group consumes 3 MiB, so the small group fits in the remaining 1 MiB. Stopping at the second group leaves a worker and that budget idle behind a slow object read. Keep FIFO admission for ordered reads and let unordered reads admit a later group that fits while preserving progress for large groups.
JingsongLi
left a comment
There was a problem hiding this comment.
I reviewed fe83adb6 integrated with 8105e1eb. All 5,383 core, parallel-read, REST, and scan-planning tests passed. Two additional write/commit/plan/read tests passed on 8105e1eb and exposed scheduling regressions on this head.
| if let Some(budget) = &blob_output_budget { | ||
| let costs = groups | ||
| .iter() | ||
| .map(|group| blob_group_cost(group, budget)) |
There was a problem hiding this comment.
[P2] Reserve bytes for the active split in current-schema unordered reads. I wrote four Data Evolution partitions in order with BLOBs of 2.5, 0.5, 0.5, and 2.5 MiB. With two workers, ordered=false, and a 4 MiB budget, the two groups each reserve 3 MiB. While I held the first group's Parquet read, the second group's first split produced no output, even though that split needs only 1 MiB and the remaining 1 MiB was available. The same split finished while the first read was held with a 6 MiB budget and on main. Keep the permit while the active split can retain decoded buffers, then admit the group's next split independently, as the historical-schema path does.
| let file_groups = if options.data_evolution_enabled() | ||
| && !self.update_read | ||
| && !budget.has_resources() | ||
| && !output_budget_active |
There was a problem hiding this comment.
[P2] Preserve independent-file parallelism in splits without BLOB payloads. I committed two Parquet files in partition A with the nullable BLOB omitted via with_write_type, and a single managed BLOB row in partition B. With three workers and the first A file gated, the second A file opened concurrently on main and on this head when I projected only p, id. When I also projected the BLOB on this head, the second A file waited for the first to finish. B's budget turns off independent file scheduling for A even though A has zero payload cost. Keep independent-file scheduling for those splits and preserve their output order, with BLOB reservations still sharing one budget.
Summary
Bound queued BLOB split batches with a shared per-read byte budget. For known-size managed BLOBs, the default is 512 MiB per available core, capped at 4 GiB (1 GiB on 2 cores, 2 GiB on 4, 4 GiB on 8+);
read.blob.output.max-buffered-bytesoverrides it. The reservation counts only BLOB files used by the projected or filtered columns, so an unread BLOB column cannot serialize the read. Files without column metadata are charged conservatively.An unknown-size split no longer disables budgeting for other known-size splits. Known BLOB bytes in a split are still reserved when that split also references an unknown-size file. The same known-byte reservation applies when the read also resolves a REST BLOB View. Pure unknown-size groups retain their existing concurrency unless the budget is explicitly configured. Ordered reads create each split stream only when admitted to an execution slot. Finite
LIMITand descriptor-only reads keep their existing paths.The budget limits queued split output for each reader; it is not a bound on decoder memory, caller-retained batches, or several readers combined.
Performance evidence
A real image/BLOB workload from an isolated test copy read 100 complete groups per repetition (23.6k–29.3k rows and 6.17–7.42 GB of image bytes). All 24 reads verified every payload against a frozen SHA-256 reference. On one 8-vCPU/32-GiB ECS, the parent, the prior PR head at an explicit 4-GiB budget, and head
7db2e9aat its 4-GiB default ran in alternating order with split parallelism 32 and BLOB parallelism 16. Times are end to end per read (total_s: planning, payload read, Python materialization, and SHA-256; table open excluded).7db2e9a, default 4 GiBThe paired
7db2e9a/parent median ratio was 1.01 for cold reads and 0.90 for warm reads. The slow consumer paused 200 ms after each batch; its single warm run had 288 MiB less sampled process peak RSS than the parent. OSS/server caches and service load were not controlled, so these numbers do not establish a speedup. They show no large sustained regression on this workload. The benchmark used unordered BLOB materialization with one BLOB column, not ordered reading, a full training DataLoader, or a Lance comparison. The projection-aware change at579eb726is covered by a deterministic dual-BLOB-column concurrency test; it has not been separately benchmarked on ECS.The internal benchmark archive contains the reproducible scripts, exact source and wheel SHA-256 values, frozen input, raw observations, and ECS release verification.
Current-head slow-consumer default validation
Release wheel built from
6006685(the laterb26fc71changes test assertions only). On separate 2-, 4-, and 8-vCPU ECSs, the exact parent, the current default, and the same current wheel with an explicit 256-MiB budget each read the same 100 complete low-precision image clips in three paired repetitions. Each repetition materialized 6.17–7.42 GB of image payload, with 200 ms consumer delay per Arrow batch. All 54 cold/warm reads passed the frozen full-payload SHA-256 check. Split and BLOB parallelism were 32 and 16. The table gives medians of immediate warm reads; time includes planning, BLOB read, Python materialization, hashing, and consumer delay. Peak RSS is sampled process memory.Paired warm-time default/parent median ratios were 1.016/1.000/1.007 on 2/4/8 vCPU. The defaults preserved throughput within run-to-run variation and reduced sampled peak RSS by 1,517/1,377/596 MiB versus the unbudgeted parent. The explicit 256-MiB limit reduced throughput by about 2.2× versus the defaults. These results support the chosen defaults for this workload, not global optimality. OSS/server cache and load were uncontrolled; this was an unordered, single-BLOB-column read with Python materialization, not a full training DataLoader or ordered-read benchmark. Raw observations, exact wheel/source and script SHA values, machine details, and ECS release verification are archived in
paimon/xrobotbranchcodex/pr1508-blob-budget-benchmark, directoryexperiments/pr1508-blob-output-budget-20261124.Validation
cargo fmt --all -- --check, 26 read-executor unit tests (including dual-BLOB-column single-column projection, known/unknown files in one split, mixed-size splits, and lazy-creation regressions), 32 table-read unit tests, 8 parallel-read integration tests, the REST BLOB View integration test, andgit diff --checkpassed. The7db2e9awheel completed 24 correct benchmark reads and the ECS was released.