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

Refactor benchmark code and add more counters #131

Merged
merged 3 commits into from
Aug 9, 2024
Merged

Conversation

NoeTerrier
Copy link
Collaborator

Code is refactored to make it easier to add a counter. Two type of counters: first one is basic counters yith purpose of counting occurences of events. The second one aims to measure difference beetween two events.
The counters shares many properties that are grouped under the Either enum.

Other properties are recorded like number of world switches or firmware exits.

Related to #125.

@NoeTerrier NoeTerrier added the enhancement New feature or request label Aug 7, 2024
@NoeTerrier NoeTerrier self-assigned this Aug 7, 2024
@NoeTerrier NoeTerrier force-pushed the benchmark-extended branch 2 times, most recently from a501c39 to 392260c Compare August 7, 2024 14:34
@NoeTerrier NoeTerrier marked this pull request as ready for review August 7, 2024 14:37
Copy link
Owner

@CharlyCst CharlyCst left a comment

Choose a reason for hiding this comment

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

Thanks a lot for all the new changes :)

It's a big features so I have a few comments about design and implementation, but it's going in the right direction!

crates/core/src/lib.rs Outdated Show resolved Hide resolved
.align 4
.global _start
_start:
csrw mie, 0x1 // Dummy instruction to exit firmware
Copy link
Owner

Choose a reason for hiding this comment

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

What is this instruction doing? It sets bit 0 in mie but why do we need that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It's not requiered, but it result in a firmware exit: it's to show that the exit counter works :)

Maybe I can add an assertion to really check that the counter is set to 1 or remove this if it's useless here.

justfile Outdated Show resolved Hide resolved
src/benchmark.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
CharlyCst
CharlyCst previously approved these changes Aug 8, 2024
Copy link
Owner

@CharlyCst CharlyCst left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, I'll merge that tomorrow :)

Next step is going to get numbers for the paper with our new tools 🥳

Comment on lines +157 to +161
for counter in [
IntervalCounter::ExecutionTime,
IntervalCounter::InstructionRet,
]
.map(Either::IntervalCounter)
Copy link
Owner

Choose a reason for hiding this comment

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

Wow I didn't know we could do that in Rust, thanks for the trick :)
That implies that Either::IntervalCounter is a function, which is cool.

Code is refactored to make it easier to add a counter.
Two type of counters: first one is basic counters with purpose of
counting occurences of events. The second one aims to measure difference
beetween two events.
The counters shares many properties that are grouped under the Either
enum.

Other properties are recorded like number of world switches or
firmware exits.
This commit adds a new benchmark ecall (FID number 3) to Miralis which
prints the collected statistics. Because it can be helpful to use this
functionality directly from the payload (e.g. Linux) this commit also
make it possible to execute some of the Miralis ecalls from the payload.
Two new firmware to test benchmark ecall (FID number 3) from firmware
and ecall from payload.
@CharlyCst CharlyCst merged commit eaeb4fd into main Aug 9, 2024
1 check passed
@CharlyCst CharlyCst deleted the benchmark-extended branch August 9, 2024 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants