Skip to content

Execute spatial distance with RowFn - #9349

Draft
connortsui20 wants to merge 2 commits into
ct/row-fn-tensor-productsfrom
ct/row-fn-spatial-distance
Draft

Execute spatial distance with RowFn#9349
connortsui20 wants to merge 2 commits into
ct/row-fn-tensor-productsfrom
ct/row-fn-spatial-distance

Conversation

@connortsui20

@connortsui20 connortsui20 commented Aug 11, 2026

Copy link
Copy Markdown
Member

Rationale for this change

Moves spatial distance to the shared row executor. Each geometry column decodes once per batch, and a constant operand remains one decoded geometry.

What changes are included in this PR?

Adds the crate-private GeometryRow input element and expresses distance as a two-row kernel. Tests cover both constant positions, nullable inputs, mixed geometry types, and exact distance behavior.

Rust 1.97.1 one-CGU fat-LTO measurements keep the ordinary distance cases within 2.7% of develop; the nullable column-by-constant case improves by 13.9%.

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

There are no public API or behavior changes. SpatialDistance implements RowFn and receives the standard scalar-function vtable automatically.

@codspeed-hq

codspeed-hq Bot commented Aug 11, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 17.87%

⚡ 3 improved benchmarks
✅ 2016 untouched benchmarks
⏩ 89 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation cold_misaligned[(64, 256)] 5.4 ms 4.4 ms +22.48%
Simulation slice_dict_tight_loop[10000] 803.3 µs 683.9 µs +17.45%
Simulation nullable_point_column_x_constant_point 762.7 µs 670 µs +13.84%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ct/row-fn-spatial-distance (bba41db) with ct/row-fn-tensor-products (cb67153)2

Open in CodSpeed

Footnotes

  1. 89 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on ct/row-fn-tensor-products (32bd4da) during the generation of this report, so 3d6daed was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-distance branch from fadcf1d to 46c63e4 Compare August 11, 2026 16:04
@connortsui20
connortsui20 marked this pull request as ready for review August 11, 2026 16:05
@connortsui20
connortsui20 marked this pull request as draft August 11, 2026 16:24
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-distance branch from 46c63e4 to 450326d Compare August 11, 2026 17:12
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-distance branch from 450326d to 788ce5f Compare August 11, 2026 17:35
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-distance branch from 788ce5f to bba41db Compare August 11, 2026 19:36
@connortsui20

Copy link
Copy Markdown
Member Author

Here are the local spatial-distance benchmark results from the final Rust 1.97.1 run.

The comparison used a develop baseline with benchmark-only backfills (1edd0fca) and the full RowFn stack (8ca9fc73). Later stack layers do not change spatial distance source, but unrelated code-placement effects can still affect these binaries.

The machine was an AMD Ryzen 9 7950X running Linux. The build used rustc 1.97.1, LLVM 22.1.6, one CGU, fat LTO, and -C target-cpu=native. Each target used two warm runs and seven alternating measured pairs. Each process used 100 samples with a 0.25–0.5 second measurement window on CPU 4.

Negative changes are faster. The values are medians across the seven paired runs.

The three ordinary distance cases remain within 2.65%. The nullable column-by-constant case improves by 13.85%.

All spatial-distance results: 4 cases
Benchmark Baseline RowFn stack Change
point_column_x_constant_point 13.670 µs 14.080 µs +2.65%
polygon_column_x_constant_polygon 33.550 µs 34.180 µs +1.70%
point_column_x_point_column 17.140 µs 17.060 µs +0.47%
nullable_point_column_x_constant_point 18.190 µs 15.680 µs -13.85%

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant