If you are a Rust developer you have most likely celebrated the news that the version 1.64 released on 22/09/2022 is 10-20% faster on Windows.
It is one of the most important changes in that release aside of stabilization of some APIs.
But how one merge request made it possible to account to such a performance improvement?
The person behind the merge request is Rémy Rakic aka lqd (pronounced liquid), a French software engineer regularly contributing changes to the Rust compiler.
On 12/05/2022 he submitted a new merge request illustrated with these performance test results:
As a proof he was able to improve performance consistently across all kinds of tests up to 18.92%. On hundreds of tests, all showed a significant improvement, while only two showed a slight decrease:
Such results are a Holy Grail of every performance hunter.
On 11/07/2022 Jakub Beránek announced the good news after two months of heavy work done by lqd to pass tests and fine tune the merge request.
Another two months was needed to make it to the release.
It only proves how much effort it required to provide the result. But what was it about?
Rust compiler supports profile guided optimization. It is a set of techniques used to prepare application, figure out how an application is executed, and based on the data, optimize the application to execute the most important code as fast as possible.
The first phase is called an instrumentation, second training, and third optimization.
The app is enchanted with points of gathering data, for example to know what function is executed, and what is the order of execution.
Than, the app is called a lot of times to gather as much data, as possible.
At the end, a set of various techniques is used to figure out, how the code can be improved to boost the performance.
One of such techniques is known as inlining. A technique made from an observation that having too much functions in…