each go routine only handle less than 10 events concurrently, why you said 
it's 100?

I found if serverDone is not globally defined, the result is better, but 
still not as expected.

在 2017年2月6日星期一 UTC+8上午3:00:15,[email protected]写道:
>
> I make a test to see the performance of select, and found the result is 
> not good.
>
> I make 1000 SeqQueue objects and run its messageLoop function (which does 
> a small piece of work, and is listed as below) in 1000 separate go 
> routines. The CPU cost is more than 20%.
> If I make the ticker 1 second, the CPU cost can slow down to about 2%.
>
> With pprof, I see the most top cost are methods related to 
> runtime.selectGo, runtime.lock.
>
> Who knows is there anything wrong in my case?
>
> func (this *SeqQueue) messageLoop() {
> var ticker = time.NewTicker(100 * time.Millisecond)
> defer ticker.Stop()
> for {
> select {
> case <-serverDone:
> return
> case <-this.done:
> return
> case <-ticker.C:
> this.tickCounter += 1
> case message := <-this.messages:
> this.messageCounter += 1
> _ = message
> }
> }
> }
>
>
>
>

-- 
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 an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to