mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #32219 from azat/fix-jemalloc-on-osx
Fix jemalloc under osx
This commit is contained in:
commit
6cfb17d10f
@ -1,6 +1,6 @@
|
||||
if (SANITIZE OR NOT (
|
||||
((OS_LINUX OR OS_FREEBSD) AND (ARCH_AMD64 OR ARCH_ARM OR ARCH_PPC64LE OR ARCH_RISCV64)) OR
|
||||
(OS_DARWIN AND (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" OR CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
(OS_DARWIN AND (CMAKE_BUILD_TYPE_UC STREQUAL "RELWITHDEBINFO" OR CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG"))
|
||||
))
|
||||
if (ENABLE_JEMALLOC)
|
||||
message (${RECONFIGURE_MESSAGE_LEVEL}
|
||||
|
2
contrib/libpqxx
vendored
2
contrib/libpqxx
vendored
@ -1 +1 @@
|
||||
Subproject commit 357608d11b7a1961c3fb7db2ef9a5dbb2e87da77
|
||||
Subproject commit 63e20f9485b8cbeabf99008123248fc9f033e766
|
@ -25,13 +25,13 @@ namespace
|
||||
{
|
||||
#if defined(OS_LINUX)
|
||||
thread_local size_t write_trace_iteration = 0;
|
||||
#endif
|
||||
/// Even after timer_delete() the signal can be delivered,
|
||||
/// since it does not do anything with pending signals.
|
||||
///
|
||||
/// And so to overcome this flag is exists,
|
||||
/// to ignore delivered signals after timer_delete().
|
||||
thread_local bool signal_handler_disarmed = true;
|
||||
#endif
|
||||
|
||||
void writeTraceInfo(TraceType trace_type, int /* sig */, siginfo_t * info, void * context)
|
||||
{
|
||||
|
@ -1,6 +1,44 @@
|
||||
#include <Common/memory.h>
|
||||
#include <new>
|
||||
|
||||
#if defined(OS_DARWIN) && (USE_JEMALLOC)
|
||||
/// In case of OSX jemalloc register itself as a default zone allocator.
|
||||
///
|
||||
/// Sure jemalloc will register itself, since zone_register() declared with
|
||||
/// constructor attribute (since zone_register is also forbidden from
|
||||
/// optimizing out), however those constructors will be called before
|
||||
/// constructors for global variable initializers (__cxx_global_var_init()).
|
||||
///
|
||||
/// So to make jemalloc under OSX more stable, we will call it explicitly from
|
||||
/// global variable initializers so that each allocation will use it.
|
||||
/// (NOTE: It is ok to call it twice, since zone_register() is a no-op if the
|
||||
/// default zone is already replaced with something.)
|
||||
///
|
||||
/// Refs: https://github.com/jemalloc/jemalloc/issues/708
|
||||
|
||||
extern "C"
|
||||
{
|
||||
extern void zone_register();
|
||||
}
|
||||
|
||||
static struct InitializeJemallocZoneAllocatorForOSX
|
||||
{
|
||||
InitializeJemallocZoneAllocatorForOSX()
|
||||
{
|
||||
zone_register();
|
||||
/// jemalloc() initializes itself only on malloc()
|
||||
/// and so if some global initializer will have free(nullptr)
|
||||
/// jemalloc may trigger some internal assertion.
|
||||
///
|
||||
/// To prevent this, we explicitly call malloc(free()) here.
|
||||
if (void * ptr = malloc(0))
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
}
|
||||
} initializeJemallocZoneAllocatorForOSX;
|
||||
#endif
|
||||
|
||||
|
||||
/// Replace default new/delete with memory tracking versions.
|
||||
/// @sa https://en.cppreference.com/w/cpp/memory/new/operator_new
|
||||
|
Loading…
Reference in New Issue
Block a user