Skip to content

Add scalar function performance baselines - #9136

Open
connortsui20 wants to merge 1 commit into
ct/l2-denorm-encodingfrom
ct/scalar-fn-baselines
Open

Add scalar function performance baselines#9136
connortsui20 wants to merge 1 commit into
ct/l2-denorm-encodingfrom
ct/scalar-fn-baselines

Conversation

@connortsui20

@connortsui20 connortsui20 commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

Tracking Issue: #9128

Adds stable scalar function performance baselines for byte_length, l2_norm, normalized, inner_product, cosine_similarity, GeoContains, and GeoIntersects.

The benchmark sizes are all comfortably above the roughly 146-instruction Divan harness floor from #9011. Each benchmark binary also uses vendored mimalloc, since scalar function execution allocates its output inside the timed trace and glibc differences between runner images caused the flakes fixed in #8861.

Why

Codspeed can only compare a later implementation change when the same benchmark name already exists on develop, so these baselines need to land before the RowFn things I want to make. And these are pretty cheap, might as well add them.

@codspeed-hq

codspeed-hq Bot commented Aug 1, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 1885 untouched benchmarks
🆕 74 new benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
🆕 Simulation inline[4096] N/A 141.1 µs N/A
🆕 Simulation inline[65536] N/A 1.8 ms N/A
🆕 Simulation nullable_out_of_line[4096] N/A 156.8 µs N/A
🆕 Simulation nullable_out_of_line[65536] N/A 1.8 ms N/A
🆕 Simulation out_of_line[4096] N/A 141.7 µs N/A
🆕 Simulation out_of_line[65536] N/A 1.8 ms N/A
🆕 Simulation add_i32_nonnull N/A 915.7 µs N/A
🆕 Simulation add_i64_constant N/A 1.2 ms N/A
🆕 Simulation add_u32_nonnull N/A 916.7 µs N/A
🆕 Simulation nullable_out_of_line_90pct[4096] N/A 169.6 µs N/A
🆕 Simulation nullable_out_of_line_90pct[65536] N/A 1.8 ms N/A
🆕 Simulation like_per_row_distinct_patterns N/A 628.3 µs N/A
🆕 Simulation like_per_row_repeated_patterns N/A 173.1 µs N/A
🆕 Simulation column_x_column_points N/A 720.4 µs N/A
🆕 Simulation column_x_column_polygons N/A 1.1 ms N/A
🆕 Simulation constant_x_nullable_points N/A 1.6 ms N/A
🆕 Simulation constant_x_nullable_polygons_disjoint N/A 1.8 ms N/A
🆕 Simulation constant_x_points N/A 1.4 ms N/A
🆕 Simulation constant_x_polygons_disjoint N/A 1.6 ms N/A
🆕 Simulation column_x_column_polygons N/A 1 ms N/A
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.


Comparing ct/scalar-fn-baselines (210a2c8) with ct/l2-denorm-encoding (a562e60)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@joseph-isaacs

Copy link
Copy Markdown
Contributor

This benchmark has a too long runtime

@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch from 880ddac to 69edd3a Compare August 3, 2026 15:57
@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch 2 times, most recently from f599518 to 9fcb4a7 Compare August 3, 2026 19:56
@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch 2 times, most recently from 1dccaaf to bf814bb Compare August 3, 2026 20:30
@connortsui20
connortsui20 changed the base branch from ct/scalar-fn-factory-ext to ct/l2-denorm-encoding August 3, 2026 20:37
@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch from bf814bb to 003cc85 Compare August 3, 2026 21:19
@connortsui20 connortsui20 added the changelog/performance A performance improvement label Aug 3, 2026
@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch from 003cc85 to 9755708 Compare August 3, 2026 21:40
@connortsui20
connortsui20 marked this pull request as ready for review August 3, 2026 21:58
@joseph-isaacs

Copy link
Copy Markdown
Contributor

Still too long

@connortsui20

Copy link
Copy Markdown
Member Author

@joseph-isaacs what is too long? which one?

https://github.com/vortex-data/vortex/blob/develop/docs/developer-guide/benchmarking.md has nothing about benchmarks being too long, can you make a PR there?

@joseph-isaacs

Copy link
Copy Markdown
Contributor

column_x_column_polygons | N/A | 23.8 ms

@connortsui20

Copy link
Copy Markdown
Member Author

