Go 1.14 improves runtime, compiler

Latest Go language production release brings improvements across the board including to Windows and WebAssembly support
Pro
Image: Paweł Czerwiński/ CCO

27 February 2020

Go 1.14, the latest
version of the Google-developed open source programming language used
to create Docker, Kubernetes, Istio, and other cloud-native
computing projects, is now available as a production release.

The Go upgrade, released 25 February, improves the runtime and compiler. Version 1.14 also will be the last to support 32-bit Apple platforms, according to release notes.

With the Go runtime improvements, the performance of most use cases of defer has been boosted to incur nearly no overhead, compared to calling the deferred function directly. As a result, defer now can be used in performance-critical code without overhead concerns.

The improved Go runtime also makes Goroutines asynchronously pre-emptible. This means loops without function calls no longer potentially deadlock the scheduler or significantly delay garbage collection. This capability is supported on all platforms except windows/arm, darwin/arm, js/wasm, and plan9/*.

One consequence of the pre-emption implementation is that Go 1.14 programs on Linux and MacOS will receive more signals than earlier versions. Programs using packages such as syscall or golang.org/x/sys/unix will see more slow system calls fail with EINTR errors. These programs will have to handle those errors in some way, most likely by looping to try the system call again.

In addition, the page allocator is more efficient and incurs less lock contention at high values of GOMAXPROCS. This will be most noticeable as lower latency and higher throughput for large allocations done in parallel and at a high rate.

The Go compiler, meanwhile, adds -d=checkptr as a compile-time option for checking that Go code is abiding by unsafe.Pointer safety rules dynamically. Also, the compiler now can emit machine-readable logs of key optimisations using the -json flag, including inlining and bounds-check elimination. Detailed escape analysis diagnostics now work again, and experimental support is offered for compiler-inserted coverage instrumentation for fuzzing.

Other changes and improvements in Go 1.14 include:

  • In an improvement to Go’s WebAssembly support, JavaScript values referenced from Go via js.Value objects now can be garbage-collected. However, js.Value objects no longer can be compared using the == operator. They must instead be compared using the Equal method. Also, js.Value now has IsUndefined, IsNull, and IsNaN methods. 
  • Similar to what is happening with the Rust language, the Go 1.14 release will be the last to support 32-bit binaries on MacOS. It will likely also be the last to support 32-bit binaries on other Apple platforms including iOS, iPadOS, WatchOS, and tvOS.
  • In a language change, embedding of overlapping interfaces is now permitted.
  • Support is discontinued for the Google Native Client platform
  • The 64-bit architecture of FreeBSD is now supported.
  • The go command now supports Subversion repos in module mode. This command also now has snippets of plain-text error messages from module proxies and other HTTP servers. An error message is shown only if it is valid UTF-8 and has only graphic characters and spaces.
  • Binaries on Windows have Data Execution Prevention (DEP) enabled for system-level memory protection.
  • A new flag, -modfile=file, instructs the go command to read and possibly write an alternative go.mod file rather than the one in the module root directory.
  • The go get command no longer accepts the -mod flag.
  • A new flag, -modcacherw, instructs the go command to leave newly created directories in the module cache at default permissions rather than being read-only. This flag makes it more likely that tests or other tools will accidentally add files not in the module’s verified checksum. But it allows the use of rm-rf to remove the module cache.
  • A hash/maphash package provides hash functions on byte sequences.
  • GOINSECURE is a new environment variable that instructs the go command to allow an HTTPS connection to skip certificate validation when fetching certain modules directly from their origins.

Go 1.14 can be downloaded from golang.org

Read More:


Back to Top ↑

TechCentral.ie