
The Rust Project has pushed out v1.38.0 of its programming language, adding pipelined compilation, a feature that can speed builds for projects involving multiple crates, according to the Rust team.
Pipelined compilation changes the behaviour of Cargo, Rust’s dependency manager and project compiler, so that it will now start to build dependant crates (Rust’s term for binary executables) as soon as the metadata is ready. This can deliver compilation speed increases of 10 to 20 percent for some projects, the Rust Project team reports on its blog announcing the new release.
The reason this approach works is because metadata such as the list of types, dependencies, and exports is produced early in the compilation process. This means that Cargo does not have to wait until the compilation process is complete in order to start the process of compiling a library that is dependent upon the current one.
However, the Rust team itself appears unsure of the merits of pipelined compilation. It obviously only delivers a benefit if the compiler is called at least twice, but according to a blog post by Rust developer Alex Crichton, several conditions must be met in order for pipelined compilation to make a significant difference.
Crichton says the best wins will come from release mode, because metadata is currently produced just before translation to LLVM, optimisation, and code generation, and optimisation typically takes longest in release mode. He also warns that full crate graph builds may not see much benefit.
“We can’t pipeline all possible compilations due to details like procedural macros, build scripts, linked executables, etc. For these compilations Cargo still has to wait for rustc to previously completely finish before proceeding,” he commented.
Also added in this release is a lint to warn when incorrect use of the mem::uninitialized
function is detected. This function allowed developers to sidestep Rust’s initialisation checks and is regarded as unsafe. The Rust team plans to deprecate it in a future release, but for now is including the lint to warn against a narrow class of incorrect uses of the function.
In addition to some library changes, Rust v1.38.0 also provides a new function for debugging that simply returns the name of a type. This enables the developer to see at run-time what a function’s type parameters have been instantiated with.
Rust is a rapidly evolving project that releases a new update every month or two. The language is language focused on speed, memory safety and parallelism and is similar to other languages such as C++in syntax. The project is sponsored by Mozilla.