diff --git a/changelog/2026-11-24-cycle-scan-like-cases.md b/changelog/2026-11-24-cycle-scan-like-cases.md new file mode 100644 index 000000000..68b2d8159 --- /dev/null +++ b/changelog/2026-11-24-cycle-scan-like-cases.md @@ -0,0 +1 @@ +Development: `node scripts/cycle-scan.mjs unit` compares a unit reading with the scan's model only when both are the same case (package, setting, transport, what the key bus carried for a key-bus effect, and the base a base charge was timed on), and prints "not comparable" with the reason otherwise; it compares a reading's DSP peak, where it kept one, with the dearest setting. The table in `sdk/cycle-scan/README.md` is now written by `unit --write`, and `cycle-scan check` fails when it differs (it still charged the key bus 51 after the charge became 43). diff --git a/scripts/cycle-scan.mjs b/scripts/cycle-scan.mjs index 8666900e0..55b3704d8 100644 --- a/scripts/cycle-scan.mjs +++ b/scripts/cycle-scan.mjs @@ -4,7 +4,8 @@ // // node scripts/cycle-scan.mjs record [ ...] # on your computer: scan each Octatrack module, write its record // node scripts/cycle-scan.mjs check # anywhere, CI included: judge every committed record -// node scripts/cycle-scan.mjs unit [--markdown] # anywhere: the records against the unit's in-use readings (report only) +// node scripts/cycle-scan.mjs unit [--markdown|--write] # anywhere: the records against the unit's in-use readings (report only; +// # --write puts the table into sdk/cycle-scan/README.md, which check holds to it) // // `record` runs sdk/cycle-scan/interlock_scan.py --sweep on the module and on the stock effect its performance.json compares // it with, and writes sdk/cycle-scan/records/.json: the dearest setting's instructions, cycles and stalls a sample, @@ -62,52 +63,125 @@ export function atSetting(report, setting) { return { setting, instructions: round(run.instr), cycles: round(run.cycles), stalls: round(run.stall) } } -/** The meter points an in-use reading added on the core of the slot it was taken on (T1-T4 core 1, T5-T8 core 0). */ +/** The meter points an in-use reading added on the core of the slot it was taken on (T1-T4 core 1, T5-T8 core 0): the mean, + * and the peak, the core's busiest block, which device:price keeps from 24 November 2026 (null in an older record). */ export function inUsePoints(result) { const track = Number(/^T(\d)/.exec(result?.inUseOn ?? '')?.[1]) if (!result?.inUseAdds || !track) return null - return { on: result.inUseOn, points: track <= 4 ? result.inUseAdds.dsp1to4 : result.inUseAdds.dsp5to8 } + const core = track <= 4 ? 'dsp1to4' : 'dsp5to8', peak = result.inUseAdds[core + 'Peak'] + return { on: result.inUseOn, points: result.inUseAdds[core], peak: typeof peak === 'number' ? peak : null } } -/** One module's line of the unit report: its cpu-price.json in-use reading against the record's model at the same - * setting (the defaults, where a fresh pick starts), plus what the base charges for features its package requires, - * which run outside the effect's proc and so outside the scan. `price` is evidence/cpu-price.json or null; `extra` - * [{name, cycles}]. */ -export function unitLine({ id, record, price, extra = [] }) { +/** The base identities a text names: each hex run of eight or more digits, cut to eight ("development twin d3d71297 of base + * 0.7.8 (main 02dfa20ca)" names d3d71297 and 02dfa20c). */ +export const identities = text => (String(text ?? '').match(/\b[0-9a-f]{8,}\b/g) ?? []).map(id => id.slice(0, 8)) + +/** The case a cycle-scan record models: the version and the published package it covers (the package row of that version), + * the setting, and what plays. dsp_host runs the proc block after block, as a playing unit does, and feeds no key bus, so a + * key-bus effect is scanned with its key bus silent. `keyBus` says whether the module reads the key bus at all. */ +export function scanCase({ record, row, keyBus = false }) { + return { version: record.version, package: row?.version === record.version ? row.sha256 ?? null : null, setting: record.defaults?.setting ?? null, + transport: 'playing', keyBus: keyBus ? record.inputs?.keyBus ?? 'silent' : null } +} + +/** The case a device:price reading measured (evidence/cpu-price.json): the version and package, the setting (a fresh pick + * starts at the defaults), what played (`inputs`, recorded from 24 November 2026: the transport always, the key bus when the + * caller named it; device:price always reads playing) and the base it ran on. */ +export function unitCase({ price, record, keyBus = false }) { + return { version: price.version, package: price.result?.packageSha256 ?? null, setting: price.result?.setting ?? record.defaults?.setting ?? null, + transport: price.inputs?.transport ?? 'playing', keyBus: keyBus ? price.inputs?.keyBus ?? 'not stated' : null, base: price.base ?? null } +} + +/** Why a reading and a model are not the same case: [] when they are. `extra` is the base charges added to the model, each + * with the base identities it was timed on (`bases`): a reading on another base ran another build of that base code. */ +export function notComparable(scan, unit, extra = []) { + const why = [] + if (scan.package && unit.package && scan.package !== unit.package) + why.push(`the unit measured package ${unit.package.slice(0, 8)}, not the published ${scan.version} (${scan.package.slice(0, 8)})`) + if (scan.setting !== unit.setting) why.push(`the unit read it at ${unit.setting}, the model is at ${scan.setting}`) + if (scan.transport !== unit.transport) why.push(`the unit read with the sequencer ${unit.transport}, the scan runs every block`) + if (scan.keyBus !== unit.keyBus) why.push(unit.keyBus === 'not stated' + ? `the reading does not say what its key bus carried, the scan's was ${scan.keyBus}` + : `its key bus was ${unit.keyBus} on the unit and ${scan.keyBus} in the scan`) + const seen = identities(unit.base) + for (const charge of extra) if (charge.bases?.length && !charge.bases.some(id => seen.includes(id))) + why.push(`the unit read on ${seen[0] ?? (unit.base || 'an unnamed base')}, the ${charge.name} charge (${charge.cycles}) was timed on ${charge.bases[0]}`) + return why +} + +/** One module's line of the unit report: its cpu-price.json in-use reading against the record's model, only where both are + * the same case (notComparable); else the line says why not and gives no ratio. The mean is compared with the model at the + * defaults (where a fresh pick starts), the peak, where the reading kept one, with the dearest setting, which bounds every + * setting. Both add what the base charges for features the package requires, which run outside the effect's proc and so + * outside the scan. `price` is evidence/cpu-price.json or null; `extra` [{name, cycles, bases?}]; `row` the USB package row. */ +export function unitLine({ id, record, price, extra = [], row, keyBus = false }) { const line = { id, version: record.version, modelDefaults: record.defaults?.cycles ?? null, modelDearest: record.dearest.cycles, - setting: record.defaults?.setting ?? null, outside: extra, notes: [] } + setting: record.defaults?.setting ?? null, outside: extra.map(({ name, cycles }) => ({ name, cycles })), notes: [] } const reading = inUsePoints(price?.result) if (!reading) { line.notes.push('no in-use reading on the unit'); return line } if (price.version !== record.version) { line.notes.push(`the unit reading is for ${price.version}, the record for ${record.version}`); return line } Object.assign(line, { on: reading.on, points: reading.points, unit: round(reading.points * POINT), base: price.base, measuredAt: price.measuredAt }) + if (reading.peak != null) Object.assign(line, { peak: reading.peak, unitPeak: round(reading.peak * POINT) }) if (line.modelDefaults == null) { line.notes.push('the record keeps no defaults run: record it again'); return line } - line.model = round(line.modelDefaults + extra.reduce((sum, e) => sum + e.cycles, 0)) + const charges = extra.reduce((sum, e) => sum + e.cycles, 0) + line.model = round(line.modelDefaults + charges) + const why = notComparable(scanCase({ record, row, keyBus }), unitCase({ price, record, keyBus }), extra) + if (why.length) { line.notComparable = why; return line } line.ratio = round(line.unit / line.model) if (Math.abs(line.unit / line.model - 1) > OUTLIER) line.outlier = true + if (line.unitPeak != null) { + line.modelPeak = round(line.modelDearest + charges) + line.peakRatio = round(line.unitPeak / line.modelPeak) + if (line.unitPeak > line.modelPeak * (1 + OUTLIER)) line.peakAbove = true + } return line } /** Every record against the unit's in-use readings, and the scanned modules that lack one. */ export function unitReport(base = root) { const dir = join(base, RECORDS), packages = readJson(join(base, 'src/engine/assets/octatrack-module-packages.json')).packages - const features = readJson(join(base, 'sdk/machines/octatrack/dsp-sites.json')).features + const sites = readJson(join(base, 'sdk/machines/octatrack/dsp-sites.json')), features = sites.features + const keyBusBits = features.filter(f => f.name === 'keybus').map(f => f.bit) + // A base charge's evidence names the base it was timed on (keybus-tap-timing-*.json's `base`). + const timedOn = f => { const path = f.evidence && join(base, 'sdk/machines/octatrack', f.evidence); return path && existsSync(path) ? identities(JSON.stringify(readJson(path).base)) : [] } const lines = readdirSync(dir).filter(name => name.endsWith('.json')).sort().map(name => { const record = readJson(join(dir, name)), id = record.module, pricePath = join(base, MODULES, id, 'evidence/cpu-price.json') - const requires = packages.find(row => row.id === id)?.requires ?? 0 - const extra = features.filter(f => requires & f.bit && typeof f.hardware === 'number').map(f => ({ name: f.name, cycles: f.hardware })) - return unitLine({ id, record, price: existsSync(pricePath) ? readJson(pricePath) : null, extra }) + const row = packages.find(item => item.id === id), requires = row?.requires ?? 0 + const extra = features.filter(f => requires & f.bit && typeof f.hardware === 'number').map(f => ({ name: f.name, cycles: f.hardware, bases: timedOn(f) })) + // A key-bus reader: its package requires the key bus, or the module owns a key-bus site (Sidechain Compressor's tap). + const keyBus = keyBusBits.some(bit => requires & bit) || sites.sites.some(site => site.module === id && keyBusBits.includes(site.feature)) + return unitLine({ id, record, price: existsSync(pricePath) ? readJson(pricePath) : null, extra, row, keyBus }) }) return { lines, missing: lines.filter(line => line.unit == null).map(line => line.id) } } /** The unit report as the Markdown table in sdk/cycle-scan/README.md. */ export function unitMarkdown({ lines }) { - const f = n => n == null ? '–' : String(Math.round(n)) + const f = n => n == null ? '–' : String(Math.round(n)), base = l => l.outside.length ? ' + ' + l.outside.map(e => `${e.cycles} ${e.name}`).join(' + ') : '' + const verdict = l => l.notComparable ? 'not comparable: ' + l.notComparable.join('; ') + : l.ratio == null ? l.notes.join('; ') : (l.outlier ? '**outlier**' : 'within ' + OUTLIER * 100 + ' %') + (l.peakAbove ? '; **peak above the dearest model**' : '') const rows = lines.map(l => `| ${l.id} ${l.version.replace(/-experimental$/, '')} | ${l.points == null ? '–' : `${l.points} = ${f(l.unit)} (${l.on})`} | ` + - `${l.setting ?? '–'} | ${f(l.modelDefaults)}${l.outside.length ? ' + ' + l.outside.map(e => `${e.cycles} ${e.name}`).join(' + ') : ''} | ${f(l.modelDearest)} | ` + - `${l.ratio == null ? '–' : l.ratio.toFixed(2)} | ${l.outlier ? '**outlier**' : l.notes.join('; ') || 'within ' + OUTLIER * 100 + ' %'} |`) - return ['| Module | Unit, in use (points = cycles a sample) | Defaults run | Model at defaults (+ base features) | Model, dearest | Unit ÷ model | Verdict |', - '|---|---|---|---|---|---|---|', ...rows].join('\n') + `${l.peak == null ? '–' : `${l.peak} = ${f(l.unitPeak)}`} | ${l.setting ?? '–'} | ${f(l.modelDefaults)}${base(l)} | ${f(l.modelDearest)}${base(l)} | ` + + `${l.ratio == null ? '–' : l.ratio.toFixed(2)} | ${l.peakRatio == null ? '–' : l.peakRatio.toFixed(2)} | ${verdict(l)} |`) + return ['| Module | Unit, in use (points = cycles a sample) | Unit, peak | Defaults run | Model at defaults (+ base features) | Model, dearest (+ base features) | Unit ÷ model | Peak ÷ dearest | Verdict |', + '|---|---|---|---|---|---|---|---|---|', ...rows].join('\n') +} + +export const README = 'sdk/cycle-scan/README.md' +const TABLE_START = '', TABLE_END = '' +/** The README's text with the table between its markers replaced. */ +export function withTable(text, table) { + const start = text.indexOf(TABLE_START), end = text.indexOf(TABLE_END) + if (start < 0 || end < start) throw new Error(`${README} has lost the generated table's markers`) + return text.slice(0, start + TABLE_START.length) + '\n' + table + '\n' + text.slice(end) +} +/** A failure when the README's committed table is not what the records and readings generate now, else null. */ +export function tableDrift(base = root) { + const path = join(base, README) + if (!existsSync(path)) return null + const text = readFileSync(path, 'utf8') + return withTable(text, unitMarkdown(unitReport(base))) === text ? null + : `${README}: the table under "Checked against the unit" is not what the records and the unit readings give now: run node scripts/cycle-scan.mjs unit --write` } /** One record's verdict: {fail: [...], info: [...]}. `sourceSha256` is the module's source now; `performance` its @@ -175,6 +249,9 @@ export async function check(base = root) { } const unscanned = readdirSync(join(base, MODULES)).filter(id => !ids.includes(id) && performanceOf(join(base, MODULES, id))?.kind === 'dsp') if (unscanned.length) info.push(`no cycle scan yet: ${unscanned.sort().join(', ')}`) + // The README's unit table is generated: it fell behind the key-bus charge once (51 there, 43 in dsp-sites.json). + const drift = ids.length ? tableDrift(base) : null + if (drift) fail.push(drift) return { fail, info, records: ids.length } } @@ -220,15 +297,21 @@ if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.ur const { fail, info, records } = await check() for (const line of info) console.log(' · ' + line) for (const line of fail) console.error(' ✗ ' + line) - console.log(fail.length ? `Cycle scan: ${fail.length} of ${records} records fail.` : `Cycle scan: ${records} records current, none under-reported.`) + console.log(fail.length ? `Cycle scan: ${fail.length} failure${fail.length === 1 ? '' : 's'} over ${records} records.` : `Cycle scan: ${records} records current, none under-reported.`) if (fail.length) process.exitCode = 1 } else if (command === 'unit') { const report = unitReport() if (ids.includes('--markdown')) console.log(unitMarkdown(report)) - else for (const l of report.lines) console.log(` ${l.outlier ? '!' : '·'} ${l.id}: ` + (l.unit == null ? l.notes.join('; ') : - `unit ${l.unit} cycles a sample (${l.points} points on ${l.on}), model ${l.model} at ${l.setting}` + - (l.outside.length ? ` with ${l.outside.map(e => e.name + ' ' + e.cycles).join(', ')}` : '') + `, ${l.ratio}x` + (l.outlier ? ': an outlier' : ''))) - if (report.missing.length && !ids.includes('--markdown')) console.log(`No in-use reading to compare: ${report.missing.join(', ')}. A report only; nothing fails.`) - } else { console.error('Usage: node scripts/cycle-scan.mjs record [ ...] | check | unit [--markdown]'); process.exitCode = 2 } + else if (ids.includes('--write')) { + const path = join(root, README), text = readFileSync(path, 'utf8'), next = withTable(text, unitMarkdown(report)) + if (next !== text) writeFileSync(path, next) + console.log(next === text ? `${README}: the table is current.` : `${README}: wrote the table.`) + } else for (const l of report.lines) console.log(` ${l.notComparable ? '×' : l.outlier || l.peakAbove ? '!' : '·'} ${l.id}: ` + (l.unit == null ? l.notes.join('; ') : + `unit ${l.unit} cycles a sample (${l.points} points on ${l.on}${l.peak == null ? '' : `, peak ${l.peak}`}), model ${l.model} at ${l.setting}` + + (l.outside.length ? ` with ${l.outside.map(e => e.name + ' ' + e.cycles).join(', ')}` : '') + + (l.notComparable ? `: not comparable: ${l.notComparable.join('; ')}` : `, ${l.ratio}x` + (l.outlier ? ': an outlier' : '') + + (l.peakRatio == null ? '' : `; peak ${l.unitPeak} against ${l.modelPeak} at the dearest, ${l.peakRatio}x` + (l.peakAbove ? ': above the model' : ''))))) + if (report.missing.length && !ids.includes('--markdown') && !ids.includes('--write')) console.log(`No in-use reading to compare: ${report.missing.join(', ')}. A report only; nothing fails.`) + } else { console.error('Usage: node scripts/cycle-scan.mjs record [ ...] | check | unit [--markdown | --write]'); process.exitCode = 2 } } catch (error) { console.error(error.message); process.exitCode = 1 } } diff --git a/scripts/cycle-scan.test.mjs b/scripts/cycle-scan.test.mjs index ab1400332..f7770489b 100644 --- a/scripts/cycle-scan.test.mjs +++ b/scripts/cycle-scan.test.mjs @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest' -import { CHARGE_COVERS_MODEL_FROM, POINT, UNDER_REPORT, atSetting, charged, check, dearest, inUsePoints, judge, judgeCharge, unitLine, unitMarkdown, unitReport } from './cycle-scan.mjs' +import { CHARGE_COVERS_MODEL_FROM, POINT, UNDER_REPORT, atSetting, charged, check, dearest, identities, inUsePoints, judge, judgeCharge, notComparable, scanCase, + tableDrift, unitCase, unitLine, unitMarkdown, unitReport, withTable } from './cycle-scan.mjs' const record = (more = {}) => ({ schema: 1, module: 'fx', version: '0.1.0', sourceSha256: 'a'.repeat(64), dearest: { setting: 'MODE=B/max', settings: 4, instructions: 400, cycles: 650, stalls: 90, stallsByKind: { arith: 60 } }, @@ -67,10 +68,19 @@ describe('the unit report', () => { const withDefaults = record({ defaults: { setting: 'MODE=A/def', instructions: 380, cycles: 600, stalls: 80 } }) it('reads the meter of the core the slot is on, at 45.32 cycles a point', () => { expect(POINT).toBe(45.32) - expect(inUsePoints({ inUseOn: 'T1 FX2', inUseAdds: { dsp1to4: 7.5, dsp5to8: 0.9 } })).toEqual({ on: 'T1 FX2', points: 7.5 }) - expect(inUsePoints({ inUseOn: 'T5 FX1', inUseAdds: { dsp1to4: 6.3, dsp5to8: 5.5 } })).toEqual({ on: 'T5 FX1', points: 5.5 }) + expect(inUsePoints({ inUseOn: 'T1 FX2', inUseAdds: { dsp1to4: 7.5, dsp5to8: 0.9 } })).toEqual({ on: 'T1 FX2', points: 7.5, peak: null }) + expect(inUsePoints({ inUseOn: 'T5 FX1', inUseAdds: { dsp1to4: 6.3, dsp5to8: 5.5, dsp1to4Peak: 9, dsp5to8Peak: 8.1 } })).toEqual({ on: 'T5 FX1', points: 5.5, peak: 8.1 }) expect(inUsePoints({ atRestAdds: {} })).toBeNull() }) + it('compares the peak with the dearest run, which bounds every setting, and flags one above it', () => { + const peaked = peak => price({ result: { inUseOn: 'T1 FX2', inUseAdds: { dsp1to4: 14.3, dsp5to8: 0.6, dsp1to4Peak: peak, dsp5to8Peak: 1 } } }) + expect(unitLine({ id: 'fx', record: withDefaults, price: peaked(15) })).toMatchObject({ peak: 15, unitPeak: 679.8, modelPeak: 650, peakRatio: 1.05 }) + const above = unitLine({ id: 'fx', record: withDefaults, price: peaked(16), extra: [{ name: 'keybus', cycles: 43 }] }) + expect(above).toMatchObject({ unitPeak: 725.12, modelPeak: 693, peakRatio: 1.05 }) + expect(above.peakAbove).toBeUndefined() + expect(unitLine({ id: 'fx', record: withDefaults, price: peaked(16) }).peakAbove).toBe(true) + expect(unitMarkdown({ lines: [unitLine({ id: 'fx', record: withDefaults, price: peaked(16) })] })).toContain('| 16 = 725 | MODE=A/def | 600 | 650 | 1.08 | 1.12 | within 10 %; **peak above the dearest model** |') + }) it('compares the reading with the model at the defaults and lists an outlier', () => { const near = unitLine({ id: 'fx', record: withDefaults, price: price() }) expect(near).toMatchObject({ unit: 648.08, model: 600, ratio: 1.08, setting: 'MODE=A/def' }) @@ -94,6 +104,59 @@ describe('the unit report', () => { }) }) +describe('only like cases are compared', () => { + const price = (more = {}) => ({ version: '0.1.0', base: 'development twin d3d71297 of base 0.7.8 (main 02dfa20ca)', measuredAt: '2026-11-18', + result: { inUseOn: 'T1 FX2', inUseAdds: { dsp1to4: 7.5, dsp5to8: 0.9 } }, ...more }) + const ring = record({ defaults: { setting: 'DUCK/def', instructions: 2.5, cycles: 5, stalls: 0 } }) + const tap = [{ name: 'keybus', cycles: 43, bases: ['856cbbcf', '9ac83b23', '1c937ed6'] }] + it('reads the base identities a base names, eight hex digits each', () => { + expect(identities('development twin d3d71297 of base 0.7.8 (main 02dfa20ca)')).toEqual(['d3d71297', '02dfa20c']) + expect(identities('8850f5399c453b9c (development twin, ef6099b0a)')).toEqual(['8850f539', 'ef6099b0']) + expect(identities(undefined)).toEqual([]) + }) + it('keeps a key-bus effect read with an unstated or live key bus, on another base than its charge, out of the ratio', () => { + const line = unitLine({ id: 'ring-sc', record: ring, price: price(), extra: tap, keyBus: true }) + expect(line.ratio).toBeUndefined() + expect(line.outlier).toBeUndefined() + expect(line.notComparable).toEqual([ + 'the reading does not say what its key bus carried, the scan\'s was silent', + 'the unit read on d3d71297, the keybus charge (43) was timed on 856cbbcf', + ]) + expect(unitMarkdown({ lines: [line] })).toMatch(/\| – \| – \| not comparable: the reading does not say what its key bus carried/) + const live = unitLine({ id: 'ring-sc', record: ring, price: price({ base: 'twin 856cbbcf', inputs: { transport: 'playing', keyBus: 'live' } }), extra: tap, keyBus: true }) + expect(live.notComparable).toEqual(['its key bus was live on the unit and silent in the scan']) + }) + it('pairs a key-bus effect read with a silent key bus on the base its charge was timed on', () => { + const silent = price({ base: 'development twin 1c937ed6', inputs: { transport: 'playing', keyBus: 'silent' } }) + expect(unitLine({ id: 'ring-sc', record: ring, price: silent, extra: tap, keyBus: true })).toMatchObject({ model: 48, ratio: 7.08, outlier: true }) + }) + it('refuses a reading of another package, another setting or a stopped sequencer', () => { + const row = { id: 'fx', version: '0.1.0', sha256: 'c'.repeat(64) }, scan = scanCase({ record: ring, row }) + expect(scan).toEqual({ version: '0.1.0', package: 'c'.repeat(64), setting: 'DUCK/def', transport: 'playing', keyBus: null }) + const unit = more => unitCase({ price: price(more), record: ring }) + expect(notComparable(scan, unit())).toEqual([]) // an older reading names no package: its version stands for it + expect(notComparable(scan, unit({ result: { packageSha256: 'c'.repeat(64) } }))).toEqual([]) + expect(notComparable(scan, unit({ result: { packageSha256: '9f22861f'.padEnd(64, '0') } }))).toEqual(['the unit measured package 9f22861f, not the published 0.1.0 (cccccccc)']) + expect(notComparable(scan, unit({ result: { setting: 'DUCK/max' } }))).toEqual(['the unit read it at DUCK/max, the model is at DUCK/def']) + expect(notComparable(scan, unit({ inputs: { transport: 'stopped' } }))).toEqual(['the unit read with the sequencer stopped, the scan runs every block']) + expect(scanCase({ record: ring, row: { ...row, version: '0.1.1' } }).package).toBeNull() // the row is another version's package + }) +}) + +describe('the README\'s unit table', () => { + // Generated from sdk/cycle-scan/records/, each module's evidence/cpu-price.json, sdk/machines/octatrack/dsp-sites.json and + // src/engine/assets/octatrack-module-packages.json; a change to any of them that moves a row must regenerate it. + it('is what node scripts/cycle-scan.mjs unit --markdown generates now', () => { + expect(tableDrift()).toBeNull() + }) + it('replaces only what lies between its markers, and fails without them', () => { + const start = '' + const text = `# x\n${start}\n| old |\n\nafter\n` + expect(withTable(text, '| new |')).toBe(`# x\n${start}\n| new |\n\nafter\n`) + expect(() => withTable('# no table', '| new |')).toThrow(/sdk\/cycle-scan\/README.md has lost the generated table's markers/) + }) +}) + describe('the committed records', () => { it('finds every committed record current and none under-reported', async () => { const result = await check() diff --git a/sdk/cycle-scan/README.md b/sdk/cycle-scan/README.md index 0fa2f79b1..6b3d06c5f 100644 --- a/sdk/cycle-scan/README.md +++ b/sdk/cycle-scan/README.md @@ -84,45 +84,56 @@ It is a model, not a measurement: the unit stays the judge ([MODULE_PERFORMANCE. ```bash node scripts/cycle-scan.mjs unit # anywhere: each record against its module's in-use reading; a report, it fails nothing node scripts/cycle-scan.mjs unit --markdown # the table below +node scripts/cycle-scan.mjs unit --write # writes it here; `check` fails when the committed table differs ``` Each module's `evidence/cpu-price.json` holds a reading `npm run device:price` took on an MKII: the DSP load meter of the slot's core with the effect picked on that slot in place of NONE, against the same scene without it (`inUseAdds`; T1-T4 -are core 1's meter, T5-T8 core 0's). A fresh pick starts from the effect's defaults, so the report compares it with the -scan's run at the defaults. **Scale:** one point of the meter is 45.32 cycles a sample. `status.c`'s `busy()` gives per -mille of `FRAME_CYCLES`, 72,520 (4,532 cycles a sample, the board's clock, as `CYCLE_SCAN.md`'s "% of a frame" uses, times -16 samples a frame), from idle passes whose cycles were calibrated on the unit with `--dsp-burn` (11 October 2026, -`idle_cycles` there). A module whose package requires a base DSP feature with a hardware charge in -`sdk/machines/octatrack/dsp-sites.json` (the key bus: 51) has it added to the model, since that work runs outside the -effect's proc and so outside the scan. +are core 1's meter, T5-T8 core 0's). A fresh pick starts from the effect's defaults, so the report compares the reading's +mean with the scan's run at the defaults, and its peak (the core's busiest block, which `device:price` keeps from +24 November 2026) with the dearest run, which bounds every setting. **Scale:** one point of the meter is 45.32 cycles a +sample. `status.c`'s `busy()` gives per mille of `FRAME_CYCLES`, 72,520 (4,532 cycles a sample, the board's clock, as +`CYCLE_SCAN.md`'s "% of a frame" uses, times 16 samples a frame), from idle passes whose cycles were calibrated on the +unit with `--dsp-burn` (11 October 2026, `idle_cycles` there). A module whose package requires a base DSP feature with a +`hardware` charge in `sdk/machines/octatrack/dsp-sites.json` (the key bus) has it added to the model, since that work runs +outside the effect's proc and so outside the scan. + +**Only like cases are compared.** A reading and a model are paired when they cover the same package of the record's +version, the same setting, the transport playing, the same key-bus input for a module that reads the key bus (the scan's +`dsp_host` feeds it silence; a reading names its own in `inputs.keyBus`, `live` or `silent`), and, where a base charge is added, +a reading taken on a base that charge was timed on (the identities its evidence names). Any other pair prints "not +comparable" with the reason and no ratio: re-measure on that case rather than read the gap as a model error. The readings, 18 November 2026, on development twins of base 0.7.8 (Sidechain Compressor's on another twin, `8850f539`), one 8-second reading each; modules with no DSP code moved the same meters by -0.6 to +0.6 points (±27 cycles) in the same runs, once 2.9. Records scanned 23 November 2026: -| Module | Unit, in use (points = cycles a sample) | Defaults run | Model at defaults (+ base features) | Model, dearest | Unit ÷ model | Verdict | -|---|---|---|---|---|---|---| -| airwindows-chorus 0.1.3 | – | defaults/def | 602 | 649 | – | no in-use reading on the unit | -| bbd 0.1.2 | 10.8 = 489 (T1 FX2) | STGS=1024/def | 469 | 528 | 1.04 | within 10 % | -| euclid 0.1.5 | 5.5 = 249 (T1 FX2) | RATE=1/16/def | 232 | 232 | 1.07 | within 10 % | -| everb 0.1.2 | 13.3 = 603 (T1 FX2) | REV=OFF/def | 603 | 665 | 1.00 | within 10 % | -| lofi2 0.1.1 | 10.3 = 467 (T1 FX2) | RING/def | 425 | 654 | 1.10 | within 10 % | -| miniverb 0.2.3 | 14.1 = 639 (T1 FX2) | RATE=1.01/def | 641 | 699 | 1.00 | within 10 % | -| ring-sc 0.2.1 | 7.5 = 340 (T1 FX2) | DUCK/def | 5 + 51 keybus | 122 | 6.04 | **outlier** | -| sidechain-compressor 0.2.2 | 5.5 = 249 (T5 FX1) | MON=OFF/def | 107 | 107 | 2.34 | **outlier** | -| tapehead 0.1.2 | 9.3 = 421 (T1 FX2) | COLOR=NORM/def | 425 | 426 | 0.99 | within 10 % | -| vibrato 0.1.0 | – | SHP=SINE/def | 204 | 207 | – | no in-use reading on the unit | + +| Module | Unit, in use (points = cycles a sample) | Unit, peak | Defaults run | Model at defaults (+ base features) | Model, dearest (+ base features) | Unit ÷ model | Peak ÷ dearest | Verdict | +|---|---|---|---|---|---|---|---|---| +| airwindows-chorus 0.1.3 | – | – | defaults/def | 602 | 649 | – | – | no in-use reading on the unit | +| bbd 0.1.2 | 10.8 = 489 (T1 FX2) | – | STGS=1024/def | 469 | 528 | 1.04 | – | within 10 % | +| euclid 0.1.5 | 5.5 = 249 (T1 FX2) | – | RATE=1/16/def | 232 | 232 | 1.07 | – | within 10 % | +| everb 0.1.2 | 13.3 = 603 (T1 FX2) | – | REV=OFF/def | 603 | 665 | 1.00 | – | within 10 % | +| lofi2 0.1.1 | 10.3 = 467 (T1 FX2) | – | RING/def | 425 | 654 | 1.10 | – | within 10 % | +| miniverb 0.2.3 | 14.1 = 639 (T1 FX2) | – | RATE=1.01/def | 641 | 699 | 1.00 | – | within 10 % | +| ring-sc 0.2.1 | 7.5 = 340 (T1 FX2) | – | DUCK/def | 5 + 43 keybus | 122 + 43 keybus | – | – | not comparable: the reading does not say what its key bus carried, the scan's was silent; the unit read on d3d71297, the keybus charge (43) was timed on 856cbbcf | +| sidechain-compressor 0.2.2 | 5.5 = 249 (T5 FX1) | – | MON=OFF/def | 107 | 107 | – | – | not comparable: the unit measured package 9f22861f, not the published 0.2.2-experimental (cbd0fa73); the reading does not say what its key bus carried, the scan's was silent | +| tapehead 0.1.2 | 9.3 = 421 (T1 FX2) | – | COLOR=NORM/def | 425 | 426 | 0.99 | – | within 10 % | +| vibrato 0.1.0 | – | – | SHP=SINE/def | 204 | 207 | – | – | no in-use reading on the unit | + - **Effects whose work is all in their proc:** the model at the defaults is 1 % above to 10 % below the unit (mean 3 % below), for six modules. LOFI2 (9.95 %) is the widest, and EUCLID's 7 % is within the meter's noise at its size. Upstream found its model 3.0 % *above* its own meter (`CYCLE_SCAN.md` section 1): the two meters differ, and Modwerk's - reads 7 to 19 % above octabam's slot costs for the same DSP code (LOFI2, BBD, EUCLID). -- **Key-bus effects cost far more on the unit than the scan sees.** RINGMOD SC at its defaults runs 2.5 instructions a - sample in the scan (`dsp_host` feeds no key bus, so its key path may stay idle), yet the unit read 340 cycles on core 1, - where its key-bus tap is charged 51; core 0 read +0.9 points (41). Even its dearest run plus the tap (173) leaves half - of it unexplained. Sidechain Compressor read 249 on its own core against 107 modelled, and +6.3 points (285) on the - other core, where it has no instance: its detector and the key-bus tap are base-resident code on both cores - (`dsp-sites.json`'s `sidechain` and `keybus`), outside the proc. Whether the key path, the tap (timed on 23 October on - the older 41-instruction tap) or something else costs the rest needs a unit run. + reads 7 to 19 % above octabam's slot costs for the same DSP code (LOFI2, BBD, EUCLID). None of these readings kept a + peak, so nothing is compared with the dearest run yet. +- **The key-bus effects are not comparable yet.** RINGMOD SC at its defaults runs 2.5 instructions a sample in the scan, + whose key bus is silent, while the unit's kick on T1 fed it: the unit read 340 cycles on core 1 and +0.9 points (41) on + core 0. Its reading was also taken on 0.7.8's 41-instruction tap, before the one-pass tap the charge (43) was timed on. + Sidechain Compressor read 249 on its own core and +6.3 points (285) on the other, where it has no instance: its detector + and the key-bus tap are base-resident code on both cores (`dsp-sites.json`'s `sidechain` and `keybus`), outside the + proc, and the build it was read on is not the published package. To compare them: read both on the current base with + what the key bus carried recorded, and scan their key path with the key bus fed. - **No reading to compare:** VIBRATO and Air Chorus (`airwindows-chorus`) have no `cpu-price.json` in-use reading yet; Output Matrix has no scan record (its mix is base-resident code too).