Skip to content

Conversation

diondokter
Copy link
Contributor

An updated #4035 that makes use of the new metadata API.

The example output is still good.

I've also retested with #4374 and these are the numbers:

cycles per poll
              nrf52832
master         78
edf            78
edf enabled    91

I don't have a nice rp2040 to test with...

Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

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

Could you add a build combination for edf-scheduler in [package.metadata.embassy] as well? This will make the release tool check it for semver break as well.

@diondokter
Copy link
Contributor Author

@lulf like this?

@lulf
Copy link
Member

lulf commented Aug 29, 2025

@diondokter Yup, that looks good for the example. Also add this to the same section in embassy-executor/Cargo.toml:

[package.metadata.embassy]
build = [
...
    {target = "thumbv7em-none-eabi", features = ["arch-cortex-m", "executor-interrupt", "executor-thread", "edf-scheduler"]},
...
]

@jamesmunns
Copy link
Contributor

jamesmunns commented Sep 1, 2025

Updated numbers using the bench2 test from #4374:

Details

Main

Test OK, count=109655, cycles=15300
  R0: 00000001   R1: 200200e0   R2: 00000000   R3: 20020249
  R4: 0001ac57   R5: 00000004   R6: 00000000   R7: 2003ff60
  R8: ffffffff   R9: ffffffff  R10: ffffffff  R11: ffffffff
 R12: ffffffff   SP: 2003ff58   LR: 200002ab   PC: 20001094
XPSR: 6100000f

upstream-drs-2, SHA 1736fd055

EDF NOT active (default)

Test OK, count=106185, cycles=15799
  R0: 00000001   R1: 200200e0   R2: 00000000   R3: 20020249
  R4: 00019ec9   R5: 00000004   R6: 00000000   R7: 2003ff58
  R8: ffffffff   R9: ffffffff  R10: ffffffff  R11: ffffffff
 R12: ffffffff   SP: 2003ff50   LR: 200002af   PC: 20001098
XPSR: 6100000f

EDF active (feat=embassy-executor/edf-scheduler)

Test OK, count=95870, cycles=17499
  R0: 00000001   R1: 200200e8   R2: 00000000   R3: 20020251
  R4: 0001767e   R5: 00000004   R6: 20020088   R7: 2003ff40
  R8: ffffffff   R9: ffffffff  R10: ffffffff  R11: ffffffff
 R12: ffffffff   SP: 2003ff38   LR: 20000313   PC: 20001124
XPSR: 6100000f

cycles per poll
               nrf52832  rp2040
master         78        153
edf            78        158
edf enabled    91        175

edit: this matches the previous test run (a bit faster with edf enabled): #4035 (comment)

@diondokter
Copy link
Contributor Author

Alright, so perf looks good and I just added the extra metadata and fixed the merge conflict

jamesmunns and others added 24 commits September 2, 2025 10:33
* Start hacking in cordyceps

This adds a third kind of runqueue, for now it should work the same as the
current "atomics" runqueue, but uses a cordyceps TransferStack instead of
the existing home-rolled linked list.

* Clean up, use new cordyceps feature

* A bit more cleanup

* Update docs to be more clear
This implements a minimal version of Deadline Rank Scheduling, as well as ways to access and set Deadlines.

This still needs some UX improvements, but is likely Enough for testing.
This allows the scheduler to better collaborate with existing critical sections
@Dirbaio
Copy link
Member

Dirbaio commented Sep 5, 2025

Implementation looks good, and it's great that perf doesn't regress now 🚀

  1. The public API is a bit strange though:

    • Metadata gives you a &Deadline.
    • Deadline has pub fn instant_ticks(&self) -> u64, to call that you must get the &Deadline from the Metadata.
    • Then it has a few pub fn *_current_task_deadline() -> impl Future methods, to call those you do not go through Metadata.

    Maybe the API should be just methods on Metadata? More consistent with the current name/set_name.

    • fn deadline(&self) -> u64
    • fn set_deadline(&self) -> u64
    • fn clear_deadline(&self)
    • etc
  2. set_current_task_deadline_after: it requires embassy-time-driver, which should be optional.

  3. about cargo features:

    • I'd name the feature scheduler-deadline.
    • I'm not sure if metadata-deadline is useful as a separate feature. What it'd be used for? I'd just make it all controlled by 'scheduler-deadline'.

@diondokter
Copy link
Contributor Author

Alright! Made the changes.

You're right about the weird API. I didn't critically review it after the metadata refactoring.

  • I'm not sure if metadata-deadline is useful as a separate feature. What it'd be used for? I'd just make it all controlled by 'scheduler-deadline'.

Idk, I just mirrored the existing metadata feature which looked nice to me. But I've removed it as per your preference.

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.

4 participants