Replace heapless queues with framed BBBuffers #97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 holdRES_CAPACITY
items ofBUF_LEN
size, leading to a memory allocation ofRES_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 thanBUF_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.