STINNER Victor <vstin...@python.org> added the comment:

> Background: Doing I/O to files on disk has a hugely bimodal latency. If the 
> I/O happens to be in or going to cache (either user-space cache, like in 
> io.BufferedIOBase, or the OS's page cache), then the operation returns 
> instantly (~1 µs) without blocking. OTOH if the I/O isn't cached (for reads) 
> or cacheable (for writes), then the operation may block for 10 ms or more.

On Linux 4.14 and newer, Python 3.8 now provides os.preadv(os.RWF_NOWAIT):

"Do not wait for data which is not immediately available. If this flag is 
specified, the system call will return instantly if it would have to read data 
from the backing storage or wait for a lock. If some data was successfully 
read, it will return the number of bytes read. If no bytes were read, it will 
return -1 and set errno to errno.EAGAIN."

At least on recent Linux, it became possible to write a different code path for 
uncached data.

----------
nosy: +vstinner

_______________________________________
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