-
Notifications
You must be signed in to change notification settings - Fork 94
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
Performance improvement #430
Conversation
When the network interface can't make any progress, it's probably a good idea to yeild the task so that the wifi task may run and proceed with actually sending/receiving data. This seems to greatly improve response times, especially with low tick_rate_hz values. At 100Hz, ping time goes down from 25ms to <2ms. A simple http server test saw a response time reduction from 45ms to 6ms. At 1000Hz tick rate the gains are diminishing but there are some small gains. I ran my tests on esp32s3. This might also increase throughput. I have not tested that. It also may have some unforseen adverse effects. Ideally, we would have a more fine grained return value from interface.poll() than a bool so we have a better idea if yeilding is appropriate or not.
This reverts commit 77c437a.
This looks great! Gonna definitely try async when i get home from vacation next week :) |
Woah! This is a huge improvment! I'm getting 2MB/s upload in also pretty congested network! Thanks for the idea @karlri! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
With these changes, what would happen if the user tried to call this code from the other CPU core on dual-core models? I guess that use case was never officially supported but still: We would not want to task switch away from the wifi driver and we wouldnt want to interrupt the wrong core or something I guess. |
The scheduler doesn't support running some tasks on different cores currently and most probably never will. In theory we can run everything on the second core (needs some adjustments currently) but nothing changes then - it's just a different core. The interrupt is asserted on the same core in that case |
This is based on the idea in #413 but this also works for async since the decision to yield from the active task is done at a lower level. To attribute the user who came up with the original idea I included that commit.
Here are some figures using ESP32-C6 with this
cfg.toml
Using
embassy_bench.rs
I got these results (with a lot of RF noise, connected the ESP32-C6 to my laptop's hotspot)This also fixes the
embassy_bench.rs
exampe.