Skip to content

runtime: time.Tick resolution on Linux dropped to less than 1ms starting with go 1.16?  #63145

Closed as not planned
@alexbozhenko

Description

@alexbozhenko

What version of Go are you using (go version)?

$ go version
go version go1.21.1 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/abozhenko/.cache/go-build'
GOENV='/home/abozhenko/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/abozhenko/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/abozhenko/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/abozhenko/tmp/slow_tick/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build468578710=/tmp/go-build -gno-record-gcc-switches'
uname -sr: Linux 5.4.0-1063-aws
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:        20.04
Codename:       focal
/lib/x86_64-linux-gnu/libc.so.6: GNU C Library (Ubuntu GLIBC 2.31-0ubuntu9.9) stable release version 2.31.
lldb --version: lldb version 10.0.0
gdb --version: GNU gdb (Ubuntu 10.2-0ubuntu1~20.04~1) 10.2

What did you do?

  1. Save main.go and go.mod from https://go.dev/play/p/N0GinbmwtDI
  2. Run:
for v in {3..10} {12..14} 15.15 16 16.15 17.13 18.10 19.13 20.7 21.1; do GOTOOLCHAIN=go1.$v go run main.go; done
    go1.3: got 1000 ticks in 1s time
    go1.4: got  999 ticks in 1s time
    go1.5: got 1000 ticks in 1s time
    go1.6: got  999 ticks in 1s time
    go1.7: got  999 ticks in 1s time
    go1.8: got  999 ticks in 1s time
    go1.9: got  999 ticks in 1s time
   go1.10: got  999 ticks in 1s time
   go1.12: got  999 ticks in 1s time
   go1.13: got  999 ticks in 1s time
   go1.14: got  999 ticks in 1s time
go1.15.15: got  999 ticks in 1s time
   go1.16: got  889 ticks in 1s time  <- drop here
go1.16.15: got  895 ticks in 1s time
go1.17.13: got  890 ticks in 1s time
go1.18.10: got  872 ticks in 1s time
go1.19.13: got  867 ticks in 1s time
 go1.20.7: got  893 ticks in 1s time
 go1.21.1: got  881 ticks in 1s time

What did you expect to see?

About 1000 ticks in all Go versions?

What did you see instead?

Starting with go 1.16 we got 5-10% less ticks.
I reproduced it both on amd64 and arm64 AWS VMs, and on amd64 linux laptop.

I found two issues that seem somewhat related:
#44343 (but that one is specifically about Windows, right?)
#53824
But it doesn't look to me that this one is exactly a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions