From c2b512e803285223959e0a97601c017730d1b0bb Mon Sep 17 00:00:00 2001 From: user Date: Sat, 18 Jul 2026 22:19:59 +0200 Subject: term+libc: batched write rendering - one tile render per write(), 2.3x lines sys_write sets wBatch; render_cursor_tile - the single choke point all of term_putc's visible mutations pass through - then marks a dirty span (per LINE-SLOT, so spans survive scroll rotation for free) instead of rendering. term_write_end renders every dirty tile exactly once, then the cursor. Scrolls stay immediate (blank rebuild is cheap and artifact-free); file-bound writes flush for free. The enabler is in libc: puts() was a SYS_PUTC trap PER CHARACTER, so almost no console output ever went through sys_write. It now issues one SYS_WRITE for the whole string - one trap, one batch, and every line-printer (echo, irc, the shell) gets the batched path. Measured: 37-char write = 128k cycles (3.5k/char) vs ~8k/char down the per-char trap path. Full demo passes; GIF regenerated. --- src/kdata.asm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/kdata.asm') diff --git a/src/kdata.asm b/src/kdata.asm index 13dc6dd..c2316b8 100644 --- a/src/kdata.asm +++ b/src/kdata.asm @@ -68,3 +68,5 @@ wBootFsFresh::DS 1 ; fs_init formatted a blank disk this boot wTicks:: DS 4 ; monotonic 64 Hz system tick (TimerISR), LE wTickTog:: DS 1 ; TimerISR fires at 128 Hz in double-speed mode; ; this toggle keeps wTicks counting at 64 Hz +wBatch:: DS 1 ; inside a sys_write: defer terminal tile rendering +wBatchDirty:: DS 1 ; batched console output happened (flush needed) -- cgit v1.3.1-sl0p