Bench: opt-in nRF52 instrument for MCU awake time and CPU time per received packet

Changelog: -
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5.5 committed 2026-11-30 12:30:27 +01:00
1 parent 22700192bd
commit 7a7c894e2d
4 files changed
+85 -1

No files matched your search

+28
View File
@@ -171,6 +171,34 @@ a half-drained `rxlog`/`pktlog` page would otherwise wait for the next
connection event — the bridge drains those on a 2-minute duty cycle, so a slower
drain directly costs collected frames.
### CPU time per received packet (`PWR_DUTY_INSTRUMENT`)
A bench build with `-D PWR_DUTY_INSTRUMENT` (nRF52 only, nothing changes
without the flag) prints one line to the USB console every ~10 s:
```
PWRDUTY awake_ms=… asleep_ms=… wakes=… duty_permille=… pkt_us=… pkt_n=…
```
- `awake_ms`, `asleep_ms` and `duty_permille` are the time between a return
from `NRF52Board::sleep()` and the next entry into it, against the WFE span
inside it. This needs `powersaving on`: without it `sleep()` is never called.
- `wakes` counts the passes through `sleep()`. BLE and USB events wake the
core too, so the duty is not packet cost alone.
- `pkt_us` and `pkt_n` are the CPU time spent in
`Dispatcher::processRecvPacket()` (dedup, crypto, routing) and the number of
packets. They do not depend on background wakes. This is the work a filter
on the radio side could skip for a packet that is dropped anyway.
All counters are cumulative since boot, so take the difference between two
lines.
Measured on the XIAO x4, 24. 11. 2026, live mesh, about 440 packets/h (all
flood adverts): about **6.8 ms CPU per received packet**, mostly the Ed25519
check of the advert signature. The duty went from 0.05 % at rest to 0.13 %.
The awake time is a small part of a node's current; the radio's RX and the
SoftDevice dominate.
## A mast that runs flat: bootlock and cutoff
A panel that gets no direct sun in winter (remote-mast faces east, 11/2026: