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

SPI Blocking Driver Performance Overhead ~2x #939

Closed
ProfFan opened this issue Nov 14, 2023 · 2 comments
Closed

SPI Blocking Driver Performance Overhead ~2x #939

ProfFan opened this issue Nov 14, 2023 · 2 comments
Labels
bug Something isn't working peripheral:spi SPI peripheral

Comments

@ProfFan
Copy link
Contributor

ProfFan commented Nov 14, 2023

On the ESP32-S3 I observed that the following snippet uses double the bit time needed for one transaction:

// Just write some garbage to SPI and see how long it takes
let mut recv_buf = [0u8; 20];
let start_time = embassy_time::Instant::now();
spi.transfer(&mut recv_buf).unwrap();
let time_to_spi = start_time.elapsed().as_micros();

This is on a SPI (36MHz) without CS line. Time needed scales linearly with the number of bits (opt-level=3):

No. bytes Time (us) LTO?
20 11 Y
64 25 Y
80 40 Y
80 167 N

Without LTO it takes even longer.

@jessebraham jessebraham added the bug Something isn't working label Nov 14, 2023
@ProfFan
Copy link
Contributor Author

ProfFan commented Nov 15, 2023

@bugadani I can mostly confirm this is caused by the SPI hot functions not in IRAM. After adding #[ram] to the two hot path functions timing variance is down to 1us and little overhead

@MabezDev
Copy link
Member

Closing in favour of #946

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working peripheral:spi SPI peripheral
Projects
Archived in project
Development

No branches or pull requests

3 participants