镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

perf(football): keep the card renderer and card width between strip builds (3.18.3) - #599

Merged
ChuckBuilds merged 4 commits into
mainfrom
claude/football-renderer-memo
Oct 2, 2026
Merged

ChuckBuilds merged 4 commits into
mainfrom
claude/football-renderer-memo

Conversation

@ChuckBuilds

Copy link
Copy Markdown
Owner

Stacked on #598 (base is its branch). Merge #598 first; GitHub then retargets this PR to main.

Why

Every scroll-strip build (each scroll-mode turn, and each Vegas content build) did avoidable setup work:

  • A new GameRenderer per strip. Its constructor loads fonts and the element-style schema. In adaptive layout it also builds a LayoutContext, whose cache of fitted logos and text sizes was then thrown away.
  • A fresh card-width probe on every read of the scroll settings. _default_game_card_width() ran on each read, building up to a dozen throwaway renderers to measure the score gap.

It is stacked on #598 because keeping the adaptive fit cache alive across builds would otherwise make #598's NFL/NCAA "logo:MIA" collision outlast a single build.

What

  • ScrollDisplay._take_card_renderer / _keep_card_renderer:
    • The renderer is popped off the display for the build and put back after. That pop is a single dict operation, so two overlapping builds never share one.
    • A build that raises before putting it back just means the next build constructs a new one; nothing can get stuck.
    • It is reused only for the same config object, card width, panel height and logo cache. A config change rebuilds the whole scroll manager anyway (on_config_change).
  • Rankings are set on every build (rankings_cache or {}), so a reused renderer cannot keep the previous build's ranks.
  • _default_game_card_width() keeps its answer for the same config object and panel height. A failed probe is not kept.
  • Memory stays bounded: the caches that now live across builds are already bounded LRUs (LayoutContext 512 fits / 64 images, the raw logo LRU 128).

Measured

Desktop, a 7-card strip at 192×48, 30 builds per process, run old/new/new/old:

layout before (median) after
classic 6.0 ms 3.4 ms
adaptive 7.2 ms 3.2 ms

Only 6 of the 14 test logos exist in the checkout, so real cards cost more. A Pi is roughly 10–20× slower in absolute terms.

Tests

test_scroll_renderer_reuse.py (new, standalone; needs LEDMATRIX_CORE) runs in both layouts and checks that:

  • the second build constructs no renderer at all;
  • a reused renderer draws a pixel-identical strip to a fresh one;
  • rankings don't leak into a build that has none;
  • a new config object gets a new renderer;
  • a taken renderer is not handed to a second, overlapping build;
  • it is handed back afterwards;
  • a different card width gets a new renderer.

16 checks pass. On the old code it fails: the second build constructs 3 renderers.

Existing tests pass: test_core_scroll, test_vegas_elements, test_live_scroll_refresh, test_config_reload, test_vegas_content_rebuilds_on_change, test_vegas_score_clears_the_logos (19), and test_scroll_mode.py.

Guards: check_version_bump football-scoreboard (3.18.2 → 3.18.3), check_manifest_version_fields, check_manifests_ascii.

🤖 Generated with Claude Code

ChuckBuilds and others added 2 commits October 1, 2026 20:37
NFL and NCAA FB share ten abbreviations (CAR CIN DAL DEN HOU LAC MIA NE
TB TBD) and one scroll strip carries both leagues. The classic logo cache
is scoped by logo directory, but the adaptive path's two caches were not:
_load_raw_logo keyed the unresized logo by abbreviation alone, and the
LayoutContext fit was cached under "logo:<abbr>". Whichever Miami was
drawn first -- Dolphins or Hurricanes -- was drawn on the other's card.
Both keys now include _logo_scope(logo_path). Classic layout unchanged.

Bumps football-scoreboard to 3.18.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uilds

prepare_scroll_content built a new GameRenderer per strip (fonts, element
styles and, in adaptive layout, a LayoutContext whose fitted logos and text
sizes were then thrown away), and every read of the scroll settings
re-measured the default card width with up to a dozen throwaway renderers.
The display now keeps its renderer (taken off the display for the build and
handed back after, so overlapping builds never share one; reused only for
the same config object, card width, panel height and logo cache) and keeps
the measured card width for the same config object and height. Rankings
are set on every build so a reused renderer cannot keep the last ones.

Desktop, 7-card strip, alternated: classic 6.0 -> 3.4 ms, adaptive
7.2 -> 3.2 ms; strips pixel-identical. Bumps football-scoreboard to 3.18.3.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 246e64e5-302d-4989-94ce-17a214cdfb56

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 31 complexity

Metric Results
Complexity 31

View in Codacy

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.

Base automatically changed from claude/football-adaptive-logo-scope to main October 2, 2026 00:53
ChuckBuilds and others added 2 commits October 1, 2026 20:54
Conflicts were the 3.18.2 metadata #598 just squash-merged: the branch's
manifest and CHANGELOG already carry it under 3.18.3; plugins.json taken
from main and regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plugins.json taken from main (registry bot) and regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ChuckBuilds
ChuckBuilds merged commit e5dd1c3 into main Oct 2, 2026
5 checks passed
@ChuckBuilds
ChuckBuilds deleted the claude/football-renderer-memo branch October 2, 2026 01:04
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.

1 participant