Post

github.com/rust-lang/ba... I optimized the size of every Rust binary (that uses std) by over 1kb :). It's not a lot but it's something! There were some easy size optimizations around placing function boundaries to reuse code, and in the end I went all in with some unsafe to remove bounds checks :3.

github.comOptimize proc maps parsing code size by Noratrieb · Pull Request #729 · rust-lang/backtrace-rsThe current code size is really wastefully large. Originally, it was 1500 lines of assembly in Godbolt, now I reduced it to just under 800. The effect of .text size in hello world is from 297028 to...

0 reposts12 likes

Is there any tooling in place that will ensure this won't regress? Looking at the changes, it seems like it'd be easy for even just a small refactor to undo that work by accident.

it had some CI to check binary size changes but it caused too many problems and was removed again. something like it could be added again. even then, I'm not too worried about this here. the code is sufficiently weird that I expect people will quickly see the history and learn why it's this way

my favorite one was moving a variable declaration of a Vec down to where it was used instead of the start of the function, so that early returns before that didn't need to worry about dropping it