[Python-ideas] Tulip / PEP 3156 event loop implementation question: CPU vs. I/O starvation

Nick Coghlan ncoghlan at gmail.com
Sat Jan 12 04:20:40 CET 2013


On Sat, Jan 12, 2013 at 1:08 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> On Sat, Jan 12, 2013 at 9:41 AM, Guido van Rossum <guido at python.org> wrote:
>> So what's more important? Avoid I/O starvation at all cost or make the
>> callbacks-posting-callbacks pattern efficient? I can see several
>> outcomes of this discussion: we could end up deciding that one or the
>> other strategy is always best; we could also leave it up to the
>> implementation (but then I still would want guidance for what to do in
>> Tulip); we could even decide this is so important that the user needs
>> to be able to control the policy here (though I hate having many
>> configuration options, since in practice few people bother to take
>> control, and you might as well have hard-coded the default...).
>>
>> Thoughts? Do I need to explain it better?
>
> Given the availability of "yield from" as a tool for efficiently
> invoking other asynchronous operations without hitting the event loop
> at all, it seems to me that it is more appropriate to avoid IO
> starvation by interleaving IO event processing and ready callback
> processing.

Oops, I meant to include a link to http://bugs.python.org/issue7946,
which is about the convoy effect created by the GIL implementation
when I/O bound threads are processed in the presence of a CPU bound
thread (essentially, the I/O latency increases to the GIL check
interval). (The thing that changed in 3.2 is that the magnitude of the
convoy effect is now independent of the work-per-bytecode in the CPU
bound thread)

That's what makes me think always alternating between processing ready
callbacks and checking for IO events is the right thing to do.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list