Skip to content

Reduce binary size of ScalarUDFImpl default impls - #24966

Open
simonvandel wants to merge 4 commits into
apache:mainfrom
simonvandel:push-npourxvywpmv
Open

Reduce binary size of ScalarUDFImpl default impls#24966
simonvandel wants to merge 4 commits into
apache:mainfrom
simonvandel:push-npourxvywpmv

Conversation

@simonvandel

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Part of #24727

Rationale for this change

Reduce binary code size by reducing monomorphized code.

What changes are included in this PR?

Extracted non-generic default method body implementations of ScalarUDFImpl:

  • coerce_types
  • schema_name
  • return_field_from_args
  • output_ordering

Measurements:
cargo llvm-lines --release -p datafusion-expr --lib | head -3

Before (1d9a982):

  Lines                  Copies               Function name
  -----                  ------               -------------
  1247760                26213                (TOTAL)

After (7278ffd4fe7f):

  Lines                  Copies               Function name
  -----                  ------               -------------
  1247097                26207                (TOTAL)

cargo build --profile release-nonlto --bin datafusion-cli && stat -f%z ../shared-cargo-target/release-nonlto/datafusion-cli

Before (1d9a982):

186946400

After (7278ffd4fe7f):

186574320

So 663 fewer LLVM lines, 372 080 fewer bytes (non-lto build of datafusion-cli)

What is the testing strategy for this PR?

Just code-shuffling, no behaviour change.

Are there any user-facing changes?

Slightly binary size, and maybe faster compilation.

`cargo llvm-lines --release -p datafusion-expr --lib | head -3`

Before (1d9a982):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247760                26213                (TOTAL)
```
After (f6e650279bc9):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247555                26214                (TOTAL)
```
Delta: 1,247,760 -> 1,247,555: -205 (-0.016%); 26,213 -> 26,214: +1 (+0.004%)

`cargo build --profile release-nonlto --bin datafusion-cli && stat -f%z ../shared-cargo-target/release-nonlto/datafusion-cli`

Before (1d9a982):
```
186946400
```
After (f6e650279bc9):
```
186774176
```
Delta: 186,946,400 -> 186,774,176: -172,224 (-0.092%)
`cargo llvm-lines --release -p datafusion-expr --lib | head -3`

Before (f6e650279bc9):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247555                26214                (TOTAL)
```
After (e3ff876dda5f):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247423                26215                (TOTAL)
```
Delta: 1,247,555 -> 1,247,423: -132 (-0.011%); 26,214 -> 26,215: +1 (+0.004%)

`cargo build --profile release-nonlto --bin datafusion-cli && stat -f%z ../shared-cargo-target/release-nonlto/datafusion-cli`

Before (f6e650279bc9):
```
186774176
```
After (e3ff876dda5f):
```
186721568
```
Delta: 186,774,176 -> 186,721,568: -52,608 (-0.028%)
…m_args)

`cargo llvm-lines --release -p datafusion-expr --lib | head -3`

Before (e3ff876dda5f):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247423                26215                (TOTAL)
```
After (076ea5dba12f):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247344                26210                (TOTAL)
```
Delta: 1,247,423 -> 1,247,344: -79 (-0.006%); 26,215 -> 26,210: -5 (-0.019%)

`cargo build --profile release-nonlto --bin datafusion-cli && stat -f%z ../shared-cargo-target/release-nonlto/datafusion-cli`

Before (e3ff876dda5f):
```
186721568
```
After (076ea5dba12f):
```
186635808
```
Delta: 186,721,568 -> 186,635,808: -85,760 (-0.046%)
`cargo llvm-lines --release -p datafusion-expr --lib | head -3`

Before (076ea5dba12f):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247344                26210                (TOTAL)
```
After (7278ffd4fe7f):
```
  Lines                  Copies               Function name
  -----                  ------               -------------
  1247097                26207                (TOTAL)
```
Delta: 1,247,344 -> 1,247,097: -247 (-0.020%); 26,210 -> 26,207: -3 (-0.011%)

`cargo build --profile release-nonlto --bin datafusion-cli && stat -f%z ../shared-cargo-target/release-nonlto/datafusion-cli`

Before (076ea5dba12f):
```
186635808
```
After (7278ffd4fe7f):
```
186574320
```
Delta: 186,635,808 -> 186,574,320: -61,488 (-0.033%)
@github-actions github-actions Bot added the logical-expr Logical plan and expressions label Sep 6, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.64%. Comparing base (1d9a982) to head (a2c6c15).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
datafusion/expr/src/udf.rs 33.33% 15 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24966      +/-   ##
==========================================
+ Coverage   81.62%   81.64%   +0.01%     
==========================================
  Files        1124     1125       +1     
  Lines      412496   413986    +1490     
  Branches   412496   413986    +1490     
==========================================
+ Hits       336710   337984    +1274     
- Misses      55967    56091     +124     
- Partials    19819    19911      +92     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

logical-expr Logical plan and expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants