BT

Rust 1.23 Improves Memory Usage and More

| by Sergio De Simone Follow 21 Followers on Jan 07, 2018. Estimated reading time: 1 minute |

The most significant improvement in Rust’s latest version is the reduction of memory usage made possible by avoiding some unnecessary copies. Additionally, rustdoc now consistently uses a CommonMark compliant engine to render the documentation.

According to the Rust team, by avoiding the creation of copies of certain objects, rustc memory usage decreases by 5–10%, although this figure likely depends on the specific program being compiled. Specifically, rustc now enforces to its full extent the equivalence between locals and arguments to a function. This makes it unnecessary to create a copy of the argument when binding it to a local. The copy behavior was a remnant of the distinction that originally existed between locals and arguments at the MIR level and was removed at some point. Besides improving memory usage, this improvement will also make debugging information less confusing by avoiding showing both the local and the incoming argument. This could get even worse with a mutable local binding, in which case the debugger could show a changing value for the local, while the argument did not change.

Another interesting change is rustc enabling TrapUnreachable in LLVM, which makes LLVM translate unreachable instructions into hardware traps. Previously, control flow could step over an unreachable instruction and reach whatever code happened to follow it in memory. This should mitigate the impact of undefined behavior with unreachable code.

On the documentation front, rustdoc has been undergoing an effort to become fully CommonMark compliant. In Rust 1.23, documentation is rendered both with Rust legacy renderer, Hoedown, as well as with a CommonMark-compliant rendering engine. This behavior will remain in place for some time and rustdoc will warn if any differences in the rendering are found, so documentation maintainers can fix them. In a future release, the CommonMark-compliant engine will become the default.

Rust 1.23 also introduces some library stabilizations, including the addition of the AsciiExt trait to primitive types. This means that u8, char, and str can use any method from the AsciiExt` trait without importing it.

Cargo, Rust's package manager, has also got a few improvements, including support for uninstalling multiple packages at once and installing a specific package version using cargo install --version.

Rust 1.23, which includes many more changes and improvements, can be updated by running rustup update stable.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss
BT