-
-
Notifications
You must be signed in to change notification settings - Fork 32k
release GIL while doing I/O operations in the mmap module #44098
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
Comments
There is a few system I/O calls in the mmap module that |
Logged In: YES Can you come up with the listing of code blocks where it |
I don't know mmap myself but patches are welcome. |
As soon as you're dealing with files (not anonymous mapping), you can get the same type of latency than when using open/read/write...
fsync() can take up to a couple seconds, so we should probably allow threads here (this is done only on VMS).
or in mmap_flush_method():
msycn too can take quite a long time to complete. I can write a patch if someone's willing to review it. |
This shouldn't really care about VMS here. As for the rest, feel free to propose a patch :) However, you'll have to be careful that the internal state of the mmap object remains consistent, such that using it from several threads doesn't crash the interpreter. |
Correction: /we/ shouldn't really care about VMS here. |
Any news? If a patch is not ready, i can work on a patch too. |
I'll add one more system I/O call that's not GIL-wrapped in the mmap module that can take some time: mmap itself. mmap on Linux with MAP_POPULATE (0x8000) as the flags can take quite a bit of time. That's the flag that prefaults the memory range. MAP_POPULATE has been around since Linux 2.5.46. I know that MAP_POPULATE isn't explicitly supported in the module, but mmap.mmap does take arbitrary flags, so it isn't exactly unsupported either. |
This seems stuck, and it’s really old (2006!). @isidentical Could I interest you in providing that patch you mentioned? |
This seems pretty straightforward. The issue mentions other calls in mmapmodule that we could release the GIL on, but those are in methods where we'd need to be careful to ensure that something sensible happens if those are called concurrently. In prior art, note that python#12073 released the GIL for munmap. In a toy benchmark, I see the speed up you'd expect from doing this.
Once the Unix PR lands, should we keep this open hoping someone will do it for Windows, or close it? |
This seems pretty straightforward. The issue mentions other calls in mmapmodule that we could release the GIL on, but those are in methods where we'd need to be careful to ensure that something sensible happens if those are called concurrently. In prior art, note that #12073 released the GIL for munmap. In a toy benchmark, I see the speedup you'd expect from doing this. Automerge-Triggered-By: GH:gvanrossum
The Unix PR has landed and I don't intend to make one for Windows (don't have access to a machine or a use case). This has been open since 2006, so I vote we close it. |
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: