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:
Dino Viehland 2023-10-30 08:43:11 -07:00 • committed by GitHub
parent 4ebf2fae96
commit 05f2f0ac92
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
61 changed files with 16792 additions and 161 deletions

View file

@ -300,6 +300,12 @@
<ClInclude Include="..\Include\marshal.h" />
<ClInclude Include="..\Include\memoryobject.h" />
<ClInclude Include="..\Include\methodobject.h" />
<ClInclude Include="..\Include\internal\mimalloc\mimalloc\atomic.h" />
<ClInclude Include="..\Include\internal\mimalloc\mimalloc\internal.h" />
<ClInclude Include="..\Include\internal\mimalloc\mimalloc\prim.h" />
<ClInclude Include="..\Include\internal\mimalloc\mimalloc\track.h" />
<ClInclude Include="..\Include\internal\mimalloc\mimalloc\types.h" />
<ClInclude Include="..\Include\internal\mimalloc\mimalloc.h" />
<ClInclude Include="..\Include\modsupport.h" />
<ClInclude Include="..\Include\moduleobject.h" />
<ClInclude Include="..\Include\object.h" />
@ -491,6 +497,20 @@
<ClCompile Include="..\Objects\longobject.c" />
<ClCompile Include="..\Objects\memoryobject.c" />
<ClCompile Include="..\Objects\methodobject.c" />
<ClCompile Include="..\Objects\mimalloc\alloc-aligned.c" />
<ClCompile Include="..\Objects\mimalloc\alloc.c" />
<ClCompile Include="..\Objects\mimalloc\arena.c" />
<ClCompile Include="..\Objects\mimalloc\bitmap.c" />
<ClCompile Include="..\Objects\mimalloc\heap.c" />
<ClCompile Include="..\Objects\mimalloc\init.c" />
<ClCompile Include="..\Objects\mimalloc\options.c" />
<ClCompile Include="..\Objects\mimalloc\os.c" />
<ClCompile Include="..\Objects\mimalloc\page.c" />
<ClCompile Include="..\Objects\mimalloc\prim\prim.c" />
<ClCompile Include="..\Objects\mimalloc\random.c" />
<ClCompile Include="..\Objects\mimalloc\segment.c" />
<ClCompile Include="..\Objects\mimalloc\segment-map.c" />
<ClCompile Include="..\Objects\mimalloc\stats.c" />
<ClCompile Include="..\Objects\moduleobject.c" />
<ClCompile Include="..\Objects\namespaceobject.c" />
<ClCompile Include="..\Objects\object.c" />