New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Experimental memory allocator with vendored mimalloc #29123
Draft
tiran
wants to merge
22
commits into
python:main
Choose a base branch
from
tiran:mimalloc
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
+12,312
−26
Conversation
Signed-off-by: Christian Heimes <christian@python.org>
Signed-off-by: Christian Heimes <christian@python.org>
Co-authored-by: Dong-hee Na <donghee.na@python.org> Signed-off-by: Christian Heimes <christian@python.org>
Signed-off-by: Christian Heimes <christian@python.org>
ifeq is not portable. Original patch by Neil. Co-authored-by: Neil Schemenauer <nas@arctrix.com> Signed-off-by: Christian Heimes <christian@python.org>
See: microsoft/mimalloc#426 Signed-off-by: Christian Heimes <christian@python.org>
Use mimalloc's ``static.c`` to include mimalloc library into obmalloc. This allows us to prefix all symbols with ``_Py_`` prefix. Signed-off-by: Christian Heimes <christian@python.org>
HAVE_FINITE and HAVE_*GAMMA are not used any more. This fixes a build issue. Configure doesn't detect finite and gamma on macOS. Signed-off-by: Christian Heimes <christian@python.org>
Saw your PR in microsoft/mimalloc#475. This is great. I'm using mimalloc as a drop-in replacement with the ENV variables: PYTHONMALLOC=malloc MIMALLOC_PAGE_RESET=0 MIMALLOC_LARGE_OS_PAGES=1 LD_PRELOAD='/usr/lib64/libmimalloc.so' I expected that this upstream integration would bring other benefits, but it would not be able to use mimalloc's allocation of large OS pages? |
Signed-off-by: Christian Heimes <christian@python.org>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
EXPERIMENTAL This is an experimental pull request and a proof of concept. mimalloc integration is in a very early stage.
Vendor and hook up mimalloc. The PR only replaces raw memory allocator and Python's internal obmalloc with mimalloc. It does not use any of the advanced features of mimalloc such as heaps.
--with-mimalloc=yes
by default (for testing)--with-pymalloc=no
by default--with-freelists=yes
mimalloc requires C11
<stdatomic.h>
on POSIX platforms to provide atomic operations such as CAS. GCC on RHEL 7 / CentOS 7 is too old. GCC 4.9 and clang 3.6 seem to be minimum versions. Users need install Red Hat Developer Toolset 10.0 from Software Collections. The CentOS 7-based manylinux2014 container image comes with GCC 10.2 pre-installed.related mimalloc tickets
Initial benchmarks
Initial benchmarks should be taken with a big grain of salt. It seems like mimalloc is in the same ballpark as libc malloc + obmalloc with slightly better performance in some cases. I haven't measured memory consumption yet.
with mimalloc, without pymalloc, without freelists
In general about same performance, with some benchmarks 7% faster to 12% slower, https://gist.github.com/pablogsal/33fce1cbe5f908c1d85cae5d678f50a6
with mimalloc, without pymalloc, with freelists
In general 2% speedup, with some benchmarks 9% faster to 6% slower, https://gist.github.com/pablogsal/8027937b71cd30f17aaaa5ef7c885d3e
debug output
The text was updated successfully, but these errors were encountered: