-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add note about monomorphisation #24
Comments
This is a good idea. Ideally, what I'd like is if we could gather some references to some quantitative research on the relationship between monomophisation and binary size. If anyone in the community would be willing to look for/watch for such articles and post them to this issue, that would be great! |
@frencojobs Thanks for this link, @jonhoo's content is great. Since it's a little more general, I think it's out of scope for |
It might also be useful to link to https://github.com/llogiq/momo, a proc_macro that makes monomorphisation (Into, AsRef, AsMut) helper functions for you. twiggy seems to provide a functionality for analyzing monomorph code size bloat. https://rustwasm.github.io/twiggy/concepts/generic-functions-and-monomorphization.html (You could do that with hand-made tools downstream of |
@Artoria2e5 Thanks for this. Both of those tools are great additions. I've added them in #31 |
A reference related to this topic was added in c4be196 |
Generics with static dispatch can lead to duplicated functions, and if they are big enough, it will make for a large piece of the final binary.
Alternatives are dynamic dispatch with
dyn
, or just removing generic code.Is seems very important for minimizing binary size.
(If you don't want to change the function API, and the function is being generic over something like
AsRef<Path>
, you can also create helper function which resolvespath.as_ref()
and calls a non-generic function that receives&Path
instead.)The text was updated successfully, but these errors were encountered: