Nathaniel Smith <n...@pobox.com> added the comment:

The idea here is *not* to avoid using a thread pool in general. When the data 
is on disk, using a thread pool is (a) unavoidable, because of how operating 
system kernels are written, and (b) basically fine anyway, because the overhead 
added by threads is swamped by the cost of disk access. So for the foreseeable 
future, we're always going to be using a thread pool for actual disk access.

But, if the data *is already in memory*, so the read can succeed without 
hitting the disk, then using a thread pool is *not* fine. Fetching data out of 
memory is super super cheap, so if that's all we're doing then using a thread 
pool adds massive overhead, in relative terms. We'd like to skip using the 
thread pool *specifically in this case*.

So the idea would be: first, attempt a "buffer-only" read. If it succeeds, then 
great we're done and it was really cheap. Otherwise, if it fails, then we know 
we're in the data-on-disk case, so we dispatch the operation to the thread pool.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32561>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to