Skip to content

Conversation

kfessel
Copy link
Contributor

@kfessel kfessel commented Oct 6, 2025

Contribution description

provide a configurable threshold value for printing event handler run time

Testing procedure

Issues/PRs references

@github-actions github-actions bot added the Area: sys Area: System label Oct 6, 2025
@kfessel kfessel force-pushed the p-eventloop-dbg branch 2 times, most recently from 58536de to 4d884bf Compare October 6, 2025 16:49
* Use this to prevent *a lot* of output when debugging.
*/
#ifndef CONFIG_EVENT_LOOP_DEBUG_THRESHOLD
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0)
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD_US (0)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0)
# define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD_US (0)

Also indentation 👀

Comment on lines 466 to 467
uint32_t now2 = ztimer_now(ZTIMER_USEC);
uint32_t dt = now2 - now;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t now2 = ztimer_now(ZTIMER_USEC);
uint32_t dt = now2 - now;
uint32_t dt = ztimer_now(ZTIMER_USEC) - now;

@crasbe crasbe added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Oct 6, 2025

if ((CONFIG_EVENT_LOOP_DEBUG_THRESHOLD == 0) ||
dt > CONFIG_EVENT_LOOP_DEBUG_THRESHOLD) {
printf("eventh: %p took %" PRIu32 " µs\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf("eventh: %p took %" PRIu32 " µs\n",
printf("event: %p took %" PRIu32 " µs\n",

Typo.

Also I'm not sure if using the actual Mu sign is a good idea, it may not work with some terminal programs. It's probably safer to use us.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing the mu -> u

the h was because i changed fro event to handler being printed

how about:
'event: %p handler: %p queue: %p took:" PRIu32 "usec\n'

* Use this to prevent *a lot* of output when debugging.
*/
#ifndef CONFIG_EVENT_LOOP_DEBUG_THRESHOLD
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD (0)
# define CONFIG_EVENT_LOOP_DEBUG_THRESHOLD_US (0)

Also indentation 👀

Comment on lines 409 to 411
* @brief Threshold (USEC) below which event_handler are not printed,
* while debugging eventloop setting a value (!0) will also remove
* event_handler start message
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @brief Threshold (USEC) below which event_handler are not printed,
* while debugging eventloop setting a value (!0) will also remove
* event_handler start message
* @brief Threshold in microseconds below which event_handler
* are not printed.
*
* This can be used for debugging event loops. Setting a value
* other than zero will also remove the event_handler start message,

Perhaps a little clearer?

Copy link
Contributor Author

@kfessel kfessel Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setting a value (!0) will also remove event_handler start message looks easier to read it especially uses less chars to express the case where one should not even set a value ( but rely on the default)

the actual sentence is: setting a value will also remove event_handler start message <supersmall> other than 0

changed it anyway

}
now = ztimer_now(ZTIMER_USEC);

void * h = event->handler;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void * h = event->handler;
void *h = event->handler;

if ((CONFIG_EVENT_LOOP_DEBUG_THRESHOLD == 0) ||
dt > CONFIG_EVENT_LOOP_DEBUG_THRESHOLD) {
printf("eventh: %p took %" PRIu32 " µs\n",
(void *)h, dt);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure why you're casting h here, it already has the type void * 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i probably first just used event->handler -> needed the cast but then saw the events might change -> h was born

@kfessel kfessel force-pushed the p-eventloop-dbg branch 2 times, most recently from 27fd3d7 to ddfbabb Compare October 6, 2025 19:40
@riot-ci
Copy link

riot-ci commented Oct 6, 2025

Murdock results

✔️ PASSED

d888d46 sys/event: clang-format

Success Failures Total Runtime
10516 0 10516 15m:14s

Artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants