]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-90815: Add mimalloc memory allocator (#109914)
authorDino Viehland <dinoviehland@fb.com>
Mon, 30 Oct 2023 15:43:11 +0000 (08:43 -0700)
committerGitHub <noreply@github.com>
Mon, 30 Oct 2023 15:43:11 +0000 (15:43 +0000)
commit05f2f0ac92afa560315eb66fd6576683c7f69e2d
treea6a4746103a67f06f04ff6df9f290f0305ff9dd5
parent4ebf2fae9664a4042511059627f44d46dceb2e09
gh-90815: Add mimalloc memory allocator (#109914)

* Add mimalloc v2.12

Modified src/alloc.c to remove include of alloc-override.c and not
compile new handler.

Did not include the following files:

 - include/mimalloc-new-delete.h
 - include/mimalloc-override.h
 - src/alloc-override-osx.c
 - src/alloc-override.c
 - src/static.c
 - src/region.c

mimalloc is thread safe and shares a single heap across all runtimes,
therefore finalization and getting global allocated blocks across all
runtimes is different.

* mimalloc: minimal changes for use in Python:

 - remove debug spam for freeing large allocations
 - use same bytes (0xDD) for freed allocations in CPython and mimalloc
   This is important for the test_capi debug memory tests

* Don't export mimalloc symbol in libpython.
* Enable mimalloc as Python allocator option.
* Add mimalloc MIT license.
* Log mimalloc in Lib/test/pythoninfo.py.
* Document new mimalloc support.
* Use macro defs for exports as done in:
  https://github.com/python/cpython/pull/31164/

Co-authored-by: Sam Gross <colesbury@gmail.com>
Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Victor Stinner <vstinner@python.org>
61 files changed:
Doc/c-api/init_config.rst
Doc/c-api/memory.rst
Doc/license.rst
Doc/using/cmdline.rst
Doc/using/configure.rst
Include/cpython/pymem.h
Include/internal/mimalloc/mimalloc.h [new file with mode: 0644]
Include/internal/mimalloc/mimalloc/atomic.h [new file with mode: 0644]
Include/internal/mimalloc/mimalloc/internal.h [new file with mode: 0644]
Include/internal/mimalloc/mimalloc/prim.h [new file with mode: 0644]
Include/internal/mimalloc/mimalloc/track.h [new file with mode: 0644]
Include/internal/mimalloc/mimalloc/types.h [new file with mode: 0644]
Include/internal/pycore_mimalloc.h [new file with mode: 0644]
Include/internal/pycore_pymem_init.h
Lib/test/pythoninfo.py
Lib/test/support/__init__.py
Lib/test/test_cmd_line.py
Makefile.pre.in
Misc/NEWS.d/next/Core and Builtins/2023-09-06-12-36-11.bpo-46657.xea1T_.rst [new file with mode: 0644]
Modules/_testcapi/mem.c
Objects/mimalloc/alloc-aligned.c [new file with mode: 0644]
Objects/mimalloc/alloc-override.c [new file with mode: 0644]
Objects/mimalloc/alloc-posix.c [new file with mode: 0644]
Objects/mimalloc/alloc.c [new file with mode: 0644]
Objects/mimalloc/arena.c [new file with mode: 0644]
Objects/mimalloc/bitmap.c [new file with mode: 0644]
Objects/mimalloc/bitmap.h [new file with mode: 0644]
Objects/mimalloc/heap.c [new file with mode: 0644]
Objects/mimalloc/init.c [new file with mode: 0644]
Objects/mimalloc/options.c [new file with mode: 0644]
Objects/mimalloc/os.c [new file with mode: 0644]
Objects/mimalloc/page-queue.c [new file with mode: 0644]
Objects/mimalloc/page.c [new file with mode: 0644]
Objects/mimalloc/prim/osx/alloc-override-zone.c [new file with mode: 0644]
Objects/mimalloc/prim/osx/prim.c [new file with mode: 0644]
Objects/mimalloc/prim/prim.c [new file with mode: 0644]
Objects/mimalloc/prim/readme.md [new file with mode: 0644]
Objects/mimalloc/prim/unix/prim.c [new file with mode: 0644]
Objects/mimalloc/prim/wasi/prim.c [new file with mode: 0644]
Objects/mimalloc/prim/windows/etw-mimalloc.wprp [new file with mode: 0644]
Objects/mimalloc/prim/windows/etw.h [new file with mode: 0644]
Objects/mimalloc/prim/windows/etw.man [new file with mode: 0644]
Objects/mimalloc/prim/windows/prim.c [new file with mode: 0644]
Objects/mimalloc/prim/windows/readme.md [new file with mode: 0644]
Objects/mimalloc/random.c [new file with mode: 0644]
Objects/mimalloc/segment-map.c [new file with mode: 0644]
Objects/mimalloc/segment.c [new file with mode: 0644]
Objects/mimalloc/static.c [new file with mode: 0644]
Objects/mimalloc/stats.c [new file with mode: 0644]
Objects/obmalloc.c
PCbuild/_freeze_module.vcxproj
PCbuild/_freeze_module.vcxproj.filters
PCbuild/pyproject.props
PCbuild/pythoncore.vcxproj
PCbuild/pythoncore.vcxproj.filters
Tools/build/smelly.py
Tools/c-analyzer/cpython/_files.py
Tools/c-analyzer/cpython/_parser.py
configure
configure.ac
pyconfig.h.in