-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
pthread: avoid heap alloc in pthread_cond_timedwait if possible (IDFGH-7409) #8987
Conversation
a754362
to
4081737
Compare
Thanks for your contribution. |
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.
This looks like a useful improvement, thank you! Have left one minor comment.
By the way, have you done any benchmarks to see how much this change improves performance?
I don't think this changes the runtime performance really (since you normally will be waiting at least a few milliseconds in the cond_timedwait). My main thought with this change was to avoid the possibility of heap fragmentation when waiting for longer timeouts, |
sha=c104662192c35ddc01050310ec96705894a75889 |
|
@MacDue Your code is available on master already. Because it is merged already, we are closing this PR. |
This creates the wait sem with
xSemaphoreCreateCountingStatic
if possible taking around 80 bytes off the stack.This semaphore is only used for the life of this function, which can be quite heavily called, so this avoids any possible heap/performance issues.