@joseph-isaacs this is unhelpful. There are other benchmarks here that are longer too (i.e. 123ms). Is there some limit here that is undocumented? Why is it bad for microbenchmarks to be "long" in the first place if we're still able to get useful info out of it?

@robert3005

Copy link
Copy Markdown
Contributor

They’re not very micro benchmarks with that runtime. I think in aggregate there’s ~30 non compliant benchmarks. This numbers is an arbitrary threshold we keep to stop them from decaying over time

@joseph-isaacs

Copy link
Copy Markdown
Contributor

I usually think under 1 ms is a good target unless there is a very good reason to go above this.

If we go above this two things happen:

  • the time benchmarks take to run just keep increase at a faster rate
  • codspeed gets upset

connortsui20 pushed a commit that referenced this pull request Aug 4, 2026
…9176)

## Rationale for this change

The benchmarking guide asked for "less than 1ms" per iteration without
saying whether that was an aspiration or a limit, and without saying
which number to measure against it.

That gap showed up in review on #9136, where benchmarks landed at 23.8
ms and 123.4 ms per iteration. The review conversation there had no
documented rule to point at — as noted on that PR, the guide "has
nothing about benchmarks being too long".

This documents the rule first, on its own, so it can be cited
independently of any tooling that enforces it.

## What changes are included in this PR?

Docs only — one section of `docs/developer-guide/benchmarking.md`:

- States that **1 ms is the maximum, not a soft target**.
- Says what to do when a benchmark does not fit: shrink the input, split
it into smaller parameterized cases, or gate it with
`#[cfg(not(codspeed))]`.
- Names the number to check: the **per-iteration** time CodSpeed reports
under `HEAD` for every benchmark a PR adds or changes — not the runtime
of the whole benchmark binary, which is what "this benchmark takes too
long" usually gets confused with.

The heading loses its `~` (`under ~1 ms` → `under 1 ms`), which leaves
the existing anchor `#keep-per-iteration-execution-time-under-1-ms`
unchanged.

A follow-up branch adds CI that reads CodSpeed's report and comments
when a new or changed benchmark exceeds this budget. It is deliberately
kept out of this PR so the rule can be agreed on its own.

## What APIs are changed? Are there any user-facing changes?

No code, no API changes. Documentation only.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01FZJAp4wVgwTVhLyErCWFZn

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FZJAp4wVgwTVhLyErCWFZn)_

Co-authored-by: Claude <noreply@anthropic.com>
@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch from 9755708 to 57236cb Compare August 4, 2026 17:28
@connortsui20

Copy link
Copy Markdown
Member Author

@joseph-isaacs everything is sub ms now

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/scalar-fn-baselines branch from 57236cb to 210a2c8 Compare August 4, 2026 18:57

@HarukiMoriarty HarukiMoriarty left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The geo part micro benchmark looks good to me!

connortsui20 added a commit that referenced this pull request Aug 4, 2026
Measured against develop through #9136's own public-path bench, the RowFn port
was 7.6-7.7x slower across every arm at 65536 rows (13.5us to 104us, divan
fastest and median of 100 samples, best of two ABBA runs, Apple M4 Max). The
non-nullable arms regressed as hard as the nullable ones, so this was never
about masking or validity.

Half of it was a defect worth recording: BytesLen::get called
VarBinViewArray::views once per row, which is a host-buffer downcast, a
vortex_expect whose panic path the optimizer cannot hoist, a length division and
a slice reconstruction. Pointing Varying at the views slice instead took it from
104us to 52us. Bytes::get had the same bug. This is the trap the InputElement::get
doc warns about, and the next person to add an element should assume Varying is
load-bearing rather than decorative.

The other half is not a defect. Develop's views().iter().map(...).collect()
vectorizes to better than one row per cycle, while a strided four-byte field read
widened to eight does not. The row executor itself is fine: row_checked_add hits
0.21ns per row on the same machine, matching both a specialized control and
develop's byte_length, while reading two input columns instead of one. So
byte_length is the outlier, and it is the case #9128 already excludes, where a
row is not the natural unit of work.

Reverting the port leaves Bytes, BytesColumn and BytesLen with no caller, so they
go too, along with the two branch-only byte benches. Shout keeps its coverage as
a test-local element, since it was the crate's only non-dense-safe input and
therefore the only in-crate exercise of the Filter contract and of branch-and-skip
agreeing with filter-and-scatter. The two compile_fail doctests move to inline
elements; both were verified against a positive control, which caught two bugs in
the rewrite where they had been failing for unrelated reasons.

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants