8.0.29-21.1 Percona XtraDB Cluster - jemalloc not working (SOLVED)

Hi.
I trying to get jemalloc on 8.0.29-21.1 Percona XtraDB Cluster but not success.
Even doing the manual startup (LD_PRELOAD=/usr/local/lib/libjemalloc.so /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/var/lib/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock) the variable inside mysql not detect:
mysql> SHOW VARIABLES LIKE ‘%malloc%’;
±-------------------±------+
| Variable_name | Value |
±-------------------±------+
| jemalloc_detected | OFF |
| jemalloc_profiling | OFF |
±-------------------±------+
2 rows in set (0.01 sec)

The docs on percona blog is outdated.

Other thing is the build-ps/build-binary.sh
There is the line: WITH_JEMALLOC=’ ’
How I can build with jemalloc included ?. I got several errors when try to include -DWITH_JEMALLOC=ON on location where are others.
If have some example file will help.

Thank you.

1 Like

Hello @Josias_L_G
This blog is from 2020 and appears to be up to date with MySQL 8.0. Is this the blog that you say isn’t working?

I notice that your LD_PRELOAD does not match the path in the blog. Did you properly install the jemalloc library using your OS package manager?

1 Like

Hi there.
Yes.
I try to use LD_PRELOAD on sysconfig too, however nothing inside mysql tell me about usage.
The lsof -Pn -p $(pidof mysqld) | grep jemalloc return the loaded module, but no usage inside mysql.
My last try was compile the jemalloc 5.3 (latest) and manually make the setting on LD_PRELOAD (before this i use others like 3.6).

But before all this, what flag inside mysql i can use to view the jemalloc ?. The only command i localize the usage is SHOW VARIABLES LIKE ‘%malloc%’; but i don´t know if is related to jemalloc in compile time or the usage of LD_PRELOAD.

1 Like

https://docs.percona.com/percona-server/8.0/performance/jemalloc-profiling.html#jemalloc-detected

jemalloc has to be custom compiled with additional flags to enable memory profiling with Percona MySQL. If the lsof returns that jemalloc is loaded, then MySQL is indeed using jemalloc but you will not be able to use the extra profiling features unless you custom compile jemalloc.

2 Likes