SchOS/kernel
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz d53602faf3 gfx: stop redrawing what already looks right
The console got slower the day TIOCGWINSZ started telling the truth.

`ESC[J` -- erase to end of screen -- arrives after every shell prompt, and zsh
redraws the prompt on every keystroke. While the terminal claimed to be 80x24
that erased 1920 cells; once it reported the real 160x50 it erased 8000, and
every one was written to the framebuffer whether or not it already looked
exactly like that.

Measured first, which killed the obvious theory: hoisting the bounds checks
out of gfx_draw_pixel changed a full-screen clear by 1%. The cost is not the
per-pixel function call, it is the framebuffer -- about 128 MB/s here, so four
megabytes is 32 ms of writing, and on a real window with QEMU rendering each
frame it is worse than that.

So write less rather than write faster. The grid already knows what is on
screen: erase_run compares before it draws and skips any row span already
blank in exactly those colours, and vt_clear does the same for the whole
screen.

    100x erase-to-end-of-screen, before   0.101s
    100x erase-to-end-of-screen, after    0.017s

Six times, with -display none where the framebuffer is ordinary RAM. This is
what the backing store is for: comparing is free, writing is not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQ7Qx8E1q1M1bbCq8QLHS2
2026-09-13 13:57:26 +02:00
..
arch/x86_64 time: read the clock from the TSC, not from counting interrupts 2026-09-13 13:57:26 +02:00
core time: read the clock from the TSC, not from counting interrupts 2026-09-13 13:57:26 +02:00
dev gfx: stop redrawing what already looks right 2026-09-13 13:57:26 +02:00
drivers kernel: the clock ran 7x slow because the GPU never acknowledged its interrupt 2026-09-12 21:34:36 +02:00
fs time: read the clock from the TSC, not from counting interrupts 2026-09-13 13:57:26 +02:00
net net: the DHCP lease goes to the log, not over the user's shell 2026-09-12 19:59:05 +02:00
proc tty: six virtual terminals, and the plumbing that makes them terminals 2026-09-13 00:08:00 +02:00
sys time: read the clock from the TSC, not from counting interrupts 2026-09-13 13:57:26 +02:00
kernel.ld Initial commit: Schunix as it stands before the SchOS rename 2026-08-09 13:47:01 +02:00