Skip to content

Execute spatial predicates with RowFn - #9350

Draft
connortsui20 wants to merge 3 commits into
ct/row-fn-spatial-distancefrom
ct/row-fn-spatial-predicates
Draft

Execute spatial predicates with RowFn#9350
connortsui20 wants to merge 3 commits into
ct/row-fn-spatial-distancefrom
ct/row-fn-spatial-predicates

Conversation

@connortsui20

@connortsui20 connortsui20 commented Aug 11, 2026

Copy link
Copy Markdown
Member

Rationale for this change

Moves contains and intersects to prepared row execution. This lets each batch reuse work derived from constant geometries.

What changes are included in this PR?

contains caches constant bounding boxes and creates a prepared geometry only when a relate path needs it. intersects hoists constant bounding boxes for conservative rejection. Tests cover operand order, constants, nulls, NaN coordinates, bounding boxes, and exact predicate agreement.

Rust 1.97.1 one-CGU fat-LTO results are mixed: most predicate cases remain within 8%, two constant-left contains cases regress by 16%, and sparse-null cases improve by 14–20%. The unchanged bounding-box controls remain near parity.

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

There are no public API changes. The predicates keep their existing OGC behavior and lazy scalar-function interfaces.

@codspeed-hq

codspeed-hq Bot commented Aug 11, 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.

✅ 818 untouched benchmarks
⏩ 1322 skipped benchmarks1


Comparing ct/row-fn-spatial-predicates (2155a49) with ct/row-fn-spatial-distance (7b253da)2

Open in CodSpeed

Footnotes

  1. 1322 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-spatial-distance (56ca4a8) during the generation of this report, so a74b0aa 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-predicates branch from a7a83b0 to 8ca9fc7 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-predicates branch from 8ca9fc7 to 970bec2 Compare August 11, 2026 17:12
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 970bec2 to 5e69f45 Compare August 11, 2026 17:35
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 5e69f45 to a7f8ee0 Compare August 11, 2026 19:36
@connortsui20

Copy link
Copy Markdown
Member Author

Here are the local spatial-predicate 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). 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 change is the median paired ratio, not the ratio of the two displayed medians.

Most predicate cases remain within 8%. Two constant-left contains cases regress by about 16%, while sparse-null cases improve by 14.04–20.45%. The bounding-box controls remain close to parity. The unchanged envelope control moved substantially for multipolygons, which indicates binary-layout sensitivity outside the predicate implementation.

Contains and intersects: 15 cases
Benchmark Baseline RowFn stack Change
contains/constant_x_polygons_disjoint 68.210 µs 79.370 µs +16.36%
contains/constant_x_points 70.630 µs 81.040 µs +15.89%
intersects/polygons_overlapping_x_constant 69.820 µs 74.980 µs +7.82%
intersects/polygons_disjoint_x_constant 68.160 µs 73.160 µs +7.80%
intersects/points_x_constant 70.370 µs 75.390 µs +6.86%
contains/polygons_x_constant_point 12.530 µs 12.930 µs +3.94%
intersects/nullable_points_x_constant 74.250 µs 76.270 µs +3.36%
contains/constant_x_nullable_points 74.560 µs 76.820 µs +2.96%
contains/column_x_column_polygons 17.980 µs 18.250 µs +1.84%
intersects/nullable_polygons_disjoint_x_constant 77.340 µs 78.060 µs +1.36%
contains/constant_x_nullable_polygons_disjoint 77.420 µs 78.250 µs +1.13%
contains/column_x_column_points 12.290 µs 12.440 µs +0.90%
intersects/column_x_column_polygons 16.150 µs 16.200 µs +0.62%
contains/nullable_polygons_90pct_x_constant_point 15.880 µs 13.640 µs -14.04%
contains/nullable_polygons_x_nullable_points 20.220 µs 16.100 µs -20.45%
Envelope controls: 7 cases
Benchmark Baseline RowFn stack Change
multipolygon_random_nulls 21.220 µs 28.500 µs +34.64%
multipolygon_mixed_validity 27.140 µs 35.780 µs +32.22%
multipolygon_non_nullable 28.060 µs 37.000 µs +31.95%
multipoint_non_nullable 19.540 µs 21.760 µs +11.44%
point_random_nulls 1.239 µs 1.269 µs +2.36%
point_non_nullable 1.209 µs 1.229 µs +0.84%
point_mixed_validity 1.269 µs 1.269 µs -0.79%
Bounding-box controls: 8 cases
Benchmark Baseline RowFn stack Change
contains_bbox_disjoint 1.584 µs 1.589 µs +2.20%
intersects_bbox_disjoint 1.584 µs 1.589 µs +2.20%
intersects_bbox_candidate 48.990 µs 48.780 µs +0.02%
contains_exact_disjoint 45.910 µs 45.910 µs +0.00%
intersects_exact_disjoint 46.130 µs 46.130 µs +0.00%
contains_bbox_candidate 48.750 µs 48.690 µs -0.18%
intersects_exact_candidate 43.910 µs 47.700 µs -0.62%
contains_exact_candidate 45.990 µs 46.650 µs -0.76%

@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from a7f8ee0 to 8afa323 Compare August 12, 2026 15:24
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 8afa323 to 808b070 Compare August 12, 2026 17:53
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 808b070 to 545ab01 Compare August 12, 2026 18:10
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 545ab01 to 1997eff Compare August 12, 2026 18:46
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 1997eff to f095e4a Compare August 12, 2026 19:23
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from f095e4a to 65d8de6 Compare August 12, 2026 20:26
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 65d8de6 to 319b6af Compare August 12, 2026 20:50
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 319b6af to 27eca54 Compare August 12, 2026 21:03
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 27eca54 to f90009a Compare August 12, 2026 23:32
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch 2 times, most recently from 12d920a to 7ce135f Compare August 13, 2026 15:40
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from 7ce135f to fe255bf Compare August 13, 2026 16:18
@connortsui20
connortsui20 force-pushed the ct/row-fn-spatial-predicates branch from fe255bf to 2155a49 Compare August 13, 2026 18:37
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
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-predicates branch from 2155a49 to c0f5e8e Compare August 13, 2026 18:54
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