Add opt_size feature to reduce .text segment size at the cost of perf… #9
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.
…ormance.
Analogous to jedisct1/rust-hmac-sha256#2, except several months late :D!
Benchmarks
Benchmarks were done targeting an Adafruit Feather RP2040, running at the default 125 MHz. My
rustc
info is as follows:I used the following
cargo
profiles (dev
== Debug) and varied theopt-level
:Results
.text
sizecargo bloat
.text
diffbloat
diffcargo bloat
field represents the cumulative.text
andSize
reported by running:cargo bloat --release --example ed22519-bench --filter ed25519_compact [--features=opt_size]
"..text
size is in bytes.Out of curiosity, I also wanted to see what would happen if I used a different
opt-level
fored25519_compact
compared to the other deps.opt-level=3
,ed25519_compact
opt-level="s"
.text
sizecargo bloat
.text
diffbloat
diffopt-level="s"
,ed25519_compact
opt-level="z"
.text
sizecargo bloat
.text
diffbloat
diffMy takeaway from these results is that the
opt-size
feature can be a net-win for time and space, but you need to do benchmarks to be sure.opt-level=3
does not appear to be a good idea for constrained environments period.Benchmark Code
I provide this for completeness only, I suggest using a project template and paste the below code into it.
Source
Cargo.toml
Deps