Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Added example of an executor that tracks the idle time. #2501

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

fakusb
Copy link
Contributor

@fakusb fakusb commented Jan 30, 2024

An example for the rp pico towards https://embassy.dev/book/dev/faq.html#_how_can_i_measure_resource_usage_cpu_ram_etc

  1. Does anyone have comments on the example code itself?
  2. If I'm not mistaken, the executor would treat time spend during an interrupt (e.g. all the tasks in an InterruptExecutor) as idle time, because the interrupt handler is executed before the non-interupt-level code after the wfe-instruction is executed. This kind of caveat should probably be made even more explicit?

let total_idle_posttick = idle_duration.get();
let delta_t = now_posttick.duration_since(now_pretick);
let delta_idle_dur = total_idle_posttick.sub(total_idle_pretick);
let idle_percentage = delta_idle_dur.as_ticks() as f32 / delta_t.as_ticks() as f32;
Copy link
Member

Choose a reason for hiding this comment

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

this is missing a *100

@Dirbaio
Copy link
Member

Dirbaio commented Feb 9, 2024

If I'm not mistaken, the executor would treat time spend during an interrupt (e.g. all the tasks in an InterruptExecutor) as idle time, because the interrupt handler is executed before the non-interupt-level code after the wfe-instruction is executed. This kind of caveat should probably be made even more explicit?

there's a way around this: you can do the wfe inside a critical section. If an interrupt becomes pending, it still causes the wfe to exit, but the interrupt isn't handled yet because it's disabled. You can then count the elapsed time as idle then exit the critical section, so the interrupt time is not counted as idle.

@Dirbaio
Copy link
Member

Dirbaio commented Feb 9, 2024

i'm marking as draft, please mask as ready to review when it's no longer WIP.

@Dirbaio Dirbaio marked this pull request as draft February 9, 2024 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants