perf: cheap per-frame and per-fetch savings - #725
Merged
Merged
Conversation
get_odds() logged the raw ESPN body with an f-string around json.dumps(raw_data, indent=2), so every fetched response was pretty-printed and thrown away with DEBUG off. The json.dumps debug lines in _extract_espn_data had the same cost. Those are now guarded with isEnabledFor(DEBUG), and the other debug f-strings on the fetch path use %-style arguments. Same messages at DEBUG; nothing else changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc5DAbSwGGUTm3MrCtpC2m
_get_visible_portion_integer() ran np.ascontiguousarray() on the visible column slice and then tobytes(), copying the frame twice. tobytes() on the non-contiguous view already returns C-order bytes, so the first copy bought nothing. A test pins the bytes against the old expression. On a Pi 4 the bytes step at 512x64 went from ~45 us to ~21 us a frame (timeit, best of 5). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc5DAbSwGGUTm3MrCtpC2m
ledmatrix.service has set MALLOC_ARENA_MAX=2 since #476: glibc gives each allocating thread its own arena (up to 8 x CPU count) and never hands a grown one back. ledmatrix-web.service runs a threaded Flask server with the same exposure but had no cap. Both installers render the template with sed, so the line installs unchanged; on an existing install the startup drift check reports the unit as changed until install_service.sh or install_web_service.sh is re-run, as for any template change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc5DAbSwGGUTm3MrCtpC2m
APIHelper.get/post, BaseOddsManager.get_odds, LogoDownloader's two team fetches and DynamicTeamResolver's rankings fetch called response.json(), the stdlib parser, while background_data_service and espn_dates already use src.common.json_body.response_json (orjson when installed, ~1.7x faster on a Pi 4, holding the GIL for less of the parse). response_json falls back to response.json() on anything orjson rejects, so a bad body still raises requests' JSONDecodeError, which every one of these call sites already catches; a test pins that with real requests.Response objects. Without orjson nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc5DAbSwGGUTm3MrCtpC2m
Every scroller logged a "Scroll frame stats" line at INFO every 5 s, so a healthy rig's journal was mostly these lines. As Vegas's FPS line already does, the line now goes to INFO only for a degraded window (fps below 0.9 of the rate the window was locked to, 1 / its median, or more than 1% of frames stalled), the window after one, and a 5-minute heartbeat per scroller; every window is still logged at DEBUG. The window, the stats and the line's text are unchanged. docs/SCROLL_PERFORMANCE.md says how to see every window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc5DAbSwGGUTm3MrCtpC2m
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uc5DAbSwGGUTm3MrCtpC2m
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 21 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (12)
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 | 7 |
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.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
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
Six small per-frame and per-fetch savings, none changing behaviour:
np.ascontiguousarrayin the scroll integer-slice path (~45 µs → ~21 µs per frame at 512x64 on a Pi 4)MALLOC_ARENA_MAX=2forledmatrix-web.service, matching the display unit (harden: cap malloc arenas, warn on unit drift, and grant the portal's sudo commands #476)response_json(orjson when installed, stdlib fallback)Type of change
Test plan
pytest): full suite passes, apart from 8test_live_status_fields.pytests that needpsutiland fail the same way onmain. Each change has a test (byte-identical output for the slice path, realrequests.Responseobjects for the JSON fallback, the systemd unit line, the log-level gating).Documentation
docs/if developer behavior changed (docs/SCROLL_PERFORMANCE.md,CHANGELOG.md)Plugin compatibility
Notes for reviewer
On an existing install the startup drift check will report the web unit as changed until
install_web_service.shis re-run, as for any template change.🤖 Generated with Claude Code