GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing github.com — gh-90815: Add mimalloc memory allocator by DinoV · Pull Request #109914 · python/cpython Conversation
|
|
@ericsnowcurrently Yep, and much of the autoconf stuff is taken from there... I just finally filled in the description with a little more background on where things are coming from :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
41b62cb to
0dbe76b
Compare
I expect that most of this PR is a relatively vanilla use of mimalloc in CPython, like @tiran's PR is. Would it be much trouble to keep the whole PR vanilla and have a follow-up PR that applies the customizations to mimalloc (e.g. per-thread allocator state)? That distinction would help, possibly a lot, when reviewing. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
7bda1e4 to
35d1ebd
Compare
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
See also issue #111499: PYTHONMALLOCSTATS=1 fails with fatal error at Python exit. Using mimalloc, Python is not affected :-)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@DinoV: I pushed a few cleanup changes. I fixed the outdated doc which still said that mimalloc is the default. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I cleaned the commit message to only keep most important information.
I added @tiran as a co-author in the commit message. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It's worth further discussion. CC @daanx |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Congrats @DinoV, I merged your PR :-) Do you want to propose a follow-up PR to enable it by default when |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks like this broke the WASM buildbot: https://buildbot.python.org/all/#/builders/1046/builds/3371. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yep, looks like there's an implicit function definition: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I wrote PR #111524 to fix WASI build. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I wrote 4 follow-up PRs to fix different issues:
While mimalloc C code is built on Windows, Python cannot currently use mimalloc on Windows: see PR #111528. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* 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: python#31164 Co-authored-by: Sam Gross <[email protected]> Co-authored-by: Christian Heimes <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
* 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: python#31164 Co-authored-by: Sam Gross <[email protected]> Co-authored-by: Christian Heimes <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
* 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: python#31164 Co-authored-by: Sam Gross <[email protected]> Co-authored-by: Christian Heimes <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
… 3.13 Python 3.13 introduced mimalloc memory allocator [1], which registers an `atexit()` handler [2]. On NetBSD 11, an `atexit()` handler registered in a shared library is not executed upon the library unload (e.g., via `dlclose()`), but rather on program exit. So unloading a library that registers an `atexit()` handler results in segmentation fault in libc's `__cxa_finalize` when the program exits, because the handler is no longer reachable... The problem seems to be specific to NetBSD; on other platforms (including OpenBSD and FreeBSD), the handler is executed upon the library unload. [1] python/cpython#109914 [2] https://github.com/python/cpython/blob/05f2f0ac92afa560315eb66fd6576683c7f69e2d/Objects/mimalloc/init.c#L530
… 3.13 Python 3.13 introduced mimalloc memory allocator [1], which registers an `atexit()` handler [2]. On NetBSD 11, an `atexit()` handler registered in a shared library is not executed upon the library unload (e.g., via `dlclose()`), but rather on program exit. So unloading a library that registers an `atexit()` handler results in segmentation fault in libc's `__cxa_finalize` when the program exits, because the handler is no longer reachable... The problem seems to be specific to NetBSD; on other platforms (including OpenBSD and FreeBSD), the handler is executed upon the library unload. [1] python/cpython#109914 [2] https://github.com/python/cpython/blob/05f2f0ac92afa560315eb66fd6576683c7f69e2d/Objects/mimalloc/init.c#L530
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.