Author vstinner
Recipients YoSTEALTH, benjamin.peterson, giampaolo.rodola, martin.panter, njs, pitrou, stutzbach, vstinner, xgdomingo
Date 2019-10-10.08:34:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570696496.93.0.216127922464.issue32561@roundup.psfhosted.org>
In-reply-to
Content
> 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.
History
Date User Action Args
2019-10-10 08:34:56vstinnersetrecipients: + vstinner, pitrou, giampaolo.rodola, benjamin.peterson, stutzbach, njs, martin.panter, YoSTEALTH, xgdomingo
2019-10-10 08:34:56vstinnersetmessageid: <1570696496.93.0.216127922464.issue32561@roundup.psfhosted.org>
2019-10-10 08:34:56vstinnerlinkissue32561 messages
2019-10-10 08:34:56vstinnercreate