You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What are the pros and cons of adding support for this new mode, e.g. are there any potential gotchas?
Assuming the result of 1 is we should go ahead, then omeone needs to generate a pull request including configure checks as necessary, doc changes and tests.
It's getting late in the game for inclusion in 3.7 with only 2 weeks left until feature freeze.
bpo-32561 is complementary to this. (They both make sense on their own, but they're even better together.)
YoSTEALTH commented on Jan 16, 2018
YoSTEALTHmannequin
MannequinAuthor
More actions
According to this nginx test https://www.nginx.com/blog/thread-pools-boost-performance-9x/ there is a huge boost in performance when using thread poll for File IO. It is postulated that when preadv2() & RWF_NONBLOCK feature are available it would further benefit (latency, thread sync, ...)
I am not a C coder so i can't just jump into this and code this feature (if i could i would have done it long ago). As Antoine mentioned, it needs to written at C (+ctypes) level.
I am willing to help, hit me up on #python user: stealth_
"In this release, the preadv2(2) syscall with RWF_NONBLOCK will let userspace applications bypass enqueuing operation in the threadpool if it's already available in the pagecache."
For applications using a thread pool, like the aiofiles does for asyncio, preadv2() allows to bypass the thread pool which is obviously faster. If the read block, just uses thread pool as currently done.
I set the priority to release blocker to make sure that I don't forget to merge the PR before Python 3.7b1 (next monday?). The PR is *almost* ready, remaining issues are mostly related to documentation and coding style.
Antoine Pitrou: "In any case, I think this would take the form of new low-level calls in the posix module, i.e. add thin wrappers around the new system / libc calls."
"new system / libc calls"... well, preadv() is available on FreeBSD since FreeBSD 6 :-) And preadv() and pwritev() first appeared in Linux 2.6.30; library support was added in glibc 2.10. It's not really something "new".
It seems like the two functions became more interesting for Python since Linux implemented the new RWF_NONBLOCK flag. aiofiles can be used to bypass its thread-pool, for better performances.
If I understand the discussion on the PR properly, Victor would like to revisit the documentation for this PR but is OK with the code as merged. I'm therefore downgrading this to "deferred blocker". Please try to get the issue closed one way or another prior to 3.7.0b2, thanks!
As far as I can tell, this issue is still open only because of the original desire to expand the original documentation. YoSTEALTH produced PR 5447 based on Victor's original doc update PR. In the meantime, the current 3.7 docs have been updated somewhat. YoSTEALTH, if you would be willing to update PR 5467 perhaps we can get it reviewed and merged and close this issue. In any case, I'm lowering the priority from "deferred blocker".
Activity
YoSTEALTH commentedon Sep 6, 2017
Asynchronous, Non-blocking Buffered File Read
"RWF_NONBLOCK" flag for os.open()
Link:
https://lwn.net/Articles/612483/
https://lwn.net/Articles/613068/
https://lwn.net/Articles/636967/
YoSTEALTH commentedon Jan 13, 2018
preadv2(2) syscall with RWF_NONBLOCK feature is now released starting linux4.14
https://kernelnewbies.org/Linux_4.14#Asynchronous_buffered_I.2FO_support
ned-deily commentedon Jan 15, 2018
It seems to me there are two issues here:
What are the pros and cons of adding support for this new mode, e.g. are there any potential gotchas?
Assuming the result of 1 is we should go ahead, then omeone needs to generate a pull request including configure checks as necessary, doc changes and tests.
It's getting late in the game for inclusion in 3.7 with only 2 weeks left until feature freeze.
[-]RWF_NONBLOCK[/-][+]Support asynchronous, non-blocking buffered reads (RWF_NONBLOCK)[/+]pitrou commentedon Jan 16, 2018
In any case, I think this would take the form of new low-level calls in the posix module, i.e. add thin wrappers around the new system / libc calls.
njsmith commentedon Jan 16, 2018
Whoa, cool.
bpo-32561 is complementary to this. (They both make sense on their own, but they're even better together.)
YoSTEALTH commentedon Jan 16, 2018
According to this nginx test https://www.nginx.com/blog/thread-pools-boost-performance-9x/ there is a huge boost in performance when using thread poll for File IO. It is postulated that when preadv2() & RWF_NONBLOCK feature are available it would further benefit (latency, thread sync, ...)
I am not a C coder so i can't just jump into this and code this feature (if i could i would have done it long ago). As Antoine mentioned, it needs to written at C (+ctypes) level.
I am willing to help, hit me up on #python user: stealth_
vstinner commentedon Jan 23, 2018
Explanation for myself.
https://kernelnewbies.org/Linux_4.14#Asynchronous_buffered_I.2FO_support
"In this release, the preadv2(2) syscall with RWF_NONBLOCK will let userspace applications bypass enqueuing operation in the threadpool if it's already available in the pagecache."
For applications using a thread pool, like the aiofiles does for asyncio, preadv2() allows to bypass the thread pool which is obviously faster. If the read block, just uses thread pool as currently done.
Same rationale for pwritev2().
vstinner commentedon Jan 27, 2018
I set the priority to release blocker to make sure that I don't forget to merge the PR before Python 3.7b1 (next monday?). The PR is *almost* ready, remaining issues are mostly related to documentation and coding style.
vstinner commentedon Jan 27, 2018
Antoine Pitrou: "In any case, I think this would take the form of new low-level calls in the posix module, i.e. add thin wrappers around the new system / libc calls."
"new system / libc calls"... well, preadv() is available on FreeBSD since FreeBSD 6 :-) And preadv() and pwritev() first appeared in Linux 2.6.30; library support was added in glibc 2.10. It's not really something "new".
It seems like the two functions became more interesting for Python since Linux implemented the new RWF_NONBLOCK flag. aiofiles can be used to bypass its thread-pool, for better performances.
[-]Support asynchronous, non-blocking buffered reads (RWF_NONBLOCK)[/-][+]Add os.preadv() and os.pwritev()[/+]vstinner commentedon Jan 27, 2018
FYI in 2013 I proposed to use writev() in the io module, but it was inefficient: bpo-17655.
vstinner commentedon Jan 27, 2018
New changeset 4defba3 by Victor Stinner (Pablo Galindo) in branch 'master':
bpo-31368: Expose preadv and pwritev in the os module (bpo-5239)
4defba3
YoSTEALTH commentedon Jan 27, 2018
Thank you Pablo Galindo for your amazingly hard work. Also Victor Stinner for your guidance, thanks you :)
ned-deily commentedon Jan 28, 2018
If I understand the discussion on the PR properly, Victor would like to revisit the documentation for this PR but is OK with the code as merged. I'm therefore downgrading this to "deferred blocker". Please try to get the issue closed one way or another prior to 3.7.0b2, thanks!
ned-deily commentedon May 24, 2018
As far as I can tell, this issue is still open only because of the original desire to expand the original documentation. YoSTEALTH produced PR 5447 based on Victor's original doc update PR. In the meantime, the current 3.7 docs have been updated somewhat. YoSTEALTH, if you would be willing to update PR 5467 perhaps we can get it reviewed and merged and close this issue. In any case, I'm lowering the priority from "deferred blocker".
YoSTEALTH commentedon May 30, 2018
I can't at the moment, i am out of country for couple more months.
vstinner commentedon May 30, 2018
New changeset 02e2a08 by Victor Stinner (Pablo Galindo) in branch 'master':
bpo-31368: Enhance os.preadv() documentation (GH-7254)
02e2a08
miss-islington commentedon May 30, 2018
New changeset 0e823c6 by Miss Islington (bot) in branch '3.7':
bpo-31368: Enhance os.preadv() documentation (GH-7254)
0e823c6
vstinner commentedon May 30, 2018
Thanks Pablo Galindo for the new better documentation! (And thanks myself since I wrote the original documentation PR ;-))