Summary
The output buffer tracks pending rendering work at two levels:
Cell.IsDirty for individual cells
DirtyLines for rows that may contain pending dirty cells
Rows remain flagged in DirtyLines after their dirty cells have been written and cleared. Subsequent output passes then continue to scan those rows despite there being no cell-level work left.
Proposed optimization
Maintain the row-level dirty-state lifecycle alongside the existing cell-level lifecycle:
- Clear
DirtyLines[row] after all pending cells in that row have been processed.
- Mark
DirtyLines[row] whenever a drawing operation dirties a cell in that row.
This allows the output pass to skip rows with no pending changes while preserving correct rendering for text writes, fills, and other buffer updates.
Expected impact
A prototype benchmark using a warmed 340x65 buffer and a single-cell update measured:
| Metric |
Current behavior |
Optimized behavior |
| Mean output-buffer refresh time |
166.0 us |
3.315 us |
| Allocation per refresh |
270.35 KB |
5.85 KB |
| Dirty-row processing |
Previously rendered rows remain eligible |
Only rows with pending work are processed |
The benchmark uses a no-I/O output backend, so it isolates framework overhead.
Acceptance criteria
- A row is skipped when it contains no pending dirty cells.
- A row becomes eligible for output whenever a drawing operation dirties one of its cells.
- Existing rendering behavior, including fills and wide-glyph handling, remains correct.
- Regression tests cover clearing a row after output and re-marking it after a subsequent update.
Alternatives considered
Recomputing row state from every cell during each output pass would avoid stale flags, but would retain the full-screen scan that the row-level optimization is intended to avoid.
Summary
The output buffer tracks pending rendering work at two levels:
Cell.IsDirtyfor individual cellsDirtyLinesfor rows that may contain pending dirty cellsRows remain flagged in
DirtyLinesafter their dirty cells have been written and cleared. Subsequent output passes then continue to scan those rows despite there being no cell-level work left.Proposed optimization
Maintain the row-level dirty-state lifecycle alongside the existing cell-level lifecycle:
DirtyLines[row]after all pending cells in that row have been processed.DirtyLines[row]whenever a drawing operation dirties a cell in that row.This allows the output pass to skip rows with no pending changes while preserving correct rendering for text writes, fills, and other buffer updates.
Expected impact
A prototype benchmark using a warmed 340x65 buffer and a single-cell update measured:
The benchmark uses a no-I/O output backend, so it isolates framework overhead.
Acceptance criteria
Alternatives considered
Recomputing row state from every cell during each output pass would avoid stale flags, but would retain the full-screen scan that the row-level optimization is intended to avoid.