perf(common): Parallelize metadata fetching during query planning#2017
Merged
perf(common): Parallelize metadata fetching during query planning#2017
Conversation
Replace sequential `.then()` with `.buffered(32)` in resolve_file_groups() so up to 32 parquet metadata fetches run concurrently. Uses `.buffered()` to preserve ordering for deterministic round-robin partition assignment.
76d9b1f to
db3133e
Compare
db3133e to
8e4d432
Compare
Configurable via config file or AMP_CONFIG_METADATA_FETCH_CONCURRENCY env var. (default: 32) Controls how many parquet footer fetches run concurrently during query planning.
8e4d432 to
b47416c
Compare
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.
Background
During query planning, parquet file metadata (footers) are fetched one at a time. On cold cache with many files, this serializes hundreds of network round trips. In a large example query 684 files are fetched, so at 50ms per file it takes ~34 seconds just to fetch metadata before any data is read. Parallelizing the fetching with .buffered(32) takes theoretical time to fetch those 684 files in example down to ~1 second.
On warm cache the impact is minimal since cache lookups are sub-millisecond, but cold starts, new tables, and large time-range queries benefit significantly.
Changes
metadata_fetch_concurrency) →Config→ server/workerConfig→ExecEnv→ExecContextBuilder→QueryableSnapshot→resolve_file_groups()