Repository navigation
perf(trait): cache rendered base map on Q10 trace updates - #974
allenporter wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address calibration cache invalidation and erase-zone rebuilding, benchmark input/percentile handling, and related test coverage.
Review effort: Lite
Findings: 2
Open (2)
What changed in this PR
Improves Q10 map rendering performance by caching base-map data, layers, and calibration across trace updates.
Changes:
- Adds cached base-map rendering and overlay composition.
- Caches Q10 layer decomposition and optimizes room-color calculations.
- Adds map parsing, rendering, and profiling benchmarks.
| File | Summary |
|---|---|
tests/map/test_benchmarks.py |
Adds benchmark utilities; percentile calculation and non-positive iteration handling require correction. |
roborock/map/room_colors.py |
Optimizes room-color adjacency calculations. |
roborock/map/b01_q10_render.py |
Adds reusable base-map rendering and composition. |
roborock/map/b01_q10_map_parser.py |
Caches layers and defers PNG serialization. |
roborock/devices/traits/b01/q10/map.py |
Adds base-map and calibration caching; calibration lifecycle and coverage require changes. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| parser.add_argument("--profile", action="store_true", help="Print cProfile hotspot breakdown for each benchmark") | ||
| args = parser.parse_args() | ||
|
|
||
| _run_benchmarks(iterations=args.iterations, warmup=args.warmup, profile=args.profile) |
e255fad to
d086d5d
Compare
05c3968 to
7c2907b
Compare
7c2907b to
d3ef605
Compare
d3ef605 to
36df1ad
Compare
swastiktawate
left a comment
There was a problem hiding this comment.
Nice perf win. The invalidation points look complete — a new map packet or DPS update clears both the cached base data and the calibration, so trace-only updates are the only path that reuses the cache. The copy.copy chain with the explicit image.data.copy() shows care that overlay drawing can't mutate the cached base. The mock-based test pins the call counts precisely.

Description
During an active cleaning run, the robot pushes
Q10TracePackettrajectory updates every 1–2 seconds. Previously, each trace packet push triggeredself._render(), which re-decomposed the entire 40,000-cell occupancy grid, re-rasterized the base room layers, and re-solved calibration from scratch.This change:
MapContentTrait(_base_map_data). When only a trace update arrives, the cached base grid is reused and only the path/robot overlays are re-composited._base_map_dataand_trace_calibrationcleanly upon receiving full map updates or DPS changes.Q10MapPacket.layerstocached_propertyto avoid redundant grid decompositions.Note: Stacked on top of #973, #972, #971, and #970.
Performance Impact
Verification
uv run pytest tests/map/ tests/devices/).