Skip to content

Improvement: a CPU budget admits Octatrack machines before they play - #1482

Merged
repeat98 merged 8 commits into
mainfrom
improvement/cpu-budget
Nov 12, 2026
Merged

repeat98 merged 8 commits into
mainfrom
improvement/cpu-budget

Conversation

@repeat98

@repeat98 repeat98 commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner
  • What was wrong or hard: Machines that render on the ColdFire had no admission. The frame guard only drops renders once the frame interrupt is over its share, so a musician with too many machines heard dropouts (or met a DSP stall) and never a refusal, unlike DSP effects, which are refused with a box.

  • What this changes: The base bills machines the way it bills DSP effects, with declared prices, not live measurement.

    • A machine's price is reserved[0] of struct modwerk_machine, in percent of a frame (no ABI change); a machine that names none costs 12, a DSP-voice machine 0. The allowance for added machines is 45 % of a frame.
    • A pick over the allowance is refused with a CPU FULL box. A loaded Part that asks for too many keeps the later tracks (in track order) on the silent source and says so.
    • npm run device -- cpu reads the bill and the longest render per track on a dev twin; cpu:PERCENT sets the allowance for a test. A refusal reaches diagnostics as incident cpu, and diagnostics:pull prints it.
    • New beta base 5ef4d447; the five base-bound packages are relinked to it, their code unchanged.
  • How I checked it: npm run pr:ready says Ready on main 28a2fc312 (host tests cover the bill, the refusal, the box and the diagnostics record). On the owner's MKII, RAM-booted dev twins of this branch (e609a796; dfbf58d6 with a temporary trace that is not in the branch), OS 1.40C:

    • The owner tried the CPU FULL refusal on the unit with FM Synth on several tracks; the trial counted 6 refusals.
    • Stock load of one busy project: 23 % mean of a frame fresh after boot, 45-57 % at rest after the first PLAY, 73-77 % playing with three modules installed; one stock FLEX render is 4.8-9.5 % of a frame per call.
    • Not done: the 45 / 12 constants are estimates and were not calibrated; POLY8 and VECTOR were not measured; the release base 5ef4d447 itself was not run on a unit, only its dev twins. One run with FM Synth, POLY8 and VECTOR installed and an 8-track pattern ended in a DSP stall ("frames stopped", frame max 163 %, the guard skipped nothing): the budget does not prevent that case yet, see the next point.
    • Known limit: FM Synth 0.1.2's package patches the STATIC renderer entry itself, so with it installed every track renders through its own wrapper, outside the base's dispatch. A refused pick works, but the frame guard cannot shed an FM Synth voice and a refused track is not silenced. The fix belongs in FM Synth (FM Synth 0.1.3 (draft): cheaper on tracks that don't use it #1473) and comes next.
  • What the guides lacked or got wrong, and where I fixed it: they did not cover a CPU price or how to read it on a unit; fixed in two guides, three traps are noted but not fixed here.

    • docs/MODULE_PERFORMANCE.md: the CPU price and how to read it with cpu.
    • docs/OCTATRACK_DRIVING.md: the cpu step.
    • Not fixed here: modwerk_events.h is generated from events.json, which nothing says at the header; octatrack:module-packages --base-only skips Sidechain's lagging row, which then needs the new base identity by hand; check_mcf54455 reads a switch's jump table as instructions (worked around in status.c with no-jump-tables on one function; the check wants its own Fix:).

🤖 Generated with Claude Code

repeat98 and others added 8 commits November 12, 2026 16:50
A Part's ColdFire machines are added up against an allowance at each pick
and each UI tick. A pick past it is refused with a CPU FULL box; a track past
it after a load renders stock's silent source. The frame guard stays as the
backstop. Prices and the allowance are estimates until measured on a unit
(npm run device -- cpu); the base is not regenerated yet.

Co-Authored-By: Claude <noreply@anthropic.com>
…lt with the CPU budget

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…ox builds on the host, and the base follows

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant