Dandandan opened a new pull request, #24342:
URL: https://github.com/apache/datafusion/pull/24342

   ## Which issue does this PR close?
   
   None. Found while profiling compile times (#24325, #24326, #24329, #24330,
   #24338, #24339) — this is the largest remaining item I measured.
   
   ## Rationale for this change
   
   `datafusion-functions` declares **63 `[[bench]]` targets**. Each one is a
   separate binary that statically links this crate, arrow and criterion, so
   building the crate's benchmarks means 63 link steps.
   
   Linking, not compiling, is the bulk of it: rebuilding a **single** bench 
target
   takes **10.6s**, almost all of it link, and the 63 benchmark files together 
are
   only ~10.5k lines of source.
   
   This is paid by `cargo bench`, by `cargo build --all-targets`, and by CI's
   `clippy --all-targets`.
   
   ## What changes are included in this PR?
   
   The targets are grouped by their `required-features`, which preserves that
   semantics exactly — a group can only be built when its feature is on, just as
   each individual bench could before:
   
   | target | benches | required-features |
   |---|---|---|
   | `string_expressions` | 16 | `["string_expressions"]` |
   | `math_expressions` | 16 | `["math_expressions"]` |
   | `unicode_expressions` | 12 | `["unicode_expressions"]` |
   | `datetime_expressions` | 8 | `["datetime_expressions"]` |
   | `regex_expressions` | 4 | `["regex_expressions"]` |
   | `misc` | 4 | none |
   
   `crypto`, `encoding` and `dictionary_encoding` stay standalone — they are the
   only members of their feature groups, so grouping them would buy nothing.
   
   Each group file declares the individual benchmarks as modules and lists their
   criterion groups in a single `criterion_main!`. `autobenches = false` stops 
cargo
   from picking the module files back up as targets of their own.
   
   **The benchmark code itself is untouched.** There is not a single change to a
   `bench_function`, `benchmark_group` or `bench_with_input` line anywhere in 
the
   diff. Per file the change is only:
   
   - drop `criterion_main!` — a module cannot define `main`
   - drop the now-unused `criterion_main` import
   - drop `extern crate criterion` (a no-op since edition 2018, present in 4 
files)
   - point the four users of `benches/helper.rs` at `crate::helper`
   
   which is why 60 of the 67 changed files have a one- or two-line diff.
   
   ## Are these changes tested?
   
   Interleaved with `main` so machine drift cancels out:
   
   | `cargo clean -p datafusion-functions` then… | main (63 targets) | this PR 
(9 targets) |
   |---|---|---|
   | `cargo build --benches` | 66.5s / 43.9s | **29.3s / 29.9s** |
   | `cargo check --benches` | 15.9s / 15.3s | **13.0s / 13.2s** |
   
   (The build column is noisier on `main` — 63 concurrent link steps contend for
   I/O — hence quoting both runs rather than an average.)
   
   Correctness, all on this branch:
   
   - `cargo bench --bench string_expressions -- --test` runs **252** benchmarks
   - `cargo bench --bench crypto --features crypto_expressions -- --test` runs 
10,
     `encoding` 9, `dictionary_encoding` 36
   - filtering a single benchmark still works:
     `cargo bench --bench math_expressions -- power` → runs just that one
   - `cargo clippy -p datafusion-functions --all-targets` and `cargo fmt 
--check`
     are both clean
   - `cargo metadata` confirms 9 bench targets
   
   ## Are there any user-facing changes?
   
   Only for running an individual benchmark. Where you would previously write
   
   ```
   cargo bench -p datafusion-functions --bench lower
   ```
   
   you now select the group and filter by name:
   
   ```
   cargo bench -p datafusion-functions --bench string_expressions -- lower
   ```
   
   The filter is criterion's own, matching on benchmark id, so it also narrows 
to a
   single case within a benchmark. No library changes.
   
   If this approach looks right, roughly 100 more bench targets across the other
   crates could get the same treatment — I did this one crate first so the 
tradeoff
   is visible on a real diff before it spreads.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to