optimize stack size requirements of reed_solomon_decode() #3
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-sleepybishop/nanors!3
Loading…
Reference in a new issue
No description provided.
Delete branch "stack_opt"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I noticed that
reed_solomon_decode()would consume quite a lot of stack space due to the 3DATA_SHARDS_MAXsizedintbuffers (3060 bytes).It looks like the range of
uint8_tis sufficient for these, which already quarters the stack size required.Then if the data shard number is known at compile time, we can also select a lower value for
DATA_SHARDS_MAX- make that configurable viaCFLAGS.I would suggest leaving this as is as it's intention is to inform the maximum shards that can be used in
GF2^8, to further reduce the size of the permutation vectors inreed_solomon_decode()maybe a new define needs to introduced or maybe use vla's there, though that's problematic for embedded targets as wellOk but I would prefer the VLA version then.
Shard number is not so variable/would have to be sanitized if it comes from the network anyway and the code is only called once per shard ensemble, so the VLA cost is negligible (but I am too not a fan).
Another approach would be allocating the array in
reed_solomon_new()but that would inflict unnececary cost on the encode-only path.Agree, that was the reasoning behind
_decodebeing the way it is. Let's go with VLA.Thank your for the PR!