Re: [go-nuts] performance optimization

2019-01-16 Thread Jesper Louis Andersen
On Wed, Jan 16, 2019 at 11:55 AM Wojciech S. Czarnecki wrote: > You can't expect a million interrupts per second and host OS running > simultaneously. > (1us gives some 4k instructions inbetween on recent 3GHz cpu core) > > And to add: if you do anything with memory, it is usually considerably

Re: [go-nuts] performance optimization

2019-01-16 Thread Wojciech S. Czarnecki
On Mon, 14 Jan 2019 21:34:34 +0100 Tamás Király wrote: > I'm simulating the internal clock of an embedded microcontroller... You can't expect a million interrupts per second and host OS running simultaneously. (1us gives some 4k instructions inbetween on recent 3GHz cpu core) Usual way for

Re: [go-nuts] performance optimization

2019-01-15 Thread Andrei Avram
Not sure what your need is, but maybe you need time.Since instead of saving the start time and substracting it from time.Now. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send

Re: [go-nuts] performance optimization

2019-01-14 Thread Tamás Király
thanks for the suggestions and notes, i threw out the loop, save the start timestamp and call time.Now()-start when i need the value which is in the second range. - Tamás David Anderson ezt írta (időpont: 2019. jan. 14., H, 21:54): > Note that even for a state of the art CPU, there's only a

Re: [go-nuts] performance optimization

2019-01-14 Thread David Anderson
Note that even for a state of the art CPU, there's only a few thousand instructions in a microsecond (1000 cycles per microsecond per GHz). At that kind of performance, anything you do that involves the OS or context-switching will make it impossible to hit your target refresh rate. The closest

Re: [go-nuts] performance optimization

2019-01-14 Thread robert engels
If you are going to use time.Now() and a ‘change loop’, you should probably lock the thread to the Go routine to avoid an scheduler thrashing. > On Jan 14, 2019, at 2:34 PM, Tamás Király wrote: > > I'm simulating the internal clock of an embedded microcontroller... And this > sentence (and

Re: [go-nuts] performance optimization

2019-01-14 Thread Tamás Király
I'm simulating the internal clock of an embedded microcontroller... And this sentence (and you!) gave the idea to use time.Now(). Thanks! Tamas 9. jan. 14., H 21:12 dátummal Matt Ho ezt írta: > Can you describe what task it is that needs to be updated every > microsecond? It seems like there

Re: [go-nuts] performance optimization

2019-01-14 Thread Matt Ho
Can you describe what task it is that needs to be updated every microsecond? It seems like there should be a better to resolve the underlying need. M -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop

Re: [go-nuts] performance optimization

2018-12-20 Thread robert engels
I updated the github issue with some additional performance comparisons and notes. I think there are some pretty trivial solutions for high frequency pollers, at least those using time.Sleep() > On Dec 19, 2018, at 10:03 PM, Robert Engels wrote: > > Then something is broken on the

Re: [go-nuts] performance optimization

2018-12-19 Thread robert engels
Isn’t doesn’t even need to be that complex, the following uses 1.25 cores at 100% on my machine: package main import "time" func main() { counter := 0 for { counter++ time.Sleep(time.Microsecond) } } even if you change it to 100 usecs, which is only 10,000 times a second,

Re: [go-nuts] performance optimization

2018-12-19 Thread Ian Lance Taylor
On Wed, Dec 19, 2018 at 1:29 PM Tamás Király wrote: > > my task is to update a value every microsecond. > i did an it with an infinite loop with time.Sleep like this > > https://play.golang.org/p/JiN3_5KiGOO > > this causes me about 50-60% of CPU usage on my machine but i made another > version

[go-nuts] performance optimization

2018-12-19 Thread Tamás Király
hi! my task is to update a value every microsecond. i did an it with an infinite loop with *time.Sleep* like this https://play.golang.org/p/JiN3_5KiGOO this causes me about 50-60% of CPU usage on my machine but i made another version with *time.After*: https://play.golang.org/p/PQHsNq261qZ