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

Remove generic in parse and emit functions #879

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thvdveld
Copy link
Contributor

@thvdveld thvdveld commented Dec 13, 2023

I was using cargo bloat and I saw duplicate functions in wire. After this PR, the duplicates were gone. Removing the generics in the parse and emit functions prevents monomorphization of these functions. Preventing monomorphization reduces the binary size of the library.

cargo bloat --release --example server --filter smoltcp:
On main: 216.3KiB
On this branch: 202.5KiB

cargo bloat --release --example sixlowpan --filter smoltcp:
On main: 213.9KiB
On this branch: 199.0KiB

I know that this is for an example of std. However, the impact of code size will be smaller for embedded I suppose. The negative impact on user experience seems low since I didn't had to change much in the examples (only the ping example) and in the tests.

@thvdveld thvdveld marked this pull request as draft December 13, 2023 16:49
Copy link

codecov bot commented Dec 13, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (2e60fc2) 79.70% compared to head (36c89d0) 79.68%.

Files Patch % Lines
src/wire/ndiscoption.rs 50.00% 3 Missing ⚠️
src/wire/arp.rs 66.66% 1 Missing ⚠️
src/wire/ethernet.rs 0.00% 1 Missing ⚠️
src/wire/icmpv4.rs 75.00% 1 Missing ⚠️
src/wire/igmp.rs 50.00% 1 Missing ⚠️
src/wire/ipv4.rs 75.00% 1 Missing ⚠️
src/wire/udp.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #879      +/-   ##
==========================================
- Coverage   79.70%   79.68%   -0.03%     
==========================================
  Files          78       78              
  Lines       28042    28002      -40     
==========================================
- Hits        22351    22312      -39     
+ Misses       5691     5690       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@thvdveld thvdveld force-pushed the remove-generic-in-parse branch 3 times, most recently from 79768ed to 7d99d71 Compare December 14, 2023 08:32
@thvdveld thvdveld marked this pull request as ready for review December 14, 2023 08:33
@thvdveld thvdveld force-pushed the remove-generic-in-parse branch 2 times, most recently from 2739262 to a0ee819 Compare December 14, 2023 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant