Re: [PATCH] BUG/MINOR: illegal use of the malloc_trim() function if jemalloc is used
On Wed, Mar 22, 2023 at 02:39:15PM +0100, Miroslav Zagorac wrote: > On 22. 03. 2023. 14:33, Willy Tarreau wrote: > >> Also, in that case, when calling 'haproxy -vv', it is no longer printed > >> that > >> malloc_trim is enabled. > > > > I'm not sure what you mean here, because for me it's never printed that > > malloc_trim() is enabled when building with jemalloc. > > > > Hello Willy, > > without the patch: > > % make -j8 ADDLIB="-ljemalloc" TARGET="linux-glibc" IGNOREGIT=1 > USE_GETADDRINFO=1 USE_LIBCRYPT=1 USE_LUA=1 USE_MEMORY_PROFILING=1 > USE_MODULES=1 USE_NS=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_TFO=1 > USE_THREAD=1 USE_ZLIB=1 > > % ldd haproxy | grep jemalloc > libjemalloc.so.2 => /lib/x86_64-linux-gnu/libjemalloc.so.2 > (0x7f1319e3a000) > > ./haproxy -vv | grep trim > Support for malloc_trim() is enabled. Ah thanks now I understand. For me it wasn't the case because I LD_PRELOADed it. However by doing so you've changed the semantics of this variable "using_default_allocator" whose role was exactly to detect if the allocator had changed from the built-in one. That's why it wasn't called "using_glibc_allocator" or so. Admittedly that part was still seriously lacking comments... I'd rather turn it back to what it was and fix the problem where the message is emitted instead. Anyway on latest changes we do emulate malloc_trim() using the equivalent in the other libs so in the end I'll just remove that message as it doesn't provide any value anymore. Thanks for the explanation! Willy
Re: [PATCH] BUG/MINOR: illegal use of the malloc_trim() function if jemalloc is used
On 22. 03. 2023. 14:33, Willy Tarreau wrote: >> Also, in that case, when calling 'haproxy -vv', it is no longer printed that >> malloc_trim is enabled. > > I'm not sure what you mean here, because for me it's never printed that > malloc_trim() is enabled when building with jemalloc. > Hello Willy, without the patch: % make -j8 ADDLIB="-ljemalloc" TARGET="linux-glibc" IGNOREGIT=1 USE_GETADDRINFO=1 USE_LIBCRYPT=1 USE_LUA=1 USE_MEMORY_PROFILING=1 USE_MODULES=1 USE_NS=1 USE_OPENSSL=1 USE_PCRE=1 USE_PCRE_JIT=1 USE_TFO=1 USE_THREAD=1 USE_ZLIB=1 % ldd haproxy | grep jemalloc libjemalloc.so.2 => /lib/x86_64-linux-gnu/libjemalloc.so.2 (0x7f1319e3a000) ./haproxy -vv | grep trim Support for malloc_trim() is enabled. -- Zaga What can change the nature of a man?
Re: [PATCH] BUG/MINOR: illegal use of the malloc_trim() function if jemalloc is used
Hi Miroslav, On Wed, Mar 22, 2023 at 01:11:53PM +0100, Miroslav Zagorac wrote: > Hello all, > > here is a patch that does not allow the use of malloc_trim() function if > HAProxy is linked with the malloc library. It was checked in some places in > the source, but not everywhere. Oh thanks for this, I remember noting it along a previous debugging session related to the patterns, and I would have sworn it was done! Interestingly we were speaking with William about this precise function 2 hours ago, saying that a more reliable long-term solution would be to intercept it and replace it so that any possible calls made from child libraries could be intercepted. This would then permit to get rid of the library compatibility check in dl_open(). > Also, in that case, when calling 'haproxy -vv', it is no longer printed that > malloc_trim is enabled. I'm not sure what you mean here, because for me it's never printed that malloc_trim() is enabled when building with jemalloc. Thanks! Willy
Re: [PATCH] BUG/MINOR: illegal use of the malloc_trim() function if jemalloc is used
On 22. 03. 2023. 13:11, Miroslav Zagorac wrote: > Hello all, > > here is a patch that does not allow the use of malloc_trim() function if > HAProxy is linked with the malloc library. It was checked in some places in .. jemalloc .., sorry for the typo. > the source, but not everywhere. > > Also, in that case, when calling 'haproxy -vv', it is no longer printed that > malloc_trim is enabled. > -- Miroslav Zagorac Senior Developer