Repository navigation
Conversation
…s, priority, promote
Member
Author
|
Closed on purpose: record only. |
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.
Record only. Not for merge. This PR is closed on purpose. It keeps the prototype code, method and results in one place.
Base: the apache#24086 head (pool-counted
read_ahead_bytes), built against the pydantic/arrow-rs batch-granularscan_planbranch (claude/push-decoder-batch-granular-scan-plan-60.0.0).What the prototype does
datasource-parquet/src/prefetch.rsadds a per-file fetch window, enabled withDF_PREFETCH=1.scan_plan(), in decode order. That order can move backward through the file (for exampleORDER BY ... DESCreverses row groups). Chunks must not overlap; if they do, the reader falls back to the plain reader.DF_PREFETCH_CHUNKbytes (default 4 MiB).Pending,InFlight,Ready(Bytes)orFreed. A read cursor moves forward only and frees every chunk it passes.MemoryReservation::grow, which never fails.DF_PREFETCH_CONCURRENCYworkers (default 4). They claim withtry_grow, withinDF_PREFETCH_BUDGETbytes (default 32 MiB) counted after the cursor chunk.Claimguard returns a cancelled fetch's chunk toPending. AJoinSetaborts the workers when the reader drops. Moving the cursor wakes the workers.push_decoder.rs: required reservations are a plaingrow.DF_PREFETCH_STATS=1):hit_mib miss_mib required_mib wait_ms denied.Earlier designs in this branch's history, kept for reference, and why they were removed:
Method
idcolumn and aattributesstring column of about 20 KB per row. Two layouts: 16384-row row groups (d16384) and 2048-row row groups (d2048).object_storefrom an n2-highmem-32 VM in the same region. Each run is pinned to 8 cores (taskset -c 0-7).FairSpillPoolwrapped inTrackConsumersPool. Batch size 4096.SELECT id, concat(substr(attributes, 1, 300), chr(120)) AS a FROM t ORDER BY id DESC, with a 512 MiB or 768 MiB pool (forces spill).attributes LIKE ...filter, 3 GiB pool.read_ahead_bytes1 MiB,DF_PREFETCH=1, chunk 4 MiB, budget 32 MiB, concurrency 4.sweep script
Results: main vs best (2 reps)
main fails 4 of 8 sort cells with
Resources exhausted. best passes all of them, spills the same 325 MiB, and holds RSS at 0.6-1.2 GiB. Prefetch hit rate is 100% (miss_mib=0) in every best run.Sizing
The 8 MiB / 32 MiB failure: prefetch held about 290 MB and read-ahead about 200 MB, which left 2.2 MB for the sort's first 2.5 MB reservation. The chunk under the cursor is also counted twice (by prefetch and by the decoder), so a larger chunk costs more than its size suggests.
Findings for upstream
MemoryPooland must be fallible (try_grow). Required reads must not be refused (grow).try_growlets prefetch take the pool before other operators reserve. A per-scan share derived fromMemoryPool::memory_limit()works (compare DuckDB's per-thread cap of limit / 8).Related: apache#26682, apache#24086, apache#23492, apache#26387, apache#25650, apache#21422; apache/arrow-rs#11609, apache#11238, apache#11613, apache#11240.