mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
Simplify jemalloc integration by replacing the three-mechanism approach (`JEMALLOC_IS_MALLOC` + `JEMALLOC_OVERRIDE___LIBC_*` + linker `--wrap`) with a cleaner two-step design: 1. Compile jemalloc with `je_` prefix so it only exports `je_malloc`, `je_free`, etc. (matching what Darwin already does). 2. Define our own `malloc`/`free` in `malloc.cpp` that perform memory tracking and delegate to `je_malloc`/`je_free`. Provide `__libc_*` aliases on glibc to intercept internal calls. Changes: - Enable `JEMALLOC_PREFIX "je_"` in all non-Darwin `jemalloc_internal_defs.h.in` - Undef `JEMALLOC_IS_MALLOC` and all `JEMALLOC_OVERRIDE___LIBC_*` defines - Remove `JEMALLOC_OVERRIDE_MEMALIGN`/`VALLOC`/`PVALLOC` from `jemalloc_defs.h` - Add `JEMALLOC_NO_RENAME` interface define so consumer code sees `je_*` names - Prefix all jemalloc API calls (`mallctl` -> `je_mallctl`, etc.) in ClickHouse - Rewrite `memory.h` to call `je_malloc`/`je_free` directly instead of `__real_*` - Rewrite `malloc.cpp` with tracking wrappers calling `je_*` underneath - Rewrite `AllocationInterceptors.h` to map `__real_*` -> `je_*` or `::*` - Remove `__wrap_*` functions from `AllocationInterceptors.cpp` - Remove `--wrap` linker flags from `CMakeLists.txt` - Add jemalloc + clickhouse_common_io deps to `clickhouse_malloc` OBJECT library - And also fix JEMALLOC_CPREFIX for Darwin, that was the only platform that uses JE_MALLOC_CONF (over MALLOC_CONF) Co-Authored-By: Claude <[email protected]>
60 lines
1.6 KiB
C++
60 lines
1.6 KiB
C++
/* include/jemalloc/jemalloc_defs.h. Generated from jemalloc_defs.h.in by configure. */
|
|
/* Defined if __attribute__((...)) syntax is supported. */
|
|
#define JEMALLOC_HAVE_ATTR
|
|
|
|
/* Defined if alloc_size attribute is supported. */
|
|
#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE
|
|
|
|
/* Defined if format_arg(...) attribute is supported. */
|
|
#define JEMALLOC_HAVE_ATTR_FORMAT_ARG
|
|
|
|
/* Defined if format(gnu_printf, ...) attribute is supported. */
|
|
/* #undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF */
|
|
|
|
/* Defined if format(printf, ...) attribute is supported. */
|
|
#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF
|
|
|
|
/* Defined if fallthrough attribute is supported. */
|
|
#define JEMALLOC_HAVE_ATTR_FALLTHROUGH
|
|
|
|
/* Defined if cold attribute is supported. */
|
|
#define JEMALLOC_HAVE_ATTR_COLD
|
|
|
|
/*
|
|
* Define overrides for non-standard allocator-related functions if they are
|
|
* present on the system.
|
|
*/
|
|
/* #undef JEMALLOC_OVERRIDE_MEMALIGN */
|
|
/* #undef JEMALLOC_OVERRIDE_VALLOC */
|
|
/* #undef JEMALLOC_OVERRIDE_PVALLOC */
|
|
/* #undef JEMALLOC_OVERRIDE___LIBC_PVALLOC */
|
|
|
|
/*
|
|
* At least Linux omits the "const" in:
|
|
*
|
|
* size_t malloc_usable_size(const void *ptr);
|
|
*
|
|
* Match the operating system's prototype.
|
|
*/
|
|
#define JEMALLOC_USABLE_SIZE_CONST
|
|
|
|
/*
|
|
* If defined, specify throw() for the public function prototypes when compiling
|
|
* with C++. The only justification for this is to match the prototypes that
|
|
* glibc defines.
|
|
*/
|
|
#define JEMALLOC_USE_CXX_THROW
|
|
|
|
#define JEMALLOC_CONFIG_ENV
|
|
|
|
#ifdef _MSC_VER
|
|
# ifdef _WIN64
|
|
# define LG_SIZEOF_PTR_WIN 3
|
|
# else
|
|
# define LG_SIZEOF_PTR_WIN 2
|
|
# endif
|
|
#endif
|
|
|
|
/* sizeof(void *) == 2^LG_SIZEOF_PTR. */
|
|
#define LG_SIZEOF_PTR 3
|