Skip to content

Commit

Permalink
gh-44098: Release the GIL during mmap on Unix (GH-98146)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hauntsaninja authored and pull[bot] committed Oct 19, 2022
1 parent b322660 commit 68e8740
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
@@ -0,0 +1 @@
Release the GIL when creating :class:`mmap.mmap` objects on Unix.
6 changes: 3 additions & 3 deletions Modules/mmapmodule.c
Expand Up @@ -1318,9 +1318,9 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
}
}

m_obj->data = mmap(NULL, map_size,
prot, flags,
fd, offset);
Py_BEGIN_ALLOW_THREADS
m_obj->data = mmap(NULL, map_size, prot, flags, fd, offset);
Py_END_ALLOW_THREADS

if (devzero != -1) {
close(devzero);
Expand Down

0 comments on commit 68e8740

Please sign in to comment.