Skip to content

perf(vortex-geo): short-circuit predicates with bounding boxes - #9076

Open
HarukiMoriarty wants to merge 2 commits into
developfrom
nemo/geo-bbox-short-circuit
Open

perf(vortex-geo): short-circuit predicates with bounding boxes#9076
HarukiMoriarty wants to merge 2 commits into
developfrom
nemo/geo-bbox-short-circuit

Conversation

@HarukiMoriarty

@HarukiMoriarty HarukiMoriarty commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

Constant-vs-column geometry predicates currently run the exact spatial predicate for every valid row, even when the constant and row bounding rectangles already prove that the result is false. For complex constant geometries and spatially selective queries, this repeats substantially more work than necessary.

What changes are included in this PR?

  • Add an optional bounding-rectangle pre-check to the shared null-propagating binary geometry executor.
  • Short-circuit vortex.geo.intersects when operand rectangles are disjoint.
  • Short-circuit vortex.geo.contains when the container rectangle cannot cover the contained rectangle, preserving operand order.
  • Keep vortex.geo.distance on exact evaluation because rectangles cannot determine the result.
  • Preserve null propagation and fall back to exact evaluation for empty geometries or overlapping rectangles.
  • Add regression coverage for short-circuiting, nulls, operand order, empty geometries, exact-result equivalence, containment, and distance.
  • Add the predicate_bbox Divan microbenchmark.

Microbenchmark

Command:

cargo bench -p vortex-geo --bench predicate_bbox -- --min-time 0.3 --sample-count 30

The benchmark evaluates 16,384 points against a 128-vertex constant polygon. Median results:

Predicate / workload Exact Bounding-box pre-check Change
contains, disjoint 1.066 ms 33.95 us 31.4x faster
contains, candidate 1.025 ms 1.049 ms 2.3% slower
intersects, disjoint 1.066 ms 33.91 us 31.4x faster
intersects, candidate 1.015 ms 1.031 ms 1.6% slower

Cache the constant geometry's bounding rectangle and use per-row rectangles to reject disjoint intersects and impossible contains checks before exact evaluation. Add correctness coverage and a comparative Divan microbenchmark.

Signed-off-by: Nemo Yu <zyu379@wisc.edu>
@HarukiMoriarty HarukiMoriarty added the changelog/performance A performance improvement label Jul 29, 2026
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.

1 participant