Commit Graph
16 Commits
Author SHA1 Message Date
Azat KhuzhinandClaude c6e3ef6a00 Integrate jemalloc with je_ prefix and remove usage of linker's --wrap
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]>
2026-03-13 10:49:11 +01:00
Konstantin Bogdanov 260122b0a0 Improve error message for functions unavailable in FIPS mode 2025-08-06 03:52:46 +02:00
Konstantin Bogdanov c850301603 Explicit OpenSSL cleanup in main.cpp 2025-05-19 16:53:47 +02:00
Konstantin Bogdanov c4abcb9542 Lint 2025-04-14 16:47:38 +02:00
Konstantin Bogdanov cd4a3a556d Proper fix 2025-04-14 00:47:15 +02:00
Konstantin Bogdanov 25af85cd7d Fix 2025-04-13 23:35:26 +02:00
Konstantin Bogdanov 66e818caf9 Lint 2025-04-10 21:33:00 +02:00
Konstantin Bogdanov 678acbafdc Fix OpenSSL early init 2025-04-10 21:33:00 +02:00
Raúl Marín 510570386f Continue hiding Exception.h 2025-02-17 18:53:53 +01:00
Alexander GololobovandGitHub 0c4abd5056 Update programs/keeper/keeper_main.cpp 2025-02-03 18:37:36 +01:00
Antonio Andelic a34e7815bb Ignore some jemalloc messages 2025-02-03 16:22:48 +01:00
Raúl Marín e50265bae5 Optimize includes of Exception.h 2024-12-02 22:26:41 +01:00
Konstantin Bogdanov b2c81981fb Use clang-19 2024-11-20 23:08:47 +01:00
Antonio Andelic 07f51e02ed Reuse some checks 2024-07-03 16:54:09 +02:00
Antonio Andelic b0bbc9c810 Fix symlinks 2024-07-01 16:01:57 +02:00
Antonio Andelic 6b47171f2c Keeper binary with different entrypoint 2024-07-01 10:52:08 +02:00