Speed up IslandPruningModule with a cheaper edge-traversability check - #8028
Merged
leonardehrenfried merged 9 commits intoOct 1, 2026
Merged
leonardehrenfried merged 9 commits into
leonardehrenfried merged 9 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev-2.x #8028 +/- ##
=============================================
+ Coverage 74.57% 74.62% +0.04%
- Complexity 22708 22880 +172
=============================================
Files 2514 2533 +19
Lines 87945 88526 +581
Branches 8690 8752 +62
=============================================
+ Hits 65589 66064 +475
- Misses 19307 19394 +87
- Partials 3049 3068 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
leonardehrenfried
force-pushed
the
island-pruning-benchmark
branch
from
September 22, 2026 14:14
cfe35ba to
0c90e4b
Compare
habrahamsson-skanetrafiken
self-requested a review
September 24, 2026 13:23
leonardehrenfried
enabled auto-merge
September 30, 2026 06:35
habrahamsson-skanetrafiken
requested changes
Sep 30, 2026
habrahamsson-skanetrafiken
requested changes
Sep 30, 2026
| } | ||
| var visibilityVertices = StreamUtils.ofIterable(graph.findEdges(AreaEdge.class)).collect( | ||
| Collectors.toSet() | ||
| ); |
Contributor
There was a problem hiding this comment.
It looks like you forgot to actually fetch the visibilityVertices?
Member
Author
There was a problem hiding this comment.
Okay, that was pretty embarrassing.
In order for this to not happen again I added a module test for this very feature and fixed the code.
leonardehrenfried
force-pushed
the
island-pruning-benchmark
branch
from
September 30, 2026 14:15
e63b923 to
e2677ce
Compare
vesameskanen
approved these changes
Oct 1, 2026
habrahamsson-skanetrafiken
approved these changes
Oct 1, 2026
Merged
via the queue into
opentripplanner:dev-2.x
with commit Oct 1, 2026
a408865
8 of 10 checks passed
t2gran
pushed a commit
that referenced
this pull request
Oct 1, 2026
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.
Summary
Speeds up
IslandPruningModule(the graph-builder step that detects small disconnected "islands" of the street graph and prunes or no-thru's them) by replacing the per-edgeStreetEdge.traverse()call incollectNeighbourVertices()with the existing, allocation-freeStreetEdge.canTraverse(TraverseMode)permission check. Benchmarked on a full Norway OSM extract (3 runs on each side), this is a reproducible ~7-8% speedup for island pruning, with identical output (same edges removed/restricted/marked no-thru).Also adds a standalone benchmark,
IslandPruningBenchmark(intest-fixtures, not run by CI), that downloads a full-country OSM extract, builds the street graph, and times island pruning in isolation - the existing unit tests only exercise small fixtures, and this module is specifically CPU/memory sensitive at country scale.Issue
No linked issue - this is a self-contained performance cleanup.
Motivation:
IslandPruningModule.collectNeighbourVertices()callse.traverse(s0)for every outgoing edge of every street vertex, once per travel mode (WALK/BICYCLE/CAR), purely to learn whether an edge is usable and which vertex it leads to - the resultingState's cost/weight is discarded.traverse()still allocates aStateEditor, computes walk/bike speed and slope-adjusted cost, and builds aStateobject for every edge, none of which this module needs.How the code works / approach:
StreetEdgealready exposescanTraverse(TraverseMode), a permission + barrier-vertex check with no allocation.collectNeighbourVertices()now uses that directly for plainStreetEdge/AreaEdgeinstances (keeping the same "dismount and walk the bike" fallbackStreetEdge.traverse()applies for BICYCLE mode), and only falls back to a realtraverse()call for edge types that don't behave like a simple permission-gated street edge (escalators, pathways, vehicle rental/parking edges).