BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News The Go 1.5 Compiler and Runtime are Written in Go

The Go 1.5 Compiler and Runtime are Written in Go

Go 1.5 has a complete tool chain written in Go, a quicker garbage collector and runs a goroutine on each available CPU.

Previous releases of the language had better performance by improving the compiler, garbage collection and tooling, plus support for more platforms such Android/ARM, BSD, Solaris, NaCl. Google mentioned with each release that they were still keeping the compatibility promise which basically said “Except for security issues, no incompatible changes to the specification would be made.”

Go 1.5 is no different from previous releases, although some users have complained having problems compiling or running their programs, as shown by the list of Go issues. While Google considers 1.5 as a “significant release”, most of the changes are underneath the hood, pushing the performance even further. Some of the improvements are:

  • The compiler/linker/assembler and the runtime have been converted from C to Go and a few lines of assembly, removing all the initial C code. The compiler was translated automatically with tools and with some final cleanup by hand to void introducing new bugs, according to Robert Pike, co-designer of Go. The runtime was rewritten by hand with the helps of some tools. The new compiler was 10x slower in the beginning because some of the C constructs were not converted into efficient Go code, but the performance was drastically enhanced in subsequent steps. Some of the benefits of getting rid of C are: one codebase for all platforms, new platforms can be added easier, a unified tool chain with less code and simplified maintenance. One drawback: builds take twice the time they needed because of the idiomatic Go code generated by tools for the compiler. Google intends to lower the build time in 1.6.
  • There is one compiler, one linker and one assembler targeting the desired architecture and OS with $GOARCH and $GOOS.
  • Go 1.4 or later is necessary to build the distribution from source code.
  • A new concurrent garbage collector (CGC) has been added to the standard stop-the-world one, lowering the GC activity to under 10ms for heavy activity for each 50ms time slot. More details on the new CGC can be found in this design document or these slides. Programs run a few percentages faster compared to 1.4.
  • Some 32-bit distributions are no longer available due to the general trend to transition to 64-bit architectures.
  • A new go tool trace command provides fine grained tracing

A possible breaking change introduced in Go 1.5 is the maximum number of threads that can run simultaneously, which has been raised from 1 to the number of CPUs available. If a program depends on the order on which goroutines are executed, it is highly possible the program to have unexpected results and needs to be fixed. More details can be found in this design document.

Other enhancements: support for internal packages for all repositories, vendor support, command-line go doc command, and others. For more details on what’s new in Go 1.5 we recommend the release notes.

Rate this Article

Adoption
Style

Educational Content

BT