Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add deterministic per-file timing summary to sqllogictest runner#20569

Merged
kosiew merged 12 commits intoapache:mainfrom
kosiew:sqllogictest-runtime-observability-20524a
Feb 27, 2026
Merged

Add deterministic per-file timing summary to sqllogictest runner#20569
kosiew merged 12 commits intoapache:mainfrom
kosiew:sqllogictest-runtime-observability-20524a

Conversation

@kosiew
Copy link
Contributor

@kosiew kosiew commented Feb 26, 2026

Which issue does this PR close?

Rationale for this change

The sqllogictest runner executes files in parallel, but it was hard to pinpoint which test files dominate wall-clock time. This change adds deterministic per-file elapsed timing observability so we can identify long-tail files and prioritize follow-up optimization work, while keeping default output usable for both local development (TTY) and CI (non-TTY).

What changes are included in this PR?

  • Collect per-file elapsed durations in the sqllogictest runner and aggregate them at end-of-run.

  • Print a deterministic timing summary (stable sort: elapsed desc, path asc; stable formatting) via MultiProgress to avoid interleaved progress-bar noise.

  • Add CLI flags and environment variables to control output:

    • --timing-summary auto|off|top|full (also SLT_TIMING_SUMMARY)
    • --timing-top-n <N> (also SLT_TIMING_TOP_N, must be >= 1)
  • Default behavior:

    • auto maps to off for local TTY runs and top for CI/non-TTY runs.
  • Add optional debug logging for slow files (over 30s) behind SLT_TIMING_DEBUG_SLOW_FILES=1.

  • Update datafusion/sqllogictest/README.md with usage examples.

Are these changes tested?

  • Covered by existing sqllogictests integration test execution; no new unit tests were added.

  • Manual validation plan (ran locally / in CI as applicable):

    • cargo test --test sqllogictests -- push_down_filter_ --test-threads 16
    • cargo test --test sqllogictests -- --test-threads 16
    • cargo test --test sqllogictests -- --timing-summary top --timing-top-n 10
    • cargo test --test sqllogictests -- --timing-summary full
  • Verified output properties:

    • Summary ordering is deterministic across repeated runs (elapsed desc, path asc).
    • auto mode is quiet on TTY but prints a top-N summary on non-TTY/CI.
    • Pass/fail behavior and error reporting are unchanged.

Are there any user-facing changes?

Yes (test-runner UX only):

  • New optional timing summary output for sqllogictests.

  • New CLI flags / env vars documented in datafusion/sqllogictest/README.md:

    • --timing-summary auto|off|top|full / SLT_TIMING_SUMMARY
    • --timing-top-n <N> / SLT_TIMING_TOP_N
    • SLT_TIMING_DEBUG_SLOW_FILES=1 (optional debug logging for slow files >30s)

No public DataFusion APIs are changed.

LLM-generated code disclosure

This PR includes LLM-generated code and comments. All LLM-generated content has been manually reviewed and tested.

Capture elapsed time once in spawned per-file task and reuse
after join. Remove redundant post-join measurement while
maintaining existing error behavior. Implement safe fallback
to Duration::ZERO for join-level panics or errors where
elapsed time is not available.
Ensure --timing-top-n accepts only values >= 1 by using
clap's value parser with a defined range. Update help text
to reflect this new requirement and clarify in README.md
to avoid silent runtime coercion.
Clarify default behavior for timing summaries in TTY
and non-TTY/CI runs. Maintain conciseness within the
existing timing-summary section.
@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Feb 26, 2026
Replace Clap parser call in sqllogictests.rs:949 with a
custom parser function. Add validation to ensure usize
values are >= 1 in lines 433-443, providing a clear
error message for any input of 0.

