Repository navigation
Closed
Labels
sanitizedTitle, body and conversation screened; review text requires separate screening.
Description
Sub-issue of #5375 (meta), part of #5356.
Problem
Every other sub-issue under this meta issue changes show() by about 5–10% of its instructions. Code layout alone moves wall time by 10–20 µs between builds, so a single change of that size can't be shown on wall time. #5362 merged on a layout-only "win" that disappeared on the next build of master.
The ESP32-C6's custom performance counter gives an instruction count per show() that layout doesn't change. #5364's 14,439 → 12,953 was measured this way. Today the counter only exists as a scratch patch that has never been committed.
The standard minstret/mcycle CSRs can't be used: reading them traps on the C6 and the board reboots.
Fix
Add an opt-in counter to AutoResearch's timingDriftTest:
- Read the Espressif RISC-V counter CSRs around each
FastLED.show():- PCER
0x7E0selects the event (bit 0 cycles, bit 1 instructions); - PCMR
0x7E1enables counting; - PCCR
0x7E2holds the count.
- PCER
- Return the mean cycles and mean instructions per
show()in the RPC result. - Compile it only on ESP32 RISC-V targets that have these CSRs (C3, C6, H2). The ESP32-P4 has a different core and counter set; it is out of scope here and reports no counter fields. Every other target returns no counter fields.
- Print the means from
ci/autoresearch/show_latency.pynext to the mean wall time. Optionally add abash autoresearch ... --show-ipcstyle flag so a PR can paste the numbers.
Acceptance
- On the C6, the AutoResearch run prints instructions per
show()and the number is stable within ±1% across two runs of the same build. - Rebuilding with an unrelated change that only moves code doesn't change the instruction count by more than ±1%.
- Other boards are unaffected; their runs still pass.
Rules for this sub-issue (from the meta issue)
- Keep the layered architecture. Fix this inside its layer. Don't bypass
ChannelManageror the channel engine. - Accept on instructions, not wall time. Measure instructions per
show()on the ESP32-C6 before and after. Usebash autoresearch esp32c6 --legacy --rmtwith the counter from the measurement sub-issue. Put both numbers in the PR. Code layout alone moves wall time by 10–20 µs between builds, so a wall-time number on its own can't show a 5–10% cut. - Usual gates:
bash test --cpp;bash lint;- a passing AutoResearch run with the
show()latency gate on; bash bloat esp32s3 --build, with no growth past the ratchet.
- Keep it small. Don't grow the binary on small-memory tiers (AVR, ATtiny). If a new bulk kernel doesn't pay for itself on
FL_PLATFORM_HAS_TINY_MEMORYbuilds, compile it out of them.
Metadata
Metadata
Assignees
Labels
sanitizedTitle, body and conversation screened; review text requires separate screening.
Type
Projects
- StatusShow more project fieldsDone
Activity
refactor(autoresearch): move the instruction counter into fl::Instruc…
fix(platforms): select the counter on FL_RMT4_DIAGNOSTICS' value, ind…
chore(lint): allow the instruction counter's chip and RMT4-diagnostic…
test(autoresearch): report instructions per show() from the RISC-V pe…