On Wed, Jun 29, 2016 at 1:28 PM, Tathagata <
event...@gmail.com> wrote:
>
> I'm measuring the context switch overhead for go routines and I have a
> question regarding the netpoller mechanism. I read online that the netpoller
> lives in its own thread, and responds to IO events. I thought this meant
> that there's a separate machine thread that keeps polling the set of FDs and
> requeues go routines whose IO has completed.
That is not how it works.
> But looking at the source code, it looks like the netpoller is only
> explicitly invoked by the runtime scheduler, when it has nothing else in its
> local runqueue. So does a go routine which was initially waiting for IO,
> will not be moved to the runqueue until the next time the scheduler is run?
That is roughly correct. Note that the scheduler is run every time a
goroutine blocks. And note that the sysmon thread ensures that the
network is polled at least every 10ms.
Ian