-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add os.preadv() and os.pwritev() #75549
Comments
Asynchronous, Non-blocking Buffered File Read "RWF_NONBLOCK" flag for os.open() Link: |
preadv2(2) syscall with RWF_NONBLOCK feature is now released starting linux4.14 |
It seems to me there are two issues here:
It's getting late in the game for inclusion in 3.7 with only 2 weeks left until feature freeze. |
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. |
Whoa, cool. bpo-32561 is complementary to this. (They both make sense on their own, but they're even better together.) |
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_ |
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(). |
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. |
FYI in 2013 I proposed to use writev() in the io module, but it was inefficient: bpo-17655. |
Thank you Pablo Galindo for your amazingly hard work. Also Victor Stinner for your guidance, thanks you :) |
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". |
I can't at the moment, i am out of country for couple more months. |
Thanks Pablo Galindo for the new better documentation! (And thanks myself since I wrote the original documentation PR ;-)) |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: