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

Replace heapless queues with framed BBBuffers #97

Merged
merged 4 commits into from
Sep 8, 2021

Conversation

MathiasKoch
Copy link
Member

@MathiasKoch MathiasKoch commented Aug 19, 2021

Replace heapless queues with framed BBBuffers for URC and response queues.

This allows for a much better utilization of the memory allocated for the queues.

For example, before this PR the RES_QUEUE was able to hold RES_CAPACITY items of BUF_LEN size, leading to a memory allocation of RES_CAPACITY * BUF_LEN plus a minor overhead for the queue. The issue being that 95% of all items being enqueued in the queue is much smaller than BUF_LEN, leading to a huge memory waste, as everything is scaled for worst cases.

With this PR, the number of items in the queue is no longer fixed, but rather the queue is of N bytes len, with dynamic item sizes through framing. See https://docs.rs/bbqueue/0.4.12/bbqueue/framed/index.html for more information on overhead.

This should allow for a lower general stack usage, and a much more efficient memory usage.

NOTE
This is an internal only change, and should not affect the public API in other places than the instantiation of the queues. Nevertheless this is considered a breaking change, and should be treated as such.

@dbrgn
Copy link
Collaborator

dbrgn commented Aug 19, 2021

Sounds nice! 🚀

@MathiasKoch MathiasKoch force-pushed the enhancement/framed-bbqueue branch from a0e5f74 to 4c844e9 Compare August 23, 2021 11:59
@MathiasKoch MathiasKoch merged commit c51e2c9 into master Sep 8, 2021
@MathiasKoch MathiasKoch deleted the enhancement/framed-bbqueue branch September 8, 2021 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants