1. 13
  1. 4

    The need for incremental compilation is one of the worst things about programming in C/C++ and a constant source of WTF moments and tedium. No modern language should make the same mistake of relying on it for fast compilation.

    I’m disappointed to see this for Rust, because if it’s aiming to replace C/C++ this is one of the things it should really get right. As a C++ programmer, I am not excited by the idea of switching from a language that’s a nightmare to build to another language that’s a nightmare to build. Honestly this might even be a step back - now it’s even less likely that anyone will put serious work into optimising the compiler.

    (That said, this is the first time I’ve looked at ccache and it seems to get it as right as possible: hashing source files/includes/compiler args/the compiler itself is good and takes no time. I did some tests at work on this and reading + hashing the entire codebase takes less time than compiling a single file)

    1. 9

      How are you supposed to avoid the need for incremental compilation? Modern compilers perform lots of complicated transformation to get good performance. This takes time.

      1. 2

        I don’t know anything about anything but it just feels like there’s no way compiling rust is an inherently as slow as rustc is

        1. 1

          The vast majority of my code has no impact on the final performance of the program and burning CPU time optimising it a waste. It’s also a waste burning CPU time on code that is performance sensitive, because optimising compilers are not remotely good enough and I have to do all the work to make it fast anyway.

          I’d much rather have a compiler that lets me tell it what needs to be optimised, how much effort should be spent optimising it, and how it should be optimised. I should be able to tell it “this loop needs unrolling”, “this loop is super hot and must be vectorised with no peeling and you should refuse to compile if you can’t do that”, etc. (This is largely how the Intel performance tools work btw)

          steve/nick: I know the rust team is working on incremental compilation, my point is that they shouldn’t. It’s a large source of sadness in the C/C++ world, and computers are fast enough that it should really not be necessary.

        2. 4

          Rust team is working on incremental compilation. They mention it in a lot of updates and threads on forums. It’s probably hard to add to a complex compiler while balancing what’s good for it vs what structuring is good for other features. Not o mention the language itself is complex.

          So far, I’d say the progress for money invested is going a lot smoother than “C with Classes” did. ;)

          1. 3

            Moreover, this commit enables it per default in recent nightlies - I’ve noticed the speedup as well :)

            1. 1

              Glad to know it’s come that far with noticeable benefit. I’ve loved it since LISP giving me per-function compiles at a fraction of a second each. You just flow and flow with the work once automated parts happen at such a pace.

          2. 3

            Yes ccache is a really nice tool. I’ve been bit by miscompiles due to stale caches once or twice but it usually works quite well.

            1. 4

              now it’s even less likely that anyone will put serious work into optimising the compiler.

              We have been putting person-years of work into getting incremental recompilation working, and regularly work on other aspects of compiler performance, and will continue to do so in the future. Our users regularly tell us that compiler performance is important, and we agree! Stuff like this is only one part of that overall picture.

            2. 2

              Short version: it’s like ccache but for Rust, delivering up to 2x build speed improvements in some Servo test scenarios. Very cool!

              1. 11

                Actually I believe it was originally designed to support the normal use case of ccache and recently extended to support Rust. So it would be more accurate to describe it as “like ccache but can use an s3/redis store instead of local disk and has a windows binary, and supports caching Rust compilations.”

                1. 2

                  Oh, I like that description! :D

                  1. 2

                    It’s also written in rust, which is a likely selling point for people browsing this tag.