Search code examples
gocompiler-constructionprogramming-languages

Is Go 1.5's bootstrapped compiler slower than the Go 1.4 compiler written in C?


Go 1.5 managed to release a bootstrapped compiler written in Go. Assuming Go is slower than C, and the earlier Go compiler is written in C, is the bootstrapped compiler going to be slower in compilation time?


Solution

  • Yes, the Go 1.5 compiler is slower, as discussed in the release notes:

    Builds in Go 1.5 will be slower by a factor of about two. The automatic translation of the compiler and linker from C to Go resulted in unidiomatic Go code that performs poorly compared to well-written Go. Analysis tools and refactoring helped to improve the code, but much remains to be done. Further profiling and optimization will continue in Go 1.6 and future releases. For more details, see these slides and associated video.

    Again, the compiler was (initially) automatically translated, so after the translation it output the same code as before: your programs aren't slower because the compiler is. The rest of the release notes and the links above shed more light. There are considerations other than compile speeds involved: the authors intend to move faster in Go than they could in C.

    I'd recommend upgrading: open-source code will come to depend on 1.5, and if you stay behind you lose a lot of cool stuff, like big reductions in GC latency from pushing most of that work into the background (also discussed in the Performance section linked above; I wrote a bit more about it responding to another question).

    You should, as with any big upgrade, test to make sure that stuff like the new default of using all available cores, tweaks to scheduling, or any of the little library behavior changes don't bite you.