Repository navigation
perf: much faster combine_polygons_below (#868) - #945
Merged
Merged
Conversation
…e seam, Z-order sorted) Fixes systemed#868 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
Thank you! With this and #949 together, Europe (RAM-resident) on my machine falls from 58m06 to 48m30. I've eyeballed the usual failure points and can't see any regressions. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
combine_polygons_belowmuch cheaper (#868).Cause
union_manygrouped multipolygons by bbox overlap and ran a binary reduction ofunion_()within each group. Adjacent landuse parcels (farmland, forest, ...) share edges, so at low zooms a tile holds one group of ~20,000 polygons. In the last rounds of the reduction both sides are huge, and Boost'sunion_()tests every ring without intersections against all vertices of the other side (select_rings->range_in_geometry, no bbox prefilter in Boost 1.83). That is quadratic: on Luxembourg with the OpenTopoMap config, 30% of all CPU time was inpoint_in_range, and two singleunion_manycalls took ~10 s each.Change (
union_manyinsrc/geom.cpponly)union_(); everything else can't overlap and is copied through.Results
OpenTopoMap config with
combine_polygons_below: 13on its landuse layer (land_low), as in #868:union_manycalls from LuxembourgGermany with
--store --shard-stores(the setup from #868, on top of #943): 571 s withoutcombine_polygons_below, 694 s with it. #868 reported ~10 min without and >2 h with.Output
Boost's union is not exactly order-independent, so results differ slightly from before, within the variation master already has:
landpolygon areas differ. Master vs master with reversed union order: 165 (tile, attributes) groups off by >0.1%, worst 6.3%; master vs this PR: 191, worst 6.0%. The larger differences come from simplification of rings that start at a different vertex: with simplification off on that layer, master vs this PR differ in a single group (0.76%). Points, lines and all other layers are identical, and so is output withoutcombine_polygons_below.🤖 Generated with Claude Code