Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alexbozhenko opened this issue Sep 21, 2023 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@alexbozhenko
Copy link
Contributor

alexbozhenko commented Sep 21, 2023

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.

@bcmills bcmills added the compiler/runtime Issues related to the Go compiler and/or runtime. label Sep 21, 2023
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 21, 2023
@ianlancetaylor ianlancetaylor changed the title time: time.Tick resolution on Linux dropped to less than 1ms starting with go 1.16? runtime: time.Tick resolution on Linux dropped to less than 1ms starting with go 1.16? Sep 21, 2023
@ianlancetaylor
Copy link
Contributor

CC @golang/runtime

@prattmic
Copy link
Member

I believe this is #44343. There, resolution is much worse on Windows, but note in the initial comment that Linux is ~1.07ms.

@alexbozhenko
Copy link
Contributor Author

Ah, I see.
In that case, maybe we can update the title in #44343, and add some summary(perhaps link to your comment #44343 (comment), and link to #53824 ?) to the issue body, to save time for other who will stumble upon it?

@prattmic
Copy link
Member

Good point, I've updated the title to include Linux. (Note that the issue body already included Linux).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants