Repository navigation
Conversation
WIP: bitmap and guard scan in the dispatch code; rig tests; generated objects follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al baseline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tch include Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cks; prove the writer order The type words are written by copy loops that run before the voice loop on both devices (finding 188), so the bitmap needs no re-check. Reconcile finding 48. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The slot bitmap build shifted the mask by 31 - type and sign-extended the bit. With one bit per slot the mask can instead be shifted down by the type and the low bit deposited: 5 instructions a slot, not 6 (16 fewer on DN2). This keeps the analog machine's slot 0 block within its budget. The Python MachineRig set every slot active, so a block of an unregistered type took the full path and the table walk. It now sets the bitmap slot 0 leaves, from the slot types and the mask. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
m-dwyer
force-pushed
the
perf/runtime-dispatch-empty-slots
branch
from
December 6, 2026 09:40
d8c92ca to
501250e
Compare
…Python rig The rig no longer re-implements the active-slot bitmap in Python: a call of a slot above 0 first runs the assembly's slot 0 on the same frame, which builds _dv_mask and _dv_active, and only the measured call is counted. This drops the device-name branch (device-literals baseline back to 48). The dsp-active rig test now covers types 0, 6, 7, 30, 31 and above 31 and rows of 30 and 31 on both devices. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With any machine type registered the runtime's
_dv_rundispatch runs for every voice slot. An empty slot cost 58 instructions on DT2 (stock 8) and 61 on DN2 (stock 10): 1,740 of the 3,978 per block with one Pluck voice on DT2. The output guard scan costs 3 instructions per word.Changes
_dv_active: the first slot of a block builds a bitmap of the slots that need the full path (a type with a row; on DT2 also a type of 7 or more, which keeps the stage 3 breadcrumb). Other slots test their bit and return to the stock renderer. A clear DT2 slot still writes the stage 1 breadcrumb, so the watch's last-step word is unchanged. The word is a newPKDATAof the two stubs plus adyndspimport row on each device; DN2's_dv_q2,_dv_q4,_dv_ql4are removed (no longer used)._dv_gcheck(and the DN2 guard): the load of word i+1 shares the instruction of the AND of word i, so 2 instructions per word. This is the bound of the single-ALU pipeline; a third instruction per word cannot be removed without SIMD.Both live in
sdk/dsp/contract/dk_dispatch.inc(macros), used bydispatch-dt2.sanddispatch-dn2.s. The unpack hook does not use the bitmap: the frame consumer runs before the voices, so the bitmap would be a block old when a track's type changes (finding 188).Why it is exact
A set bit runs the unchanged full path (it reads the type again); a clear bit means the type has no row and, on DT2, is below 7, which the full path sent to the stock renderer after the stage 1 breadcrumb. The bitmap is rebuilt each block while a row exists. The guard computes the same maximum magnitude. The type words are written only by the frame consumer's copy loops, all of which run before the voice loop is called on both devices (addresses in finding 188), so slot 0's build sees what every later slot sees; a type change between blocks is seen by the next block's build (rig tests).
Rig counts (instructions per 32-voice DT2 / 16-slot DN2 block, steady; one script, main c84d9cc vs this branch,
digikit/pluck, Python MachineRig)fadedlimes/analog conformance, worst block over its cases (steady / note-on), main vs branch: DT2 5,562 / 5,613 vs 5,648 / 5,699 (budget 12,140); DN2 5,728 / 5,797 vs 5,798 / 5,867 (steady budget 5,799, headroom 1). Delta +86 (DT2) and +70 (DN2): the slot 0 build.
Tests
dsp-active.rig.test.ts(new, both devices): the bitmap marks exactly the slots with a row (none, one, several, a row freed between blocks); a clear slot is the stock renderer plus the stage 1 breadcrumb; no breadcrumb without a row.dsp-guard.rig.test.tsanddsp-guard-dn2.rig.test.ts: the cases ofguard-cases.ts(none, 8.0 and -8.0 exactly, one over at word 0/31, negative, Inf, NaN, several; stereo 64-word block on DT2) throughspot.s(DT2) andspot_contract.s(DN2 MachineRig). They pass on the old and the new loop.dsp-active.rig.test.tsalso changes a slot's type between blocks and checks the next block runs the new path, on both devices._dv_activeas every slot (the full path decides itself):sharc-rig-kit(MachineRig.setActive,VoiceRig),dsp-quality, and the two Python rigs.Review findings and fixes
FUN_1c2b24at 0x1c2c79 and 0x1c3069, before the voice-loop call at 0x1c3083; DN2FUN_1c2712at 0x1c287a and 0x1c302d, before the call at 0x1c3044). No fix and no cost: the bitmap is exact.dsp-guard-dn2.rig.test.ts), and a rig test changes a slot's type between blocks on both devices.Gate
mise run test:changed: unit and static tasks passed (29 tasks), rig preflight 67 halves, 0 problems.test-device--reload-fx--dn2:wb transfer install ... --restartwas killed with SIGTERM (a load timeout at load average 50 to 90, not an assertion). The same target rerun alone passed (nx 79 ok, 0 failed).sharc_cells, one fixture state per tree: A = merge-base 769f409, B = branch; the samecoupled-runbinary and core, 20/24 s, one emulator at a time): PCM equal at both lengths, DT2dt2-sample-trigand DN2trig1-hold.The DSP and ColdFire state hashes differ at both lengths on both devices, as they must: the two trees give different runtime images (the new
_dv_activeword, DN2's three removed_dv_q*words). Attribution of the DSP dumps (24 s; static analysis of the two dumps,tools/emulator/dspdiff.pyreader, no link map of the runtime builds was kept, so the layout delta was found from the dumps): each differing word of A was matched to the word at the same place shifted by the layout delta in B, equal or with a pointer or opcode immediate relocated by that delta (a multiple of 4 bytes).DN2's shift is -8 bytes (one word added, three removed, 8-byte alignment) for 1,278 words and 0 for the rest. The
_dv_activeword and the_dv_q*words are inside the matched clusters (no isolated word is left). The DT2 residue, 20 words, is run-phase state: the five counters at 0x2662d8, 0x266328, 0x282ca3ec, 0x4801b3d0 and 0x4809b858 differ by 2 or 3 ticks (B is ahead), the timestamp words at 0x2826f7a8 and 0x28269a10/1c differ by a few ticks, two ring pointers (0x261a48, 0x261ab8) point at neighbouring slots, 0x25f780 is a flag, and 9 SDRAM float words (0x80058770/74, 0x8045a490..4ac) are running state that also differs at 20 s by the same phase. Taken from the DSP at a different tick when the fixed emulated time ends, as B runs fewer instructions per block. This is an explanation from the 20 s and 24 s dumps, not a proof word by word, and the relocation test allows a field delta of 4 to 24 bytes (so a coincidence is possible). PCM equality is the exactness check. The ColdFire state digest is a single hash: its differing words were not attributed.Hardware check
This ships to the device. Listen to stock tracks and a module voice on DT2 and DN2, trigger a note on the first beat of a block-aligned step, and check fault reporting (a guard fault of a module must still zero the block and report).
🤖 Generated with Claude Code
Merge-gate failures and fixes (DN2)
test_sine.py::...unregistered_type_goes_back_to_the_stock_code_without_the_table_walk[dn2]: 147 instructions, bound 70. Cause:tests/support/machine_rig.pyset_dv_activeto all ones for every block (a full-path shortcut), so the slot of an unregistered type took the full path and the table walk. Fix: the rig sets the bitmap slot 0 leaves, from the slot types and the mask (_active_bitmap). The test and its bound are unchanged. DT2 did not fail: its clear slot returns after the breadcrumb either way, and the DT2 case sets the type below 7.fadedlimes/analog:test-dsp-conformanceon DN2: 5,814 instructions, budget 5,799. Cause: slot 0 of the measured block pays the bitmap build (6 instructions a slot, 16 slots). Fix: with one bit per slot the mask is shifted down by the type and the low bit deposited (DV_ACTIVE_ONE_BIT, 5 instructions a slot): 16 fewer, 5,798. DT2 keeps the 2-bit form and has headroom in its budget.digikit/shot:test-host-integration(peer-voice-host, 5,000 ms): load; the rerun passed (22 s).Rerun: the two failing tests,
core/dsp-voice:test-dsp(dsp-active, dsp-guard, dsp-guard-dn2; 443 tests),fadedlimes/analog:test-dsp-conformance(both devices),mise run test:changed(29 tasks, preflight 0 problems). The two counts that move (1 voice, 4 voices on DN2) are the old counts minus 16.Rig honesty (review round)
The Python
MachineRigno longer sets_dv_activefrom a Python copy of the build. A block of a slot above 0 first runs the real slot 0 call (the assembly builds_dv_maskand_dv_activefrom the table and the frame's types, as in a real block); only the measured call is counted and read._active_bitmapand its device-name branch are gone (device-literals baseline back to 48).dsp-active.rig.test.tscovers the one-bit macro on DN2 and the 2-bit form on DT2 with types 0, 6, 7, 30, 31 and 40, and rows of 8, 30 and 31 (a row of 31 or more names every type from 31 up). The TSMachineRig.setActivedefault (all slots) is unchanged.Checks:
test_sine.py2 passed;core/dsp-voice:test-dspok;fadedlimes/analog:test-dsp-conformanceok on both devices;mise run test:changed29 tasks ok, preflight 0 problems.