Skip to content

Commit 7afff74

Browse files
authored
perf(datafusion): push filters into Paimon Parquet readers (#574)
1 parent a9a8f6b commit 7afff74

28 files changed

Lines changed: 1830 additions & 940 deletions

benchmarks/tpcds/src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ pub struct RuntimeArgs {
113113
/// DataFusion execution partitions. Defaults to available CPUs.
114114
#[arg(long)]
115115
pub target_partitions: Option<usize>,
116+
/// Record batch size used by both DataFusion and Paimon file readers.
117+
#[arg(long, default_value_t = 8192)]
118+
pub batch_size: usize,
116119
/// Evaluate pushed filters during Parquet scans, in addition to statistics pruning.
117120
#[arg(long)]
118121
pub parquet_pushdown_filters: bool,
@@ -129,12 +132,16 @@ pub struct RuntimeArgs {
129132

130133
impl RuntimeArgs {
131134
pub fn to_config(&self) -> Result<BenchmarkRuntimeConfig, String> {
135+
if self.batch_size == 0 {
136+
return Err("--batch-size must be greater than zero".to_string());
137+
}
132138
let defaults = BenchmarkRuntimeConfig::default();
133139
Ok(BenchmarkRuntimeConfig {
134140
target_partitions: self
135141
.target_partitions
136142
.unwrap_or(defaults.target_partitions)
137143
.max(1),
144+
batch_size: self.batch_size,
138145
parquet_pushdown_filters: self.parquet_pushdown_filters,
139146
memory_limit_bytes: self.memory_limit_gib.map(gib_to_usize).transpose()?,
140147
spill_dir: self.spill_dir.clone(),

benchmarks/tpcds/src/context.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use serde::{Deserialize, Serialize};
2828
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
2929
pub struct BenchmarkRuntimeConfig {
3030
pub target_partitions: usize,
31+
#[serde(default = "default_batch_size")]
32+
pub batch_size: usize,
3133
#[serde(default)]
3234
pub parquet_pushdown_filters: bool,
3335
pub memory_limit_bytes: Option<usize>,
@@ -41,6 +43,7 @@ impl Default for BenchmarkRuntimeConfig {
4143
target_partitions: std::thread::available_parallelism()
4244
.map(usize::from)
4345
.unwrap_or(1),
46+
batch_size: default_batch_size(),
4447
parquet_pushdown_filters: false,
4548
memory_limit_bytes: None,
4649
spill_dir: None,
@@ -49,6 +52,10 @@ impl Default for BenchmarkRuntimeConfig {
4952
}
5053
}
5154

55+
fn default_batch_size() -> usize {
56+
8192
57+
}
58+
5259
pub fn build_sql_context(config: &BenchmarkRuntimeConfig) -> DataFusionResult<SQLContext> {
5360
let mut runtime = RuntimeEnvBuilder::new();
5461
if let Some(memory_limit) = config.memory_limit_bytes {
@@ -66,7 +73,8 @@ pub fn build_sql_context(config: &BenchmarkRuntimeConfig) -> DataFusionResult<SQ
6673
let mut session_config = current_state
6774
.config()
6875
.clone()
69-
.with_target_partitions(config.target_partitions.max(1));
76+
.with_target_partitions(config.target_partitions.max(1))
77+
.with_batch_size(config.batch_size.max(1));
7078
session_config
7179
.options_mut()
7280
.execution
@@ -100,6 +108,13 @@ pub async fn open_catalog_session(
100108
let mut sql = build_sql_context(runtime_config)?;
101109
sql.register_catalog_with_default_db("paimon", catalog.clone(), Some(database))
102110
.await?;
111+
// Keep decoder batch boundaries identical for Parquet and Paimon. Paimon
112+
// retains Java's table default, so use its supported session override.
113+
sql.sql(&format!(
114+
"SET 'paimon.read.batch-size' = '{}'",
115+
runtime_config.batch_size
116+
))
117+
.await?;
103118
Ok(CatalogSession {
104119
sql,
105120
catalog,

benchmarks/tpcds/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ mod tests {
183183
let spill_dir = TempDir::new().unwrap();
184184
let ctx = build_sql_context(&BenchmarkRuntimeConfig {
185185
target_partitions: 3,
186+
batch_size: 4096,
186187
parquet_pushdown_filters: true,
187188
memory_limit_bytes: Some(32 * 1024 * 1024),
188189
spill_dir: Some(spill_dir.path().to_path_buf()),
@@ -198,6 +199,10 @@ mod tests {
198199
.target_partitions,
199200
3
200201
);
202+
assert_eq!(
203+
ctx.ctx().state().config_options().execution.batch_size,
204+
4096
205+
);
201206
assert!(
202207
ctx.ctx()
203208
.state()

benchmarks/tpcds/tests/smoke.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ async fn command_orchestration_loads_and_writes_a_run_report() {
225225
.unwrap();
226226
let runtime = RuntimeArgs {
227227
target_partitions: Some(2),
228+
batch_size: 8192,
228229
parquet_pushdown_filters: false,
229230
memory_limit_gib: None,
230231
spill_dir: None,

crates/integrations/datafusion/src/config.rs

Lines changed: 0 additions & 61 deletions
This file was deleted.

crates/integrations/datafusion/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ mod blob_descriptor_functions;
4040
mod blob_reader;
4141
mod blob_view;
4242
mod catalog;
43-
pub mod config;
4443
mod delete;
4544
mod error;
4645
mod filter_pushdown;

0 commit comments

Comments
 (0)