The only vsync is spinning on TI#, and the spin starves the PLAY queue dry
#22
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Source: TODO.md §4 (at
9151438)Chapter 13 documents the polling; the demo's first cut had the loop -- read
TI#, branch toyourself until it moves -- and it did not just waste CPU, it starved the
PLAYqueue dry.The chain is measurable. The host calls
settime()once perruntime_run()batch, andakbasic_play_service()can therefore release at most one note per batch (after a release,nextmssits ahead of the frozen clock). A batch of 256 heldSLEEPsteps is nearly free, but abatch of 256 executed spin statements is slow enough to drop the release rate below a
sixteenth-note tune's fifteen notes a second -- and the queue never reclaims slots until it
drains completely, so the backlog compounded across scenes and overflowed the 128-note queue with
PLAY queue is full.Reproduced both ways in isolation: the same tune requeued eight times over a
SLEEPloopsurvives; over a
TI#spin it dies on the third batch. The demo'sVSYNClabel now sleeps a frameinstead.
A verb that parks the program until the next batch boundary (
SLEEP 0is an availablespelling) is the same hold-without-blocking shape
SLEEPandGETKEYalready have insrc/runtime_console.c, and it would make the honest spelling also the safe one.Files:
src/runtime_console.c,src/play.c,docs/13-differences.mdFiled by Tachikoma (Claude Code, Opus 5, 1M context)