Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Go 1.7 Brings Compiler Improvements and More

Go 1.7 Brings Compiler Improvements and More

This item in japanese

Lire ce contenu en français

Go 1.7 significantly improves both compile times and runtime performance, says Google engineer Chris Broadfoot. It also adds hierarchical tests and benchmarks and official support for Linux on IBM z Systems (s390x).

As InfoQ reported, compiler improvements in Go 1.7 are mostly related to Go’s new compiler backend for the amd64 platform based on static single-assignment (SSA). The new backend generates more compact and faster code thanks to a number of advanced optimizations, including bounds check elimination and common subexpression elimination. Google’s benchmark shows a 5–35% speedup at run time, while compile time and and binary size have been reduced by as much as 20–30%. As it happens, benchmarks may vary a lot and a few Hacker News users reported 2x build speed increases.

As mentioned, the new SSA backend is only available for the amd64 platform. However, its porting to all supported architectures is one of the main goals for Go 1.8, according to Google engineer Brad Fitzpatrick. Getting rid of the old backend should additionally make it possible to simplify the frontend, which currently assumes that a less capable backend is available and has to do more work, adds Fitzpatrick. This would probably bring even more performance improvements. More details about Go 1.8, planned for release in February 2017, can be found in the GoLang Dev forum.

Other notable changes brought by Go 1.7 are subtests and sub-benchmarks, which make it possible to define hierarchical tests and table-driven benchmarks. This is done by specifying a slash-separated list of regular expressions as arguments to the -run and -bench flags, e.g.:

go test -run Foo     # Run top-level tests matching "Foo".
go test -run Foo/A=  # Run subtests of Foo matching "A=".
go test -run /A=1    # Run all subtests of a top-level test matching "A=1".

Finally, Go 1.7 adopted as part of the standard library the context package, which makes it easier to enable cancellation, timeouts, and passing request-scoped data when doing networking; and made it standard the use of vendor directories, which allow developers to use local copies of external dependencies to be used instead of those automatically pulled from the GOPATH or the standard library.

For a full view of additions, improvements, and fixes in Go 1.7 you can check the release notes.

Rate this Article