v0.6.1 flush: memcmp finds a row's first and last changed cells
The whole-row memcmp settled an unchanged row, but on a changed row the cell loop then read again the prefix memcmp had already compared, and the trailing trim walked unchanged cells one by one. Chunks of eight cells now find the first and last changed cell, so no cell is compared twice and only the span between them is scanned cell by cell. Output is byte-identical. Measured on frames captured from vif at 60 fps (median of 15, one core): vanguard 120x40 73.7 -> 66.6 us a frame (-10%), vanguard 240x66 158.8 -> 131.8 (-17%), main with the gun firing 40.0 -> 34.1 (-15%), main idle 20.3 -> 14.0 (-31%). Dropping the row compare instead costs +15% to +120% on the same frames.
This commit is contained in:
1 parent
bc22a9bf00
commit
df94556101
3 files changed
+59
-14
No files matched your search
@@ -45,7 +45,9 @@ behaves as `New`'s Terminal does, the writer goroutine included; `New` is
|
||||
The application owns a flat `[]Cell` buffer (row-major, `cells[y*width+x]`) and
|
||||
passes it to `Flush`. The output buffer diffs against the previously flushed frame:
|
||||
|
||||
- Rows are scanned with early termination (trailing unchanged cells skipped).
|
||||
- A row's first and last changed cells are found by memcmp, eight cells a compare:
|
||||
an unchanged row costs those compares alone, and only the cells between are
|
||||
scanned one by one.
|
||||
- Cursor moves are emitted only when the write position is non-contiguous.
|
||||
- SGR state (fg, bg, attributes) is coalesced across cells; redundant sequences
|
||||
are suppressed.
|
||||
|
||||
Reference in new issue
Block a user