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

FIX : some benchmarks are failing #15367

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

getChan
Copy link
Contributor

@getChan getChan commented Mar 23, 2025

Which issue does this PR close?

Rationale for this change

It is not certain, but it seems that plan creation and collect() should share the same runtime.. It is presumed that the issue occurred because RepartitionExec lazily polls within the runtime.

I will add more details if I find anything additional.

What changes are included in this PR?

  • Move the Runtime::new() intobench_function
  • Ensure that plan creation (ctx.sql()) and collect() share the same runtime.

Are these changes tested?

yes. below test are succeded

  • cargo bench -p datafusion --bench topk_aggregate
  • cargo bench -p datafusion --bench distinct_query_sql

Are there any user-facing changes?

No.

@github-actions github-actions bot added the core Core DataFusion crate label Mar 23, 2025
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 for this @getChan

|b| b.iter(|| run(distinct_trace_id_100_partitions_100_000_samples_limit_100.0.clone(),
distinct_trace_id_100_partitions_100_000_samples_limit_100.1.clone())),
|b| b.iter(|| {
let rt = Runtime::new().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this means that the benchmark will include the time to create each tokio runtime (with a bunch of threads, etc)

To avoid this I think you can create the runtime once, and then use it for each tieration:

            let rt = Runtime::new().unwrap();
    c.bench_function(
        format!("distinct query with {} partitions and {} samples per partition with limit {}", partitions, samples, limit).as_str(),
        |b| b.iter(|| {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Changed the runtime to be shared between loops.

However, it seems that other benchmark codes still have runtime creation within the iteration.

@github-actions github-actions bot added documentation Improvements or additions to documentation sql SQL Planner development-process Related to development process of DataFusion logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate catalog Related to the catalog crate common Related to common crate proto Related to proto crate functions Changes to functions implementation datasource Changes to the datasource crate labels Mar 26, 2025
@getChan getChan force-pushed the fix-repartition-bench-bug branch from c7414b2 to c36e781 Compare March 26, 2025 15:37
@github-actions github-actions bot removed documentation Improvements or additions to documentation sql SQL Planner development-process Related to development process of DataFusion logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates optimizer Optimizer rules sqllogictest SQL Logic Tests (.slt) substrait Changes to the substrait crate catalog Related to the catalog crate common Related to common crate proto Related to proto crate labels Mar 26, 2025
@github-actions github-actions bot removed functions Changes to functions implementation datasource Changes to the datasource crate labels Mar 26, 2025
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.

distinct_query_sql benchmark is failing
2 participants