Re: [go-nuts] Periodic task when time.Ticker and time.Sleep are pretty expensive

2018-09-17 Thread Lei Ni
Thanks everyone for looking into this. I've raised an issue https://github.com/golang/go/issues/27707 On Monday, September 17, 2018 at 4:29:15 PM UTC+8, Dave Cheney wrote: > > I've confirmed this uses 14% on a random OS X machine. Please raise a bug, > https://golang.org/issue/new > > On Monda

Re: [go-nuts] Periodic task when time.Ticker and time.Sleep are pretty expensive

2018-09-17 Thread Dave Cheney
I've confirmed this uses 14% on a random OS X machine. Please raise a bug, https://golang.org/issue/new On Monday, 17 September 2018 14:29:44 UTC+10, Robert Engels wrote: > > For reference, similar code under Java consumes 2.5 % CPU. > > I tested the Go code under OSX, and it is roughly 10%, whic

Re: [go-nuts] Periodic task when time.Ticker and time.Sleep are pretty expensive

2018-09-16 Thread robert engels
For reference, similar code under Java consumes 2.5 % CPU. I tested the Go code under OSX, and it is roughly 10%, which seems to be very high. Might be because the “context switching” is performed/attributed to the process (since it is internal), where for other systems it is the system call on

Re: [go-nuts] Periodic task when time.Ticker and time.Sleep are pretty expensive

2018-09-16 Thread Lei Ni
Thanks for the input Jan! When running the following exact code, I saw 20% %CPU in top as well, measured on a single socket E5-2696v4 server without any vm/container/CPU intensive task. package main import ( "time" ) func main() { ticker := time.NewTicker(time.Millisecond) defer tick

Re: [go-nuts] Periodic task when time.Ticker and time.Sleep are pretty expensive

2018-09-16 Thread Jan Mercl
On Sun, Sep 16, 2018 at 10:49 AM Lei Ni wrote: func main() { ... for { select { case <-ticker.C: // call my function here } } } Is the above the actual code you're using for the CPU usage "benchmark"?