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: Windows "high-resolution" timer seems to do the opposite #51530

Closed
CannibalVox opened this issue Mar 7, 2022 · 3 comments
Closed

runtime: Windows "high-resolution" timer seems to do the opposite #51530

CannibalVox opened this issue Mar 7, 2022 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows

Comments

@CannibalVox
Copy link

CannibalVox commented Mar 7, 2022

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

$ go version
go version go1.17 windows/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
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Stephen\AppData\Local\go-build
set GOENV=C:\Users\Stephen\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\msys64\mingw64\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:/msys64/mingw64
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Stephen\projects\testslice\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\msys64\tmp\go-build805753431=/tmp/go-build -gno-record-gcc-switches

What did you do?

Ran this code on any release post-1.16, on windows:

package main

import (
	"fmt"
	"time"
)

func main() {
	t := time.NewTicker(5 * time.Millisecond)
	begin := make(chan bool)
	var count int
	go func() {
		<-begin
		for range t.C {
			count++
		}
	}()
	begin <- true
	time.Sleep(time.Second)
	t.Stop()
	fmt.Println(count)
}

What did you expect to see?

~200ish ticks over the life of the program

What did you see instead?

64 ticks

Additional:

This works correctly on 1.15.15. Probably seems to be introduced in 1.16 It is important to understand the following:

The new code seems to substitute high-resolution timers in place of setting the timer resolution to 1ms at the start of a program. However, my system timer is already set to 1ms and despite that, go sleeps/ticks/etc. are operating at 15.whatever millisecond resolution on my windows system.

@ALTree ALTree added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows labels Mar 7, 2022
@ALTree
Copy link
Member

ALTree commented Mar 7, 2022

Seems like it could be a dup of #44343?

@ALTree
Copy link
Member

ALTree commented Mar 7, 2022

Yeah, I think it is. Closing here, please comment if you think it's not a dup of #44343.

@ALTree ALTree closed this as completed Mar 7, 2022
@CannibalVox
Copy link
Author

I think you're right- thank you very much!

@golang golang locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

3 participants