Optimizing Rustc's next trait solver (opens external site)
View full thread · View on Hacker News
To get push notifications on iPhone or iPad, add Hack and Chat to your Home Screen: tap Share → Add to Home Screen, then open the installed app and enable push in Settings.
View full thread · View on Hacker News
Also the point of the release profile is to trade compilation performance for runtime performance (you'd be better off iterating on the dev profile).
There are also many other details that interfere and can't be inferred from your comment like: what's your OS, which linker are you using, are you using opt-level 3 on C++, which compiler are you using on C++, are you using heavily using templates in C++ or macros in Rust, etc.
Replies (1)
I use clang for compiling c++. But I use a custom build system I built on top of it. I compile with -O2 but using -O3 or even -O5 doesn't make much of a difference.
I tried pretty hard to make sure both projects output small binaries and compile fast.
I don't depend on serde because I knew it is bloated but didn't know serde_json was so bloated too.
I am using latest stable rust on linux x86_64 so I assume it is using lld which is what c++ project uses too.
I don't think there are any template use in either project except things like hashmaps and slices etc. I don't use traits except to interact with dependencies in rust.
I use a specific structure in C++ so it is not like regular C++ code but that is just basically impossible to do in rust because I would have to write too much unsafe code and it feels mandatory to use RAII in rust.
Replies (1)
-O4 and higher are (currently) equivalent to -O3
> I don't depend on serde because I knew it is bloated but didn't know serde_json was so bloated too.
serde_json depends on serde though?
> I don't think there are any template use in either project except things like hashmaps and slices etc. I don't use traits except to interact with dependencies in rust.
If you're interested in investigating further it might be worth trying cargo bloat [0] or similar to get a bit more data about what is consuming space. rustc's self-profiling framework [1] might be another way to get data.
[0]: https://github.com/razrfalcon/cargo-bloat
[1]: https://github.com/rust-lang/measureme
Replies (1)
Ahhh, of course.
Thanks for the suggestions.
Edit: I was able to reduce the output code size to <600KB from the original 1.3MB after exploring the suggestions. It made the release build time a lot longer but it is worth it for my use case.