Skip to content

Optimize dissolve_and_inherit_attributes and reduce_nearby_points_by_selecting - #174

Merged
JuhoErvasti merged 6 commits into
mainfrom
perf-buildings
Oct 22, 2026
Merged

JuhoErvasti merged 6 commits into
mainfrom
perf-buildings

Conversation

@JuhoErvasti

@JuhoErvasti JuhoErvasti commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Mainly targeting GeneralizeBuildings. Main culprits were dissolve_and_inherit_attributes (and group_geometries_by_intersections_recursively) and reduce_nearby_points_by_selecting which are now optimized. The single largest remaining bottleneck is simplify_building_ruas which we can't directly affect (without writing our own implementation of it).

API changes:

  • dissolve_and_inherit_attributes: remove inherit_from parameter, instead hard-code "most_intersection" option
    • "min_id" was kind of a legacy option and it was not used anywhere and I'm really hard-pressed to think why it would be ever used over most_intersection
  • reduce_nearby_points_by_selecting:
    • remove priority_column, again this was not being used anywhere
    • force reference_points_gdf as a keyword argument; this is more in line with the library API generally
  • group_geometries_by_intersections_recursively:
    • rename to group_intersecting_geometries
    • shorter and IMO clearer (and there's no longer a recursive function used)

Benchmark Change Report

Comparing perf-buildings against main (Threshold ±25.0)

Buildings:

Benchmark Base Mean PR Mean Change Status
test_generalize_buildings_50k 12.196 s 1.884 s -84.55%
test_generalize_buildings_100k 4.528 s 536.22 ms -88.16%

Others:

Benchmark Base Mean PR Mean Change Status
test_generalize_landcover 6.293 s 1.559 s -75.22%
test_dissolve_polygons 11.69 ms 2.25 ms -80.71%
test_generalize_building_areas 847.70 ms 533.28 ms -37.09%
test_generalize_conservation_areas * 12.612 s 1.368 s -89.16%

* This is misleading; the dissolve_and_inherit_attributes improvement probably improved things slightly, but I also reduced the amount of test data.

Type of change

  • Bug fix

  • New feature

  • Other

  • Non-breaking change

  • Breaking change

Developer checklist

  • A CHANGELOG entry has been included (only when change is visible to users)

@JuhoErvasti
JuhoErvasti requested a review from rnousia October 16, 2026 14:17
@github-actions

Copy link
Copy Markdown

Benchmark Change Report

Comparing perf-buildings against main (threshold at ±25.0)

Passes threshold:

Benchmark Base Mean PR Mean Change Status
test_generalize_building_areas 1.202 s 809.70 ms -32.65%
test_generalize_landcover 8.393 s 2.088 s -75.12%
test_generalize_buildings_50k 16.813 s 3.324 s -80.23%
test_dissolve_polygons 16.50 ms 3.23 ms -80.43%
test_generalize_buildings_100k 5.814 s 790.08 ms -86.41%
test_generalize_conservation_areas 17.098 s 2.126 s -87.56%
Does not pass threshold
Benchmark Base Mean PR Mean Change Status
test_add_contiguous_lines_information[100] 1.31 ms 1.48 ms +13.05%
test_merge_connecting_lines_by_attribute[5000] 68.46 ms 74.49 ms +8.80%
test_merge_connecting_lines_by_attribute[1000] 16.10 ms 17.33 ms +7.64%
test_count_connections[10000] 45.21 ms 47.50 ms +5.08%
test_concatenate_lines 624.45 µs 655.56 µs +4.98%
test_generalize_watercourse_lines 824.07 ms 853.82 ms +3.61%
test_generalize_points[aggfunc] 14.48 ms 14.73 ms +1.73%
test_generalize_shared_paths 3.103 s 3.142 s +1.26%
test_assign_nearest_z[20000] 1.354 s 1.368 s +1.06%
test_generalize_watercourse_areas 6.850 s 6.910 s +0.88%
test_get_topological_points[100] 100.06 µs 100.67 µs +0.61%
test_get_line_connection_points[100] 134.47 µs 135.12 µs +0.48%
test_generalize_points[points] 14.19 ms 14.24 ms +0.35%
test_generalize_polygons_to_points 1.77 ms 1.77 ms +0.21%
test_generalize_slopelines 11.95 ms 11.97 ms +0.13%
test_gaussian_smooth[10000000] 1.132 s 1.133 s +0.05%
test_assign_nearest_z[5000] 315.05 ms 315.12 ms +0.02%
test_generalize_contours 82.19 ms 82.18 ms -0.00%
test_generalize_cliffs 14.96 ms 14.96 ms -0.01%
test_assign_nearest_z[100] 6.47 ms 6.45 ms -0.33%
test_generalize_points[displacement] 308.06 ms 306.84 ms -0.40%
test_count_connections[100] 519.57 µs 517.37 µs -0.42%
test_merge_connecting_lines_by_attribute[100] 4.15 ms 4.13 ms -0.53%
test_get_contiguous_lengths[10000] 18.56 ms 18.46 ms -0.56%
test_add_contiguous_lines_information[10000] 64.39 ms 63.95 ms -0.68%
test_remove_overlap[points] 9.81 ms 9.74 ms -0.72%
test_generalize_water_areas 1.288 s 1.278 s -0.75%
test_merge_connecting_lines_by_attribute[10000] 147.22 ms 146.06 ms -0.79%
test_flag_connections[100] 527.79 µs 523.49 µs -0.82%
test_get_topological_points[5000] 3.58 ms 3.55 ms -0.85%
test_generalize_railroads 1.462 s 1.449 s -0.91%
test_gaussian_smooth[1000000] 80.38 ms 79.57 ms -1.01%
test_substring 86.83 µs 85.92 µs -1.05%
test_keep_intersection[points] 13.28 ms 13.14 ms -1.05%
test_gaussian_smooth[100000] 8.05 ms 7.96 ms -1.09%
test_get_line_connection_points[1000] 738.80 µs 729.93 µs -1.20%
test_get_line_connection_points_roads 1.44 ms 1.42 ms -1.22%
test_keep_intersection[lines] 13.66 ms 13.48 ms -1.32%
test_get_contiguous_lengths[1000] 1.67 ms 1.65 ms -1.37%
test_thin_points 64.47 ms 63.56 ms -1.42%
test_keep_intersection[polygons] 15.31 ms 15.09 ms -1.44%
test_assign_nearest_z[1000] 59.40 ms 58.49 ms -1.53%
test_gaussian_smooth[30000] 2.43 ms 2.39 ms -1.57%
test_remove_overlap[polygons] 11.83 ms 11.63 ms -1.70%
test_flag_connections[1000] 3.12 ms 3.07 ms -1.72%
test_get_contiguous_lengths[100] 390.23 µs 382.75 µs -1.92%
test_count_connections[5000] 20.77 ms 20.37 ms -1.92%
test_generalize_power_lines 3.539 s 3.471 s -1.94%
test_remove_overlap[lines] 10.18 ms 9.98 ms -1.99%
test_gaussian_smooth[1000] 258.81 µs 253.58 µs -2.02%
test_get_topological_points[1000] 641.55 µs 627.48 µs -2.19%
test_flag_connections[5000] 20.98 ms 20.51 ms -2.22%
test_generalize_fences 753.73 ms 737.01 ms -2.22%
test_get_contiguous_lengths[5000] 9.24 ms 9.03 ms -2.31%
test_gaussian_smooth[100] 182.48 µs 178.16 µs -2.37%
test_gaussian_smooth[10000] 928.52 µs 906.48 µs -2.37%
test_get_line_connection_points[5000] 4.45 ms 4.34 ms -2.52%
test_count_connections[1000] 3.04 ms 2.96 ms -2.60%
test_get_line_connection_points[10000] 10.06 ms 9.75 ms -3.08%
test_get_topological_points_roads 2.87 ms 2.78 ms -3.20%
test_generalize_address_points 245.71 ms 234.76 ms -4.46%
test_get_topological_points[10000] 9.17 ms 8.73 ms -4.77%
test_assign_z_from_attribute 4.87 ms 4.55 ms -6.58%
test_generalize_roads 12.41 ms 11.55 ms -6.93%
test_add_contiguous_lines_information[5000] 33.61 ms 31.23 ms -7.08%
test_add_contiguous_lines_information[1000] 5.80 ms 5.16 ms -11.01%
test_flag_connections_to_reference 19.57 ms 17.35 ms -11.33%
test_flag_connections[10000] 50.32 ms 43.62 ms -13.32%

@JuhoErvasti
JuhoErvasti merged commit 4a19045 into main Oct 22, 2026
4 checks passed
@JuhoErvasti
JuhoErvasti deleted the perf-buildings branch October 22, 2026 13:18
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.

2 participants