mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-05 14:55:08 +00:00
perf(scroll): extend and trim the Vegas strip in place
Every strip extension rebuilt the whole strip (np.concatenate: 2-2.6 ms for a 10-14k px strip at 512x64 on a Pi 4) and every trim copied what was left (1.2-1.8 ms), on the render thread. With ~4 ms of slack per refresh, every extension frame on hdpi missed its refresh (5/5 in each soak run). The strip now lives in a buffer with spare room; cached_array is a view of its live columns. An append writes only the new columns (~0.2 ms), a trim only moves the view's start, and the one full copy happens when the buffer is reallocated (STRIP_SPARE_FACTOR 3: about once every two strip-lengths scrolled). A cached_array set from outside -- the multi-display follower's read-only one, create_scrolling_image's -- is never written through, and a new strip lets the old buffer go. last_copy_bytes says what was copied, and the Vegas frame-timing attribution reports that instead of the whole strip. test_scroll_helper_in_place.py: the buffer is reused and only new columns copied, trims copy nothing, reallocation when the room runs out, outside arrays untouched, and random appends/trims/patches/scrolling checked frame by frame against the old copying strip (mutation-checked). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -418,6 +418,15 @@ read any of them:
|
||||
|
||||
### Scrolling
|
||||
|
||||
- A Vegas strip extension no longer costs a late frame. Appending the next
|
||||
group rebuilt the whole strip (`np.concatenate`, 2-2.6ms for a 10-14k px
|
||||
strip at 512x64 on a Pi 4) and trimming copied what was left (1.2-1.8ms),
|
||||
so on hdpi every extension frame missed its refresh. The strip now lives in
|
||||
a buffer with spare room (`ScrollHelper.STRIP_SPARE_FACTOR`): an append
|
||||
writes only the new columns (~0.2ms), a trim only moves the start, and the
|
||||
one full copy happens when the buffer is reallocated, about once every two
|
||||
strip-lengths scrolled. A strip set from outside (the multi-display
|
||||
follower's) is never written through.
|
||||
- A Vegas strip extension costs the render thread about a third of what it
|
||||
did. Appending the next group and trimming what has scrolled past each
|
||||
rebuilt the strip's PIL image from its numpy array in full
|
||||
|
||||
Reference in New Issue
Block a user