-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Update mimalloc to 2.1.7 #21548
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
Update mimalloc to 2.1.7 #21548
Conversation
Oh, I guess we should make |
Could you open an upsteam llvm issue regarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Should we wait until dev-slice
lands in their main branch? I would guess that would be when they consider it stable, but I don't actually know their dev practices.
return ENOMEM; | ||
} | ||
return 0; | ||
*addr = emmalloc_memalign(try_alignment, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did the emmalloc alignment limitations get fixed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fixed via PR #21905 in the meantime. I also removed MIN_EMMALLOC_ALIGN
initially, but let's leave that for now.
b7e3831
to
6906868
Compare
dev-slice
branch
Revised this PR to update mimalloc to 2.1.7 instead. This is ready for review now.
I just opened issue llvm/llvm-project#117433 for this. Commit 0dc7223 defines |
2830274
to
0dc7223
Compare
tools/system_libs.py
Outdated
# disable `assert()` in emmalloc | ||
'-DNDEBUG', | ||
# avoid use of `__builtin_thread_pointer()` | ||
# FIXME: https://github.com/llvm/llvm-project/issues/117433 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we want a FIXME here since we are using musl as our libc so this seems correct in any case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tools/system_libs.py
Outdated
'-DMI_MALLOC_OVERRIDE', | ||
# TODO: add build modes that include debug checks 1,2,3 | ||
'-DMI_DEBUG=0', | ||
# disable `assert()` in emmalloc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# disable `assert()` in emmalloc | |
# disable `assert()` in mimalloc |
But do we not want this in debug builds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do, I think that we can/should make that a separate change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the comment is correct in this case, mimalloc uses mi_assert
, which is already disabled.
emscripten/system/lib/mimalloc/include/mimalloc/types.h
Lines 563 to 569 in a090ba8
#if (MI_DEBUG) | |
// use our own assertion to print without memory allocation | |
void _mi_assert_fail(const char* assertion, const char* fname, unsigned int line, const char* func ); | |
#define mi_assert(expr) ((expr) ? (void)0 : _mi_assert_fail(#expr,__FILE__,__LINE__,__func__)) | |
#else | |
#define mi_assert(x) | |
#endif |
However, we also want to disable the assertions in the underlying emmalloc allocator, which we build as part of mimalloc:
emscripten/tools/system_libs.py
Lines 1818 to 1819 in a090ba8
# Build all of mimalloc, and also emmalloc which is used as the system | |
# allocator underneath it. |
emscripten/tools/system_libs.py
Line 1828 in a090ba8
src_files += [utils.path_from_root('system/lib/emmalloc.c')] |
emscripten/system/lib/emmalloc.c
Lines 33 to 35 in a090ba8
* Debugging: | |
* | |
* - If not NDEBUG, runtime assert()s are in use. |
emscripten/system/lib/libc/musl/include/assert.h
Lines 5 to 9 in a090ba8
#ifdef NDEBUG | |
#define assert(x) (void)0 | |
#else | |
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) | |
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, it's for the underlying allocator. In that case it sounds ok. But can it be a separate change, or was it necessary for some reason to do in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no specific reason to address it in this PR; it was discovered by accident while working on this. Split into PR #23016.
a090ba8
to
7040d13
Compare
Thanks @kleisauke ! |
No description provided.