firmware icon indicating copy to clipboard operation
firmware copied to clipboard

[Feature Request]: Add CPU usage to host Metrics

Open marshalleq opened this issue 7 months ago • 3 comments

Platform

Cross-Platform

Description

I realise there can be a slight performance penalty for this which is why I think it should be more like an opt in toggle for debugging, however I'm interested to know how for example a high site node is performing and whether cpu is a bottleneck, in particular on the single core low power devices.

Would it be possible to get this added in somewhere?

It's my understanding this could potentially be implemented by leveraging FreeRTOS's run-time statistics capabilities (detailed at https://www.freertos.org/Documentation/02-Kernel/02-Kernel-features/08-Run-time-statistics), which involves enabling configGENERATE_RUN_TIME_STATS and configuring the associated timer macros.

Thanks.

marshalleq avatar May 28 '25 20:05 marshalleq

I would expect the arduino loop() polling to eat up 100% CPU all the time and therefore doesn't let the FreeRTOS idle task run to count its idle time. A solution would require to measure the runtime of a single loop walkthrough and to calculate according expected runtime (based on actual CPU and frequency) an estimated "idle" time / percentage value.

mverch67 avatar May 29 '25 08:05 mverch67

I would expect the arduino loop() polling to eat up 100% CPU all the time and therefore doesn't let the FreeRTOS idle task run to count its idle time.

The loop() function is called by the idle task when using FreeRTOS under Arduino.

mikerjuk avatar Jun 04 '25 09:06 mikerjuk

This is implemented in forked version by instrumenting loop() and RadioLibInterface::onNotify to measure time it spent doing actual work (excluding mainDelay.delay(...)).

It does not include time spent handling interrupts, but those should be minimal anyway.

lkosson avatar Jun 16 '25 08:06 lkosson