Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metadata_size_hint for optimistic fetching of parquet metadata #2946

Merged
merged 6 commits into from
Jul 21, 2022

Conversation

thinkharderdev
Copy link
Contributor

@thinkharderdev thinkharderdev commented Jul 20, 2022

Which issue does this PR close?

Closes #.
Related to apache/arrow-rs#2110

Rationale for this change

Add a configurable size hint to ParquetFormat to allow fetching metadata without multiple seeks. This is not set by default. If it is configured, the ParquetFileReader will read metadata_size_hint bytes from the end of the parquet file and then fetch additional data only if the metadata is more than metadata_size_hint

What changes are included in this PR?

Are there any user-facing changes?

Both ParquetFormat and ParquetExec can not take an optional metadata_size_hint.

@github-actions github-actions bot added the core Core DataFusion crate label Jul 20, 2022
@thinkharderdev
Copy link
Contributor Author

Build failure seems to be infra related: note: /usr/bin/ld: final link failed: No space left on device

@alamb
Copy link
Contributor

alamb commented Jul 20, 2022

I have filed #2947 to track the CI failure

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @thinkharderdev -- this looks great.

I think we should handle the case when size_hint is greater than the file_size (but perhaps I am misreading the code) before merging this but otherwise 👍

cc @tustvold

@@ -298,13 +327,20 @@ pub(crate) async fn fetch_parquet_metadata(
)));
}

let footer_start = meta.size - 8;
let footer_start = if let Some(size_hint) = size_hint {
meta.size - size_hint
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if size_hit is larger than the file size?

Maybe we could used saturating_sub here instead: https://doc.rust-lang.org/std/primitive.usize.html#method.saturating_sub

assert_eq!(c1_stats.null_count, Some(1));
assert_eq!(c2_stats.null_count, Some(3));

// Use the file size as the hint so we can get the full metadata from the first fetch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is any way to test that there was a single request made to the object store as well 🤔

@@ -567,6 +575,90 @@ mod tests {
Ok(())
}

#[derive(Debug)]
struct RequestCountingObjectStore {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

@alamb
Copy link
Contributor

alamb commented Jul 20, 2022

I think if you rebase from master to pick up #2948 your CI should pass cleanly

@codecov-commenter
Copy link

Codecov Report

Merging #2946 (d027f16) into master (b49093c) will decrease coverage by 0.00%.
The diff coverage is 83.19%.

@@            Coverage Diff             @@
##           master    #2946      +/-   ##
==========================================
- Coverage   85.43%   85.42%   -0.01%     
==========================================
  Files         275      275              
  Lines       49739    49839     +100     
==========================================
+ Hits        42495    42576      +81     
- Misses       7244     7263      +19     
Impacted Files Coverage Δ
...afusion/core/src/datasource/file_format/parquet.rs 85.02% <80.95%> (-1.52%) ⬇️
...afusion/core/src/physical_optimizer/repartition.rs 100.00% <100.00%> (ø)
...sion/core/src/physical_plan/file_format/parquet.rs 95.00% <100.00%> (+0.08%) ⬆️
datafusion/expr/src/logical_plan/plan.rs 77.14% <0.00%> (-0.18%) ⬇️
datafusion/core/src/physical_plan/metrics/value.rs 86.93% <0.00%> (+0.50%) ⬆️

@alamb alamb merged commit 834924f into apache:master Jul 21, 2022
@ursabot
Copy link

ursabot commented Jul 21, 2022

Benchmark runs are scheduled for baseline = b49093c and contender = 834924f. 834924f is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ec2-t3-xlarge-us-east-2] ec2-t3-xlarge-us-east-2
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on test-mac-arm] test-mac-arm
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-i9-9960x] ursa-i9-9960x
[Skipped ⚠️ Benchmarking of arrow-datafusion-commits is not supported on ursa-thinkcentre-m75q] ursa-thinkcentre-m75q
Buildkite builds:
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants