Repository navigation
[python] Choose split read parallelism from planned splits - #1504
XiaoHongbo-Hope wants to merge 5 commits into
Conversation
JingsongLi
left a comment
There was a problem hiding this comment.
All 222 Python read, streaming scan, and BLOB tests passed against a wheel built from this revision.
| || (self.table.rest_env().is_some() | ||
| && options.blob_view_resolve_enabled() | ||
| && !options.blob_view_fields().is_empty()); | ||
| default_split_parallelism( |
There was a problem hiding this comment.
[P1] Bound buffered BLOB bytes before enabling automatic parallelism.
The first poll starts a read for each split worker, and each worker can retain a materialized batch. The BLOB range-read permits are released when the I/O finishes. I reproduced this with 32 splits and a 16 MiB payload batch per split. After consuming and releasing the first read_arrow() batch and pausing, RSS was about 621 MiB with the default and 113 MiB with parallelism=1 on the same wheel. Larger image or video batches can exhaust memory even when the caller processes one batch at a time. Please keep the BLOB default at one worker until a shared byte budget covers the batches waiting to be consumed.
| /// Without an explicit parallelism, filtered reads without a limit use up | ||
| /// to 64 splits for descriptors or 32 for BLOB payloads. Other reads keep | ||
| /// the existing single-split default. | ||
| #[pyo3(signature = (splits, *, parallelism = None, ordered = false))] |
There was a problem hiding this comment.
[P2] Update the shipped type stubs for both methods.
read() and read_arrow() now accept parallelism=None. The corresponding signatures in bindings/python/python/pypaimon_rust/datafusion.pyi still declare parallelism: int = 1 for both. The wheel ships py.typed, so type checkers reject an explicit None and editors show the old default. Please declare parallelism: int | None = None in both stubs and document when automatic parallelism applies.
| // Favor the payload cap whenever this table may resolve a BLOB. | ||
| // Projection and filters can introduce hidden BLOB operands, so a | ||
| // wider default is only safe for descriptor-only reads. | ||
| let has_blob = !options.blob_fields().is_empty() |
There was a problem hiding this comment.
[P2] Use the descriptor cap for unresolved BLOB views.
If a table's only BLOB column is a blob-view-field and blob-view.resolve.enabled=false, Core returns the stored references. blob_fields() still includes the view, and the schema check also counts it as a scalar BLOB. With the default blob-as-descriptor=false, a filtered read with more than 32 splits therefore gets the payload cap. Please exclude view fields from the ordinary BLOB checks and use the REST and resolution conditions for views, as Core does.
Summary
For filtered reads without LIMIT, derive the default worker count from the supplied splits. Cap ordinary and descriptor reads at 64 workers. Cap reads of known-size managed BLOBs at 32 when the physical files in the plan are covered by the shared output budget from #1508. External payloads and plans with uncertain BLOB coverage use one worker. REST BLOB View descriptor lookups use the 32-worker cap. Views that return stored references use the descriptor cap.
Unfiltered and limited reads default to one worker. Both
read()andread_arrow()acceptparallelism=None. A positive explicit value overrides the automatic policy.ordered=Trueretains split order.Evidence
The original worker-cap sweep used three paired seeds on an 8-vCPU, 32-GiB ECS. Queries used a fixed content key, unordered reads, the default batch size, and a local page-cache drop before each cold run.
These measurements selected the caps for the tested workload. The automatic BLOB path now uses the shared Core budget in #1508.
Validation
parallelism=Noneon bothread()andread_arrow().5ca4c53fwith merged [core] Bound queued BLOB split batches by a shared byte budget #1508, 11 Rust binding tests and 279 Python tests passed. The Python run used a locally built debug extension and included read, streaming scan, and BLOB suites.