Repository navigation
perf(nx): cache the patchkit CLI, module packs and device images - #988
Conversation
…ce-images patchkit:cli, every module pack and pack-aliases, patchkit:device-bytes and patchkit:device-images were cache: false, so every gate run in every worktree rebuilt them (0% hit over 7 days). They are cached on declared inputs now. - cli: adds COMPILE_SOURCE.patchkit, Cargo.toml, Cargo.lock, .cargo, the rust pin, rustc version, profile and flag variables (shared rustEnvInputs with the hermetic rust-tests); outputs are the binary and the patchkit test keys. - pack and pack-aliases: inputs were already complete; only the flag changes. - device-bytes: adds the module manifests. - device-images: adds devices, ports, ports/fw, the manifests, and the stock image bytes through firmware-hash.mjs --syx --overrides (new flag, images only). Checked: second run hits, restored outputs are byte-identical, a one-line input edit misses and the revert hits again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each missing input meant a stale cache hit and a false pass. - device-images hashes the module files the loader opens beyond module.toml (payload bodies, registry index_table, system package), derived from the manifests by loaderFiles; firmware-hash.mjs --module-files - pack and pack-aliases take ports/*.toml, ports/fw and the environment overrides (PATCHKIT_MODULES refuses reuse), through firmware-hash.mjs - patchkit:cli hashes CF_NATIVE_DIR and the kernels.rs it names - docs/TESTING.md: drop the stale "uncached" sentence, describe the inputs Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
[host] test:subset: --base origin/main |
Why
Seven-day numbers:
patchkit:cli1,226 min at 0% hits,patchkit:device-images744 min at 0%,patchkit:device-bytes660 runs at 0%. The modulepackandpack-aliasestargets rebuilt on every gate run too. All five arecache: truenow, on declared inputs.First vs cached time (this machine, warm toolchain)
Per-target times include dependencies; the first-run figures are lower bounds because dependencies were partly warm.
Input evidence (
nx show target <t> inputs)packages/patchkitplus the path-dependency crates (dkaddrmap, dkheader, dkprof, dksample, dksharc, dkupload, service-rules, emulator, runtime, services/),devices/,config/. Runtime: rustc -vV of the pinned toolchain, cargo profile env,firmware-hash.mjs --cf-native. Env: RUSTFLAGS group, CARGO_, CF_NATIVE_DIR.sdk/,ports/(all port files andports/fw),devices/, runtime services. Runtime: firmware hash with overrides, rust pin, node and pnpm versions. depOutputs:patchkit:clibinary and test keys..dko.jsonand the CLI.devices/,ports/, manifests, and stock image bytes throughfirmware-hash.mjs --syx --overrides --module-files.Hit, miss, revert hit
Second run hits for all five (
[local cache]). One edit each, then revert:packages/patchkit/src/abigen.rs: 0/1 hit, then 1/1 after revert.modules/machine/digikit/pluck/src/module.c: miss, revert 2/2.ports/fw/draw.toml: 1/3 (CLI hit, pack and aliases rebuilt), revert 3/3.module.toml: 33/35, revert 34/35 (the one non-cached dependency is outside this PR).ports/fw/draw.toml: 23/25, revert 24/25.Review gaps and closures
module.toml(payload bodies, registry index_table, system package) were missing from device-images: derived from the manifests (loaderFiles,--module-files).ports/and the env overrides: addedports/*.toml,ports/fwand the overrides throughfirmware-hash.mjs;PATCHKIT_MODULESrefuses reuse.CF_NATIVE_DIRor thekernels.rsit names: both added.Static proof
test-plans --ref origin/main --count 22, before (clean origin/main lane) and after (branch), none FAILED: 21 of 22 plans identical. One differs: d4d0724 (feat(devices): take the dn2 runtime buffers from the firmware heap #967, editsdevices/digitone-ii.toml) gains 9 tasks:test/dyn-dsp-hang:pack,test/stock-pool:pack,test/syspkg:pack,tom/tb303:pack,sdk:test-dspand fourworkbench-ts-check. Cause: the producers now declare the CLI outputs as dependency outputs, and the CLI's inputs includedevices/, so a device-profile edit is now seen to reach them. That is correct (the profile is compiled into the CLI) and was a missed selection before. No selection shrank.mise run test:ledgerbefore/after (both in one lane so artifacts match): 0 removed, 0 added, 0 moved.test:changed: 19 tasks pass, rig preflight 0 problems; py_select checks pass.🤖 Generated with Claude Code