fix(geochron): cache the map per panel size instead of thrashing between two - #283
fix(geochron): cache the map per panel size instead of thrashing between two#283ChuckBuilds wants to merge 1 commit into
Conversation
…een two The rendered map lived in a single _cached_map, and display() re-rendered whenever the cached layout's size differed from the display manager's. Vegas captures this plugin through the display-capture fallback at a narrower width than the panel -- 153px against 512px on the rig this was found on -- so the two sizes alternated and every switch re-rendered from scratch. For a capture that happens on the render thread. Measured there at 271ms, 292ms, 559ms, 283ms, 287ms and 639ms per pass, which is a visibly stalled marquee. Timed the two halves: compute_terminator is 105ms and does not depend on size at all, render_map_image is ~150ms and does. The terminator is now computed once per update and shared, and the map is cached per (width, height). update() re-renders every size in use, on the update worker, so the render thread finds a warm image rather than building one. Deliberately not solved by refreshing less often. The obvious alternative -- recompute every 30 minutes rather than every 45 seconds -- would trade accuracy for the same saving, and the readout is drawn after the map on every display() call, so a throttle risks the clock while a per-size cache does not. The terminator keeps its configured update_interval. Mutation-checked, all four caught: update() refreshing only the live size, recomputing the terminator per size, the render not populating the cache, and folding the clock into the cached image. Harness clean. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Udr6MfaFLUPhX5Fgo67Jf5
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 32 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
The problem
The rendered map lived in a single
_cached_map, anddisplay()re-rendered whenever the cached layout's size differed from the display manager's:Vegas captures this plugin through the display-capture fallback at a narrower width than the panel — 153 px against 512 px on the rig this was found on. So the two sizes alternated, the one-entry cache missed every time, and each switch re-rendered the whole map from scratch. For a capture, that runs on the render thread.
Caught in the act:
Measured across a session at 271, 292, 559, 283, 287 and 639 ms per pass — a visibly stalled marquee.
Where the time goes
Timed the two halves directly:
compute_terminatorrender_map_imageSo a third of it was recomputing something that didn't depend on the size that had just changed.
The fix
The terminator is computed once per update and shared across sizes. The map is cached per
(width, height), andupdate()re-renders every size in use — on the update worker — so the render thread finds a warm image instead of building one.Why not just refresh less often
The obvious alternative is to recompute every 30 minutes rather than every 45 seconds. That trades accuracy for the same saving, and it has a sharper edge:
_draw_readout()draws a clock. It runs after the map is pasted, on everydisplay()call, so a cached map doesn't freeze the time — but a throttled refresh would put the clock at risk, and the terminator would drift ~7.5° of longitude between rebuilds.Caching per size costs nothing in accuracy, so the terminator keeps its configured
update_interval. The test asserts the readout is still drawn on everydisplay()and still reads the clock fresh, so a later change can't quietly fold it into the cached image.Verification
Mutation-checked, all four caught:
update()refreshing only the live size (the thrash returning)Safety harness clean. Deployed to the rig it was diagnosed on; I'll post the before/after render-thread cost here.