mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
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>
This commit is contained in:
parent
4ebf2fae96
commit
05f2f0ac92
61 changed files with 16792 additions and 161 deletions
|
@ -253,11 +253,21 @@ PyPreConfig
|
|||
* ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` (``6``): :ref:`Python pymalloc
|
||||
memory allocator <pymalloc>` with :ref:`debug hooks
|
||||
<pymem-debug-hooks>`.
|
||||
* ``PYMEM_ALLOCATOR_MIMALLOC`` (``6``): use ``mimalloc``, a fast
|
||||
malloc replacement.
|
||||
* ``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` (``7``): use ``mimalloc``, a fast
|
||||
malloc replacement with :ref:`debug hooks <pymem-debug-hooks>`.
|
||||
|
||||
|
||||
``PYMEM_ALLOCATOR_PYMALLOC`` and ``PYMEM_ALLOCATOR_PYMALLOC_DEBUG`` are
|
||||
not supported if Python is :option:`configured using --without-pymalloc
|
||||
<--without-pymalloc>`.
|
||||
|
||||
``PYMEM_ALLOCATOR_MIMALLOC`` and ``PYMEM_ALLOCATOR_MIMALLOC_DEBUG`` are
|
||||
not supported if Python is :option:`configured using --without-mimalloc
|
||||
<--without-mimalloc>` or if the underlying atomic support isn't
|
||||
available.
|
||||
|
||||
See :ref:`Memory Management <memory>`.
|
||||
|
||||
Default: ``PYMEM_ALLOCATOR_NOT_SET``.
|
||||
|
|
|
@ -391,6 +391,8 @@ Legend:
|
|||
* ``malloc``: system allocators from the standard C library, C functions:
|
||||
:c:func:`malloc`, :c:func:`calloc`, :c:func:`realloc` and :c:func:`free`.
|
||||
* ``pymalloc``: :ref:`pymalloc memory allocator <pymalloc>`.
|
||||
* ``mimalloc``: :ref:`mimalloc memory allocator <mimalloc>`. The pymalloc
|
||||
allocator will be used if mimalloc support isn't available.
|
||||
* "+ debug": with :ref:`debug hooks on the Python memory allocators
|
||||
<pymem-debug-hooks>`.
|
||||
* "Debug build": :ref:`Python build in debug mode <debug-build>`.
|
||||
|
@ -672,6 +674,16 @@ Customize pymalloc Arena Allocator
|
|||
|
||||
Set the arena allocator.
|
||||
|
||||
.. _mimalloc:
|
||||
|
||||
The mimalloc allocator
|
||||
======================
|
||||
|
||||
.. versionadded:: 3.13
|
||||
|
||||
Python supports the mimalloc allocator when the underlying platform support is available.
|
||||
mimalloc "is a general purpose allocator with excellent performance characteristics.
|
||||
Initially developed by Daan Leijen for the runtime systems of the Koka and Lean languages."
|
||||
|
||||
tracemalloc C API
|
||||
=================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue