-
Notifications
You must be signed in to change notification settings - Fork 96
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
Reduce stack-allocations #243
Conversation
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.
Weird that heapless::Pool
didn't help that much 🤔. This impl looks good to me though, just a few comments :)
Tested locally in a current project. The highlighted code section isn't present after 6b53683 -> 04e9d2c So that's a very optimized
|
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!
@@ -97,31 +98,72 @@ impl WifiMode { | |||
} | |||
} | |||
|
|||
const DATA_FRAMES_MAX_COUNT: usize = RX_QUEUE_SIZE + RX_QUEUE_SIZE; |
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.
@bjoernQ Is this a typo (RX_QUEUE_SIZE + TX_QUEUE_SIZE
) or is this intentionally 2x?
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.
looks like a typo, true. should be RX + TX queue size 👍
let packet = if let Some(packet) = DataFrame::from_bytes(src) { | ||
packet | ||
} else { | ||
return esp_wifi_sys::include::ESP_ERR_NO_MEM as esp_err_t; |
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.
I think this return may leak memory because esp_wifi_internal_free_rx_buffer(eb);
is not called.
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.
true - we should call esp_wifi_internal_free_rx_buffer(eb);
here 👍
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.
before you do anything, I made a PR this morning that includes this :)
Currently there are a lot of stack allocations especially here:
I first tried to use
heapless::Pool
- that helped a lot but not as much as I wanted.This PR now uses statically allocated memory backing the
DataFrame
With that we get to e.g.
Which looks quite okay to me.