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

Correct increased memory usage #7

Merged
merged 47 commits into from
Jul 31, 2023
Merged

Correct increased memory usage #7

merged 47 commits into from
Jul 31, 2023

Conversation

szszszsz
Copy link
Member

@szszszsz szszszsz commented Jul 5, 2023

Correct increased memory usage by using references instead of the heapless buffers, and switching to serde_bytes for the serialization.

Copy link
Contributor

@sosthene-nitrokey sosthene-nitrokey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, but it appears that not all commands use references (for example CommandOpenPGPInfoResponse does not).

src/lib/commands.rs Outdated Show resolved Hide resolved
src/lib/commands.rs Outdated Show resolved Hide resolved
src/lib/commands.rs Outdated Show resolved Hide resolved
src/lib/transport.rs Outdated Show resolved Hide resolved
src/lib/transport.rs Show resolved Hide resolved
@szszszsz
Copy link
Member Author

szszszsz commented Jul 6, 2023

it appears that not all commands use references (for example CommandOpenPGPInfoResponse does not).

That's correct - I was prioritizing the failing command first. Will finish that in the next steps.

@sosthene-nitrokey
Copy link
Contributor

Protip to check the size of the types: cargo +nightly rustc --release -- -Zprint-type-sizes |& tee /tmp/type-sizes

Then you can peek into type-sizes to see where are the issues. I then used rg '\d{4} bytes' /tmp/type-sizes to see sizes larger than 1000 bytes.

@szszszsz
Copy link
Member Author

szszszsz commented Jul 6, 2023

To add, these were informative for me too:

  • arm-none-eabi-objdump -d runner-nrf52-nk3am.elf | c++filt
  • nm runner-nrf52-nk3am.elf -SCln

I think, that cargo bloat is not the best approximation for the embedded firmware case

@szszszsz
Copy link
Member Author

Connected: Nitrokey/nitrokey-3-firmware#312

@szszszsz szszszsz marked this pull request as ready for review July 31, 2023 13:14
@szszszsz
Copy link
Member Author

There were no heavy changes since the last review, only some clean up. I plan to merge the current state as-is, in a squashed commit.

@szszszsz szszszsz merged commit 9ec3d56 into main Jul 31, 2023
3 checks passed
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