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

Time.sleep and Ticker bug in 1.16 #44476

Closed
konethmelathil opened this issue Feb 21, 2021 · 2 comments
Closed

Time.sleep and Ticker bug in 1.16 #44476

konethmelathil opened this issue Feb 21, 2021 · 2 comments

Comments

@konethmelathil
Copy link

konethmelathil commented Feb 21, 2021

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

1.16

$ go version
I was using 1.16 and then switched back to 1.15.8 windows/amd64

This does not appear to be a issue in go version go1.16 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

Windows 10 / amd64

go env Output
$ go env

Output generated after reverting back to 1.15.8:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\user1\AppData\Local\go-build
set GOENV=C:\Users\user1\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=c:\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=c:\gopath
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 GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\user1\IdeaProjects\test\source\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:\Users\user1\AppData\Local\Temp\go-build037891810=/tmp/go-build -gno-record-gcc-switches

What did you do?

Used time.sleep in a for ever loop generating data into a channel. Modfied the code below to be only 10000 generations. My rate was 5000 per second in go 1.15.8 but dropped to 200 in 1.16 and went back to 5000 when I reinstalled 1.15.8.

package main

import (
	"fmt"
	"time"
)

func main() {
mychan:= make(chan string, 5000)

go func(){

  for i:=0; i<10000;i++ {
    select {
      case foo:= <- mychan:
      fmt.Printf(foo)
    }
  }

}()


for {
   foo := "bar"
   time.Sleep(500 * time.Nanosecond)
   mychan<- foo
  }

}

What did you expect to see?

Higher rate of generation and submission into channel. Ticker also is affected as though time resolution is impacted in 1.16.
Channel queuing is not the problem. It is in the the Sleep function.

What did you see instead?

Lower rate. Time.Sleep and Ticker functionality appears impaired when tasked with high resolution function with durations in the Nanosecond or Microsecond range. This is NOT the case with 1.15.8 and below!

@konethmelathil konethmelathil changed the title Time.sleep bug in 1.16 Time.sleep and Ticker bug in 1.16 Feb 21, 2021
@tmthrgd
Copy link
Contributor

tmthrgd commented Feb 21, 2021

This is a duplicate of #44343.

@seankhliao
Copy link
Member

Duplicate of #44343

@seankhliao seankhliao marked this as a duplicate of #44343 Feb 21, 2021
@golang golang locked and limited conversation to collaborators Feb 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants