Repository navigation
[python] Choose split read parallelism from planned splits - #1504
XiaoHongbo-Hope wants to merge 3 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, choose split parallelism from the planned split count: up to 64 for descriptor reads, or 32 for tables that may resolve BLOB payloads. Other reads keep the single-worker default; an explicitparallelismis unchanged.The API still defaults to
ordered=False. Parallel reads may return batches in a different order; callers needing split order can setordered=True.Evidence
In a Paimon-only, three-seed paired test on an 8-vCPU, 32-GiB ECS, we queried a BLOB table with one fixed
content_key. Queries selected 100 or 1000 clips, used unordered reads and the default batch size; each cold run followed a local page-cache drop:The caps balance latency and memory on this host; callers can still tune
parallelism. The BLOB default of 32 depends on the shared buffered-byte budget in #1508.Validation
cargo fmt --all --check;cargo check -p pypaimon_rust --tests. Added unit checks for the caps and nested BLOB classification; order-sensitive Python tests now requestordered=True.