Go 1.20 unveils profile-guided optimization Computerworld

Previewed in Go 1.20, this feature allows the compiler to perform application and workload specific optimizations based on runtime profile information.

Now at release candidate stage, this planned update to Go, the open source language developed by Google and renowned for its simplicity, concurrency, and functional programming features previews Profile Guided Optimization (PGO) for the compiler. Announced on December 7, the Go 1.20 release candidate can be downloaded from go.dev. The production version is expected in February 2023.

This release’s anticipated profile-guided optimization support allows the compiler toolchain to perform application- and workload-specific enhancements based on runtime profile data. Currently, the compiler supports pprof CPU profiles, which can be collected via runtime/pprof or net/http/pprof packages. Version 1.20 uses PGO to more aggressively inline functions where the calls are most important. Benchmarks for a representative set of Go programs show that enabling PGO’s online optimization improves performance by approximately 3-4%. Further PGO optimizations are planned for future releases.

Changes in the language

In addition, Go 1.20 introduces four language changes. First, the ability to convert slice to array pointer, an improvement made in Go 1.17 that shipped in 2021, has been extended to convert slice to array conversions, according to the draft release notes. Second, the package unsafe defines three other functions: SliceData, Stringand StringData. They provide the full ability to construct and deconstruct slide and string values ​​without depending on the exact representation.

Third, the specification now defines that the values structure are compared one field at a time, considering the fields in the order they appear in the type definition structure and stopping at the first discrepancy. Finally, comparable types like ordinary interfaces can now satisfy the comparable constraints, even if the type arguments are not strictly comparable. This allows the instantiation of a comparable-constrained type parameter with a non-strictly comparable type argument such as an interface type, or a composite type containing an interface type.

Other innovations

Other new features in Go 1.20:

– The runtime adds experimental support for memory-safe arena allocation that quickly releases memory in large quantities. This could improve CPU performance.

– Collection of code coverage profiles for programs is supported, including for applications and integration tests, as opposed to just unit tests.

– The directory $GOROOT/pkg no longer stores precompiled package activities for the standard library. Now, library packages are built as needed and cached in the build cache. This reduces the size of the Go distribution and avoids C toolchain imbalance for packages that use cgo.

– The implementation of gotest-json has been improved to be more robust. Programs that run gotest-json do not need to be updated.

– The command gocode now defines build tags for architecture features.

– The command go now disable cgo by default on systems without a C toolchain.

– The command go version -m now supports reading more types of Go binaries, including Windows DLLs built with go build-buildmode=c shared and Linux binaries without execute permission.

– Experimental support has been added for FreeBSD on RISC-V.

– Go 1.20 will be the last version to run on macOS 10.13 High Sierra or 10.14 Mojave. Go 1.21 will require macOS 10.15 Catalina or later.

Go 1.20 follows Go 1.19 released on August 2, which improved the generics and the memory model.

We would love to thank the author of this article for this remarkable web content

Go 1.20 unveils profile-guided optimization Computerworld


You can find our social media profiles as well as other pages that are related to them.https://yaroos.com/related-pages/