Improving Rust compile times to enable adoption of memory safety
I originally posted this on reddit[1], but figured I&#x27;d share this here. I checked out ripgrep 0.8.0 and compiled it with both Rust 1.20 (from ~5.5 years ago) and Rust 1.67 (just released):<p><pre><code>    $ git clone https:&#x2F;&#x2F;github.com&#x2F;BurntSushi&#x2F;ripgrep
    $ cd ripgrep
    $ git checkout 0.8.0
    $ time cargo +1.20.0 build --release
    real    34.367
    user    1:07.36
    sys     1.568
    maxmem  520 MB
    faults  1575
    
    $ time cargo +1.67.0 build --release
    [... snip sooooo many warnings, lol ...]
    real    7.761
    user    1:32.29
    sys     4.489
    maxmem  609 MB
    faults  7503
</code></pre>
As kryps pointed out on reddit, I believe at some point there was a change to add&#x2F;improve compilation times by making more effective use of parallelism. So forcing the build to use a single thread produces more sobering results, but still a huge win:<p><pre><code>    $ time cargo +1.20.0 build -j1 --release
    real    1:03.11
    user    1:01.90
    sys     1.156
    maxmem  518 MB
    faults  0

    $ time cargo +1.67.0 build -j1 --release
    real    46.112
    user    44.259
    sys     1.930
    maxmem  344 MB
    faults  0
</code></pre>
(My CPU is a i9-12900K.)<p>These are from-scratch release builds, which probably matter less than incremental builds. But they still matter. This is just one barometer of many.<p>[1]: <a href="https:&#x2F;&#x2F;old.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;10s5nkq&#x2F;improving_rust_compile_times_to_enable_adoption&#x2F;j6ztle9&#x2F;" rel="nofollow">https:&#x2F;&#x2F;old.reddit.com&#x2F;r&#x2F;rust&#x2F;comments&#x2F;10s5nkq&#x2F;improving_rus...</a>