Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 20 additions & 38 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,29 @@ incremental = false
[profile.ci-bench]
inherits = "ci"
opt-level = 1

# EXPERIMENT: pin arrow-rs to the 60.2.0 release plus the push decoder
# changes that no release has: apache/arrow-rs#11238 (batch-granular
# `ParquetPushDecoder`) and apache/arrow-rs#12456 (`retain_row_groups` and
# `active_row_group`). The commit is on pydantic/arrow-rs, branch
# claude/push-decoder-batch-granularity-60.2.0-v3.
# The patch covers every arrow crate, so that all of them come from one source.
[patch.crates-io]
arrow = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-arith = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-array = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-avro = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-buffer = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-cast = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-cmp = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-csv = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-data = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-flight = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-ipc = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-json = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-ord = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-row = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-schema = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-select = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
arrow-string = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
parquet = { git = "https://github.com/pydantic/arrow-rs.git", rev = "f37f753637572dde5602e5b28ac0544aed893259" }
25 changes: 25 additions & 0 deletions datafusion/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,31 @@ config_namespace! {
/// parquet reader setting. 0 means no caching.
pub max_predicate_cache_size: Option<usize>, default = None

/// (reading) If set, fetch Parquet data ahead of the decoder, in the
/// order the decoder reads it, up to this many bytes for each file a
/// partition stream reads. If unset, the reader fetches one row group
/// at a time, when the decoder needs it.
///
/// The window bounds the bytes in flight plus the fetched bytes the
/// decoder still holds, including the gaps between ranges that one
/// request reads through. Bytes the decoder needs are fetched even if
/// the window is full. Read-ahead fetches small row groups whole and
/// large ones in parts, with several requests in flight.
///
/// The throughput of a partition stream is at most about this window
/// divided by the storage latency. Thus, windows below a few MiB are
/// slow on object storage.
///
/// With read-ahead, the reader decodes a batch at a time. Scans that
/// return the rows of each row group in reverse order (`reverse_rows`)
/// decode a row group at a time, and read ahead the next row groups.
///
/// Read-ahead also fetches ranges that a pushed-down filter can make
/// unnecessary. In addition to this window, read-ahead takes only the
/// memory that the memory pool grants. Bytes the decoder needs are
/// fetched even if the pool is full.
pub read_ahead_bytes: Option<usize>, default = None

/// Maximum number of input values in an `IN (...)` list eligible for
/// min/max pruning. Lists above this cap, or a cap of 0, skip this
/// rewrite; other predicates and Bloom-filter pruning remain available.
Expand Down
3 changes: 3 additions & 0 deletions datafusion/common/src/file_options/parquet_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ impl ParquetOptions {
coerce_int96_tz: _, // not used for writer props
skip_arrow_metadata: _,
max_predicate_cache_size: _,
read_ahead_bytes: _,
max_in_list_size: _,
enable_rle_to_dictionary: _,
dictionary_read_max_distinct_values: _,
Expand Down Expand Up @@ -406,6 +407,7 @@ mod tests {
coerce_int96: None,
coerce_int96_tz: None,
max_predicate_cache_size: defaults.max_predicate_cache_size,
read_ahead_bytes: defaults.read_ahead_bytes,
content_defined_chunking: defaults.content_defined_chunking.clone(),
enable_rle_to_dictionary: defaults.enable_rle_to_dictionary,
dictionary_read_max_distinct_values: defaults
Expand Down Expand Up @@ -538,6 +540,7 @@ mod tests {
bloom_filter_on_read: global_options_defaults.bloom_filter_on_read,
max_predicate_cache_size: global_options_defaults
.max_predicate_cache_size,
read_ahead_bytes: global_options_defaults.read_ahead_bytes,
schema_force_view_types: global_options_defaults.schema_force_view_types,
binary_as_string: global_options_defaults.binary_as_string,
skip_arrow_metadata: global_options_defaults.skip_arrow_metadata,
Expand Down
3 changes: 3 additions & 0 deletions datafusion/datasource-parquet/src/file_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ impl From<&ParquetFormatFactory> for protobuf::TableParquetOptions {
max_predicate_cache_size_opt: global_options.global.max_predicate_cache_size.map(|size| {
parquet_options::MaxPredicateCacheSizeOpt::MaxPredicateCacheSize(size as u64)
}),
read_ahead_bytes_opt: global_options.global.read_ahead_bytes.map(|size| {
parquet_options::ReadAheadBytesOpt::ReadAheadBytes(size as u64)
}),
max_row_group_bytes_opt: global_options.global.max_row_group_bytes.map(|size| {
parquet_options::MaxRowGroupBytesOpt::MaxRowGroupBytes(size.get() as u64)
}),
Expand Down
37 changes: 37 additions & 0 deletions datafusion/datasource-parquet/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,43 @@ impl Drop for ByteProgress {
}
}

/// Metrics of a file that is read with read-ahead
/// (`datafusion.execution.parquet.read_ahead_bytes`).
///
/// They are registered only for such a file, so a scan without read-ahead
/// does not show them.
#[derive(Debug, Clone)]
pub(crate) struct ReadAheadMetrics {
/// `read_ahead_bytes_fetched`: bytes that read-ahead fetched before the
/// decoder asked for them, including the gaps between ranges that a
/// fetch reads through. It does not count the fetches that the decoder
/// asked for. With the default reader, `bytes_scanned` counts both.
pub bytes_fetched: Count,
/// `read_ahead_wait_time`: time the scan waited for the fetches of byte
/// ranges that the decoder asked for. This includes the wait for a
/// read-ahead fetch in flight that holds such a range. Read-ahead that
/// keeps ahead of the decoder keeps this near zero.
pub wait_time: Time,
}

impl ReadAheadMetrics {
pub(crate) fn new(
metrics: &ExecutionPlanMetricsSet,
partition: usize,
filename: &str,
) -> Self {
let builder = MetricBuilder::new(metrics)
.with_new_label("filename", filename.to_string())
.with_type(MetricType::Summary);
Self {
bytes_fetched: builder
.clone()
.bytes_counter("read_ahead_bytes_fetched", partition),
wait_time: builder.subset_time("read_ahead_wait_time", partition),
}
}
}

impl ParquetFileMetrics {
/// Create new metrics
pub fn new(
Expand Down
Loading