let top_n = options.timing_top_n;
let count = match mode {
TimingSummaryMode::Off => 0,
Copy link
Member

Choose a reason for hiding this comment

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

nit: This is already handled at line 391.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I will remove the redundant TimingSummaryMode::Off handling from the count calculation since Off already returns early.

let top_n = options.timing_top_n;
let count = match mode {
TimingSummaryMode::Off => 0,
TimingSummaryMode::Auto | TimingSummaryMode::Top => top_n,
Copy link
Member

Choose a reason for hiding this comment

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

nit: mode cannot be TimingSummaryMode::Auto because Options::timing_summary_mode() does not return it. But it is not doing any harm either.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. timing_summary_mode() normalizes Auto to Top/Off before this point.
I will update the branch logic to only rely on Top vs Full and add a debug_assert! to document/enforce that invariant in debug builds.

@kosiew
Copy link
Contributor Author

kosiew commented Feb 26, 2026

Thanks @martin-g for the quick review.

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 @kosiew and @martin-g

This feature will be super helpful to try and schedule the tests more carefully if we go with #20576

One quick thought I had while skimming this PR was I wonder if we really need all the different modes.

It seems the key thing that we can't do without changes to sqllogictests itself is get the per-file timing. However, everything else we could do with post run scripts,.

For example, rather than adding a special flag --timings-top-n 10 maybe we could follow the unix philosophy and pipe the output to head -n 10

cargo test --test sqllogictests -- --timing-summary | head -n 10

Just a thought to keep the code a bit simpler

ColorChoice::Auto => {
// CARGO_TERM_COLOR takes precedence over auto-detection
let cargo_term_color = ColorChoice::from_str(
let cargo_term_color = <ColorChoice as FromStr>::from_str(
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed?

Copy link
Member

Choose a reason for hiding this comment

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

It is needed because clap::ValueEnum is in scope too.
https://docs.rs/clap/latest/clap/trait.ValueEnum.html#method.from_str

@alamb alamb added the development-process Related to development process of DataFusion label Feb 26, 2026
Streamline timing summary to a single switch, enabling
full deterministic per-file timings sorted slowest-first.
Eliminate all mode and top-N options in sqllogictests.rs,
including the removal of TimingSummaryMode and related
auto branching for summary output. Update README.md
to recommend Unix post-processing with `| head -n 10`.
@github-actions github-actions bot removed the development-process Related to development process of DataFusion label Feb 27, 2026
@kosiew
Copy link
Contributor Author

kosiew commented Feb 27, 2026

For example, rather than adding a special flag --timings-top-n 10 maybe we could follow the unix philosophy and pipe the output to head -n 10 ...a thought to keep the code a bit simpler

Agreed and simplified.

❯ cargo test --test sqllogictests -- --timing-summary
...
Running with 10 test threads (available parallelism: 10)
Per-file elapsed summary (deterministic):                                                 
1.   18.405s  push_down_filter.slt                                                      
2.    6.874s  joins.slt                                                                 
3.    6.713s  aggregate.slt 
...
408.    0.001s  avro.slt                                                                
Completed 408 test files in 19 seconds

@kosiew
Copy link
Contributor Author

kosiew commented Feb 27, 2026

hmmm....

❯ cargo test --test sqllogictests -- --timing-summary 2>&1| head -n 10
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.66s
     Running bin/sqllogictests.rs (target/debug/deps/sqllogictests-47b2fcb888654300)
Running with 10 test threads (available parallelism: 10)
Progress: 50/408 files completed (12%)
Progress: 100/408 files completed (25%)
Progress: 150/408 files completed (37%)
Progress: 200/408 files completed (49%)
Progress: 250/408 files completed (61%)
Progress: 300/408 files completed (74%)
Progress: 350/408 files completed (86%)

It's not as straightforward as I thought.
I'll merge before the simplification and work on simplifying it as a follow up.

@kosiew kosiew added this pull request to the merge queue Feb 27, 2026
Merged via the queue into apache:main with commit e583fe9 Feb 27, 2026
28 checks passed
@alamb
Copy link
Contributor

alamb commented Feb 27, 2026

hmmm....

❯ cargo test --test sqllogictests -- --timing-summary 2>&1| head -n 10
    Finished `test` profile [unoptimized + debuginfo] target(s) in 0.66s
     Running bin/sqllogictests.rs (target/debug/deps/sqllogictests-47b2fcb888654300)
Running with 10 test threads (available parallelism: 10)
Progress: 50/408 files completed (12%)
Progress: 100/408 files completed (25%)
Progress: 150/408 files completed (37%)
Progress: 200/408 files completed (49%)
Progress: 250/408 files completed (61%)
Progress: 300/408 files completed (74%)
Progress: 350/408 files completed (86%)

It's not as straightforward as I thought. I'll merge before the simplification and work on simplifying it as a follow up.

looks good -- thanks!

If possibility is to avoid printing progress when in "timing mode" and only print out the overall runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants