DEV Community

Julian-Chu
Julian-Chu

Posted on

Go 1.19 beta1

#go

Compared to 1.18, 1.19 is not a big release, but something still catches my eye.

Memory Model

The Go memory model has been revised to align Go with the memory model used by C, C++, Java, JavaScript, Rust, and Swift. Go only provides sequentially consistent atomics, not any of the more relaxed forms found in other languages

Doc Comments

support for links, lists, and clearer headings in doc comments

Go runtime

file descriptor

automatically increase the open file limit (RLIMIT_NOFILE) to the maximum allowed value

new env: GOMEMLIMIT

The runtime now includes support for a soft memory limit. This memory limit includes the Go heap and all other memory managed by the runtime, and excludes external memory sources such as mappings of the binary itself, memory managed in other languages, and memory held by the operating system on behalf of the Go program

it's possible to avoid/reduce OOM kill of golang app by env. Looking forward to reading the GC guide

self-adaptive initial stack size( before is fixed 2KB):

allocate initial goroutine stacks based on the historic average stack usage of goroutines

Compiler

jump table for large integer and string switch statements. Performance improvements for the switch statement vary but can be on the order of 20% faster. (GOARCH=amd64 and GOARCH=arm64 only)

modern CPUs do branch prediction for performance, but instead when the prediction fails too often, the performance becomes worse, introduce branchless(jump table) to avoid branch prediction to get better performance.

IMHO go memory model and the GC guide worth to spend some time to read.

Discussion (0)