Station drawing scans every segment several times per station #86

Open
opened 2026-10-13 02:27:36 +00:00 by ImBenji · 0 comments
Owner

From the engineering review on 2026-10-13. Timings are flutter test debug mode on macOS and measure CPU work only, so read the scaling and not the milliseconds. Nothing here measured GPU cost.

_stationInnerBlobRotationAngle and _stationOverlapPunchoutLines in lib/rendering/components/stations.dart (around lines 164 to 235), plus stationOwningLineAngle and _nearestSegmentAngle in lib/models/functions/station_stretch.dart, each walk the full segment list per station. That runs on every tile bake (so every edit) and every frame on the direct or drag path.

Same shape in stationCoveringSegmentZs (lib/models/functions/scene_z_order.dart:171), the halo derivation, which is O(stations x segments) on every scene version bump: 6 ms at 1000 segments, 106 ms at 5000.

Evidence: test/review_probes/perf_static_paint.dart (local, untracked), same 26 stations each run with only the segment count growing. Extra cost over lines only, per direct frame: 82 ms at 1000 segments, 288 ms at 2500, 650 ms at 5000.

Fix sketch: resolve owning angle and overlap candidates per station once per scene version, or query segments through the per-tile line index rather than the full list. Bucket segments in a coarse grid for the halo pass.

From the engineering review on 2026-10-13. Timings are `flutter test` debug mode on macOS and measure CPU work only, so read the scaling and not the milliseconds. Nothing here measured GPU cost. `_stationInnerBlobRotationAngle` and `_stationOverlapPunchoutLines` in `lib/rendering/components/stations.dart` (around lines 164 to 235), plus `stationOwningLineAngle` and `_nearestSegmentAngle` in `lib/models/functions/station_stretch.dart`, each walk the full segment list per station. That runs on every tile bake (so every edit) and every frame on the direct or drag path. Same shape in `stationCoveringSegmentZs` (`lib/models/functions/scene_z_order.dart:171`), the halo derivation, which is O(stations x segments) on every scene version bump: 6 ms at 1000 segments, 106 ms at 5000. **Evidence:** `test/review_probes/perf_static_paint.dart` (local, untracked), same 26 stations each run with only the segment count growing. Extra cost over lines only, per direct frame: 82 ms at 1000 segments, 288 ms at 2500, 650 ms at 5000. **Fix sketch:** resolve owning angle and overlap candidates per station once per scene version, or query segments through the per-tile line index rather than the full list. Bucket segments in a coarse grid for the halo pass.
ImBenji added the enhancementarea:performance labels 2026-10-13 02:27:36 +00:00
ImBenji added this to the Arcs & Angles project 2026-10-13 02:27:36 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: IMBENJI.NET/Metro-Map-Maker#86