Repository navigation
perf: stop buffering file listings once they exceed the cache budget - #27172
Open
shehab-ali wants to merge 1 commit into
Open
shehab-ali wants to merge 1 commit into
shehab-ali wants to merge 1 commit into
Conversation
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.
Rationale for this change
On a cache miss, DataFusion buffers the entire object-store file listing before rejecting entries that exceed the cache budget. Large directories therefore increase memory use and delay queries that only need a few files, such as
LIMITqueries.What changes are included in this PR?
Stop building the cache entry once its key and metadata exceed the cache budget. Return the buffered prefix followed by the remaining listing stream, so consumers can start processing or stop early. Only complete, successful listings are cached.
Add regression tests and a Criterion benchmark through the public
ListingTableUrlAPI.Related work: #25858 changes cache identity and object-store isolation; this PR addresses buffering on cache misses.
Local performance testing
Measured locally on November 6, 2026:
main(a61683112) versus this change (6194d58e9), on an M3 Max with 64 GiB RAM/macOS, using matchedrelease-nonltobuilds and a 1 MiB listing cache:SELECT id, value FROM events LIMIT 10The SQL workload uses 100,000 local Parquet files × 32 rows, four target partitions, and medians of seven alternating fresh-process pairs after warm-up. Statistics collection is disabled during table registration, then enabled before the query. Timings include planning and execution; RSS covers the whole process. These gains describe this early-stop workload, not default registration costs. The metadata-only memory benchmark uses ten fresh processes per version and performs no file-data I/O.
Full-scan SQL and the existing pruning, SQLIO, and narrow-schema controls showed no reliable gain; the additional local measurements are below.
Standard TPC-H SF10: all 22 queries ran in two reversed-order pairs with default runtime settings. Overall performance was inconclusive because of substantial timing drift. These single-file table paths bypass the changed listing-cache code.
Potential regression: Q12 was slower in both full-suite pairs. Four additional paired runs reproduced a 4.8% slowdown (102.41 → 107.31 ms). Its cause remains unconfirmed and needs investigation before claiming no regressions.
Additional local performance results and measurement method
SUM(id)parquet_pruning_setup_cachesql_query_with_io: all-partitionsEXPLAINwide_schema: narrow Q02Method: SQL time/RSS values are medians of seven alternating fresh-process pairs. Metadata listing time is the median of three Criterion run means (30 samples/run). Stock controls use medians of Criterion run means (10 samples/run): three pairs for pruning and SQLIO, seven for narrow Q02. Small control differences are within observed variation.
TPC-H used four full passes in baseline/fixed/fixed/baseline order, with default runtime settings and 10 samples/query/pass. The TPC-H total averages two run means per query, then sums all 22 queries; it excludes setup and warm-up, so it is not total suite wall time. The geometric-mean query-time change was −9.9%, but the same binaries varied by 13–28% between repeats and 14/22 queries reversed direction. These figures do not establish an overall speedup.
Q12 follow-up values average four Criterion run means per version. Those extra pairs were selected after Q12 slowed in both full-suite pairs, and remain separate from the full-suite totals. No measured samples were discarded from these comparisons. All results are from a shared workstation, without flushing filesystem caches; the standard suite did not measure process RSS or CPU consumption.
What is the testing strategy for this PR?
cargo clippy --all-targets --all-features -- -D warnings.Are there any user-facing changes?
Oversized listings can be consumed or cancelled incrementally. Errors beyond the prefetched prefix surface during stream consumption. The cache budget limits prefetch accounting, not total query memory; public APIs are unchanged.