Skip to content

Frame guard: in a busy pattern a ColdFire machine gets only ~20–27 µs a frame, and even a near-empty render shows ~50 µs peaks #1790

Open

Description

@GnocchiBalboa

On an Octatrack MKI with the USB base 9680e9ac…, the frame guard (machine_registry.c, guarded()) skips a module machine's render (stock's silent source in its place) as soon as the machine needs more than about 20–27 µs a frame while a busy pattern plays. The skips grow with the number of trigs on the other tracks and stop when the sequencer stops. Musically, a machine of normal size (~50–120 µs) sounds bitcrushed or chopped in a real live set.

All measurements below come from test builds of a draft machine module (UNGEMACH; its pull request follows and links here). The module times each of its own render calls with DTCN3 and reports once a second through module_tick → api->value. It also counts the frames it was not called for at all, against DTCN3's count of frames (47891 counts a frame). Nothing here needs a development base.

Activity

  1. added
    bug
    on Nov 19, 2026
  2. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    Thanks for the careful write-up, and for timing it from inside the module. The issue says the measurements follow below, but the text ends right after the paragraph on how you measured, so the numbers didn't make it in. Could you add them: the render times and skipped-frame counts per test build, the pattern you played (how many trigs on the other tracks), and whether the sequencer was running? That lets us check the guard's limit against your figures.

  3. GnocchiBalboa commented on Nov 19, 2026

    @GnocchiBalboa
    Author
  4. repeat98 commented on Nov 19, 2026

    @repeat98
    Owner

    The two MKIs give us a useful comparison. On the busy project, the 3 µs sine ran clean even with ~52 µs peaks, and adding ~22 µs of work brought on crackles. On the lighter project, the 57 µs build ran clean. The guard gives the whole frame interrupt about 290 µs on average (80% of a 363 µs frame). Stock playback and both possible render calls for a track share that time. The 36 µs figure in the performance guide is a limit on added work in the stock benchmark. It promises no minimum time per track.

    I ran the C guard from your exact base and from 0.7.9 on the host. With synthetic stock work fixed at 265 µs per frame, a 30 µs callback was skipped 4,510 times in 27,560 frames. With 205 µs of stock work the same callback had zero skips. A 3 µs callback with a 52 µs peak once a second also had zero skips in the heavier case. Both bases gave those results. DTCN3 measures elapsed time, so we still need a trace to tell what caused the peaks on your MKI. Raising the frame share would spend time that the panel and USB need. Hardware measurements

    There is one relevant fix since your build. After a deliberately much larger outlier, the old guard never retried the render in 4,096 test frames. The 0.7.9 guard retried it on frame 1,024. That covers recovery from a stale estimate. The short peaks in your report are still an open question. Guard change in #1389

    @GnocchiBalboa, could you rerun the NULL + knob test on the same busy MKI pattern using base 0.7.9 and the draft rebuilt for that base? The most useful comparison is the same knob setting just below and just above the first crackles, for the same duration. Please include the base identity, knob setting, mean and peak per call, and how you count missing frames when a track can get two callbacks in one frame. On a release base, npm run device -- do diaglog can corroborate guard skips. Just the shed incident's time and a= number are enough. Those incidents are rate-limited to one every ten minutes, so a quiet log over a short run is inconclusive. If you already have a development twin, the guard readings bracketing each run give the actual skip count and track mask. The per-second logs you offered would help match the audible onset to those readings.

  5. GnocchiBalboa commented on Nov 20, 2026

    @GnocchiBalboa
    Author

    thanks for getting back, here are the tzest results:

    issue-1790-reply.md

  6. repeat98 commented on Nov 21, 2026

    @repeat98
    Owner

    Thanks for rerunning the same pattern. On 0.7.10 it played clean at about 38 µs mean render time per frame, with the first crackles around 43 µs. I'll keep this open for the remaining 20–25 µs gap between the mean and peak. The next trace should capture stock work and both render calls in the same frame so we can see what was running when a peak hit.

  7. GnocchiBalboa commented on Nov 23, 2026

    @GnocchiBalboa
    Author

    Thanks for the explanation. A short update from my side, and one observation that may help with the mean-to-peak gap.

    UNGEMACH is now a draft PR: #2081. In the same busy live set on my MKI (base 0.7.10, 6070a4e4), it now runs at about 37 µs mean render time per frame most of the time, with few or no skipped frames. I heard no crackles. The last saving came from dropping the low cut (about 2 µs). It stays limited to one track per Part, like SYNTIZ.

    How I measured: the same as before. DTCN3 times the whole callback of the first UNGEMACH track, both calls of a frame together, and the build reports the mean per frame once a second. A later diag build also reports the knob settings in the same word, so I can tell whether a change in cost follows the module or something else. In that build the skip count is capped at 15 a second.

    The observation: the cost does not follow the module's settings. In free-play runs of up to 10 minutes there are two clear states, and the module switches between them while its settings stay the same:

    State Mean per frame Skipped frames
    A 37–43 µs 0 in most seconds, up to 15+ a second at busy moments
    B 49–60 µs none, for minutes at a time
    • The high-mean state B never coincided with skipped frames. Skips only came in state A. In one 10-minute run, 63 % of the playing seconds had no skipped frame at all.
    • Right after starting the sequencer, a run stayed at 53–59 µs for about 30 s, then 50–54, then 43–46 and later 38–41. No setting changed (PTCH 24, DISS 40, WAVE ~32, RATE 16).
    • Every sequencer stop showed one second at 44–53 µs, with no skips.
    • Stopped, the module reads 34–37 µs steadily.

    Turning one knob at a time (PNCH with trigs, WAVE, PTCH, DISS, RATE free and synced, TONE, a crossfader scene) changed the mean by only 1–3 µs.

    So the 49–60 µs stretches look like the render being slowed or interrupted by something outside it, while the guard does not count those frames as overruns. The guard's skips seem to come with a different state of the set. I can't see more from inside the module. If a development base with the trace you described is ready, I'm happy to run it on this set.

    A side finding that may matter for other ColdFire machines: on the MKI, the code size of the render loop mattered more than its instruction count. The same loop compiled with -O2, all helpers inlined, sample-identical output, was about 10 µs slower per frame than with the builder's -Os. Writing the 16 voice reads as small loops instead of unrolled made it 3–6 µs slower. Per-call state in BSS was also measurably slower than in .data.

    For the first release: one UNGEMACH track is about 10–17 % of the frame, which is above the 10 % ColdFire rule. Would you consider an experimental first release with the one-track limit, as for SYNTIZ? The CPU price and device:qualify are next on my list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions