Skip to content

fix(store): read a part of a join side again in halves when its join gives up (#340) - #831

Open
MathiasVDA wants to merge 2 commits into
mainfrom
b5/parts-split
Open

MathiasVDA wants to merge 2 commits into
mainfrom
b5/parts-split

Conversation

@MathiasVDA

@MathiasVDA MathiasVDA commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Mathias · project thread

Refs #340 (a paid ONLY=osm_track_landuse run must confirm)

What and why

The confirmation run of #810 (bench run 47052744664) still logged side ?w2 not read on term ids; joined another way for the land-use side at 1B triples.

I reproduced it on bench-shaped data (13k tracks, 300k land-use areas, 1.5M buildings), bulk-loaded with tripletrail load, with the join memory scaled to the same ratio.

The cause:

  • A few features have two geometries. In the bench data, OSM area ids become IRIs of other ways (tripletrail-bench#160).
  • So each part of the side, sized for about one row per feature, made a few more rows than that.
  • The part's Vec of rows then doubled past the join memory, and the merge join gave up.
  • One part giving up gave up the whole side.

The fix, in Snapshot::join_ids_each_part:

  • A part whose join gives up is read again in halves, and the parts after it stay at that size. A single value that still gives up gives up the whole, as before.
  • Parts start at an eighth of the join memory, not a quarter.
  • The cross-product guard refuses only more than 16 estimated rows per value, not 4. The estimate multiplies per-triple fanouts that are rounded up: two such steps already gave exactly 4× on the repro.

How it was tested

  • On the scaled repro, the query runs on ids in 0.22 s, against 4.4 s row by row before. The count is the same (480).
  • New a_part_that_gives_up_is_read_again_in_halves in tripletrail-store/tests/join_in_parts.rs. Without the halving it fails.
  • cargo test -p tripletrail-store -p tripletrail-spatial -p tripletrail passes (132 test binaries). Clippy -D warnings and fmt are clean.

Documentation

  • docs/spatial-index.md
  • CHANGELOG (Unreleased, Fixed)
  • Guide: no user-facing option or answer changes

Generated by Claude Code

…gives up (#340)

On a bulk-loaded store, a few land-use features with two geometries took
each part of the side past the memory it was sized for, and the whole
side was joined row by row instead. A part whose join gives up is now read
again in halves, parts start at an eighth of the join memory, and the
cross-product guard allows the rounded-up fanout estimates (16 rows per
value, not 4).
@MathiasVDA MathiasVDA self-assigned this Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

The audit check fails on RUSTSEC-2026-0628 (calamine), which this PR does not touch. It fails on main too (cab0f26). #828 bumps calamine to 0.39; once it merges, I will merge main into this branch so the check reruns.


Generated by Claude Code

@MathiasVDA MathiasVDA added the review:approved Reviewer approved label Dec 3, 2026 — with Claude

Copy link
Copy Markdown
Contributor Author

Approved at 26c8d60. The halving ends (a part of one value that still gives up gives up the whole, as before), it also covers the parts #821 sizes from the query memory, and the new test and the 19 cost_model tests pass locally. audit is red here as on main (the calamine advisory, fixed by #828); I merge main in once #828 lands and merge this on green. The paid osm_track_landuse confirmation stays open on #340, as the PR says.


Generated by Claude Code

This branch has not been deployed

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

Labels

review:approved Reviewer approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant