Tighten Rust’s Belt: Shrinking Embedded Rust Binaries
Hudson Ayers, Evan Laufer, Paul Mure, Jaehyeon Park, Eduardo Rodelo, Thea Rossman, Andrey Pronin, Philip Levis, and Johnathan Van Why
Published in Proceedings of the 23rd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2022), June 2022.
Abstract
Rust is a promising programming language for embedded soft- ware, providing low-level primitives and performance similar to C/C++ alongside type safety, memory safety, and modern high-level language features. We find naive use of Rust leads to binaries much larger than their C equivalents. For flash- constrained embedded microcontrollers, this is prohibitive. We find four major causes of this growth: monomorphization, inefficient derivations, implicit data structures, and missing compiler optimizations. We present a set of embedded Rust programming principles which reduce Rust binary sizes. We apply these principles to an industrial Rust firmware application, reducing size by 76kB (19%), and an open source Rust OS kernel binary, reducing size by 23kB (26%). We explore compiler optimizations that could further shrink embedded Rust.
Paper (529KB)
BibTeX entry
@inproceedings{rust-lctes22, author = "Hudson Ayers and Evan Laufer and Paul Mure and Jaehyeon Park and Eduardo Rodelo and Thea Rossman and Andrey Pronin and Philip Levis and Johnathan Van Why", title = "{Tighten Rust’s Belt: Shrinking Embedded Rust Binaries}", booktitle = "{Proceedings of the 23rd ACM SIGPLAN/SIGBED International Conference on Languages, Compilers, and Tools for Embedded Systems (LCTES 2022)}", year = {2022}, month = {June} }





Login