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: FreeBSD time.Tick(time.Millisecond) ticks every two milliseconds #7274

Closed
dustin opened this issue Feb 6, 2014 · 6 comments
Closed

time: FreeBSD time.Tick(time.Millisecond) ticks every two milliseconds #7274

dustin opened this issue Feb 6, 2014 · 6 comments

Comments

@dustin
Copy link

@dustin dustin commented Feb 6, 2014

Output of the following program:

21:34:14.577072 t = 2014-02-05 21:34:14.576613081 -0800 PST
21:34:14.578735 t = 2014-02-05 21:34:14.57862239 -0800 PST
21:34:14.580640 t = 2014-02-05 21:34:14.580601877 -0800 PST
21:34:14.582617 t = 2014-02-05 21:34:14.582587231 -0800 PST
21:34:14.584643 t = 2014-02-05 21:34:14.584580407 -0800 PST



package main

import (
    "log"
    "os"
    "time"
)

func main() {
    time.AfterFunc(10*time.Millisecond, func() { os.Exit(0) })

    log.SetFlags(log.Lmicroseconds)
    for t := range time.Tick(time.Millisecond) {
        log.Printf("t = %v\n", t)
    }
}
@dustin
Copy link
Author

@dustin dustin commented Feb 6, 2014

Comment 1:

Forgot to mention:  go version go1.2 freebsd/amd64
@dvyukov
Copy link
Member

@dvyukov dvyukov commented Feb 6, 2014

Comment 2:

Does it work differently in C? It can be scheduling limitation of the OS.
@dustin
Copy link
Author

@dustin dustin commented Feb 6, 2014

Comment 3:

It does seem to be an issue with the default OS scheduling config.  Setting kern.hz =
10000 gets me more regular ticks.
@davecheney
Copy link
Contributor

@davecheney davecheney commented Feb 6, 2014

Comment 4:

Interesting, 
here is a random FBSD 9.1 system
[dfc@deadwood ~/src]$ go run x.go 
16:06:53.532294 t = 2014-02-06 16:06:53.532141414 +1100 EST
16:06:53.534191 t = 2014-02-06 16:06:53.534140885 +1100 EST
16:06:53.536190 t = 2014-02-06 16:06:53.536141334 +1100 EST
16:06:53.538108 t = 2014-02-06 16:06:53.538091429 +1100 EST
16:06:53.540126 t = 2014-02-06 16:06:53.540107522 +1100 EST
[dfc@deadwood ~/src]$ uname -a
FreeBSD deadwood.local 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10
UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
@dvyukov
Copy link
Member

@dvyukov dvyukov commented Feb 6, 2014

Comment 5:

If it will make you happier, by default windows ticks are 15ms (however we bring it down
to 1ms with a special system call with system-wide effect).
So 2ms is not that bad.
@davecheney
Copy link
Contributor

@davecheney davecheney commented Feb 24, 2014

Comment 6:

Whelp, there you go.

Status changed to WontFix.

@dustin dustin added the wontfix label Feb 24, 2014
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.