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
release GIL on mmap dealloc #80320
Comments
munmap() can take a long time. I think mmap_object_dealloc can trivially release the GIL around this operation. Something similar was already mentioned in https://bugs.python.org/issue1572968 but a general patch was never provided. The dealloc case alone is significant enough to deserve fixing. |
Your patch is modifying obmalloc. bpo-1572968 is different. It is mmap module. It can use file-backed mmap. It is I/O. |
Sorry, I messed up. Your PR is changing mmap module, not obmalloc. |
Yes, this is mmap module. I found this to be slow for posix-shm-backed mmaps. Several milliseconds, like 20ms for a 128 MB object. Maybe the same can happen with private|anon mmaps? I will follow up with more numbers. |
munmap() of private maps is usually pretty fast but not negligible (2 ms for 1GB). Shared maps are much slower. For some reason, shared maps explicitly backed by POSIX shared memory stand in between but are still pretty slow. If someone cares about file-backed mmaps I can test those too. I thought this is already significant to justify releasing the GIL. This is on Linux 4.4: shared anon mmap 1048576 bytes
|
The change sounds like a good idea and should be backported, too. IIRC mmap() performance also depends on MMU and TLB speed. In the past I have seen paravirtualized systems with poor MMU performance that caused fork() to be slow and Redis to hang. |
This change broke the Windows 7 buildbot: Example: 0:01:34 [ 66/420/1] test_mmap crashed (Exit code 2147483651) -- running: test_tools (1 min 22 sec) Current thread 0x00000de4 (most recent call first): Current thread 0x00000de4 (most recent call first): |
The bug: -- If nobody comes up quickly with a fix, I will revert the change to repair Windows buildbots: PR 12198, as part of the buildbot policy ("revert on failure"). I don't have the bandwidth to dig into this failure. |
""" Oh wow, that's really strange. I'm sure that I wrote "https://..." URL but my URL became "r263026496">https://..." !? 3rd attempt to post the link: Anyway, my link points to my comment: """ PyMem_Free(m_obj->tagname) is called below without holding the GIL: that's illegal. Other move the call to free when the GIL is hold again, or use PyMem_RawFree(). "Warning: The GIL must be held when using these functions. " Note: You can use PYTHONMALLOC=debug or -X dev to reproduce the issue on a Python compiled in release mode. On the #ifdef MS_WINDOWS path of mmap_object_dealloc(). |
Thanks Victor. I think this fixes it #12199 |
BTW should this be backported to 3.7? |
The second commit does fix the regression (I tested manually on Windows with Python compiled in debug mode). |
The links are now fixed (Roundup was getting confused by the rNNNNNN, since it looks like a SVN revision). |
4th attempt (sorry for the spam, it's just to check the Roundup fix!): |
Yeah! Roundup is fixed, thanks Ezio! |
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: