Bug #110490 add a option to get the malloc lib infomation of MySQL server use
Submitted: 24 Mar 2023 11:08 Modified: 24 Mar 2023 11:51
Reporter: bin wang (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Options Severity:S3 (Non-critical)
Version:Ver 8.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Contribution

[24 Mar 2023 11:08] bin wang
Description:
when configure  MySQL with tcmalloc or jemalloc lib, it is  hard to confirm whether it is effective or not, has no option to see the malloc infomation,
Add a malloc option will be more convenient  for checking malloc configurition.

How to repeat:
export LD_PRELOAD=/root/libjemalloc.so
./mysqld --defaults-file=my.cnf &
mysql -uroot
show variables like "%malloc%";
Empty set (0.01 sec)

Suggested fix:
export LD_PRELOAD=/root/libjemalloc.so 
show variables like "%malloc%";
+------------------------+------------------------------------------------------------+
| Variable_name          | Value                                                      |
+------------------------+------------------------------------------------------
export LD_PRELOAD=/root/libjemalloc.so 
show variables like "%malloc%";
------+
| malloc_library | jemalloc 5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c |
+------------------------+------------------------------------------------------------+
1 row in set (0.01 sec)

mysql> show variables like "%malloc%";
+------------------------+--------------------------+
| Variable_name          | Value                    |
+------------------------+--------------------------+
| malloc_library | tcmalloc gperftools 2.10 |
+------------------------+--------------------------+
1 row in set (0.01 sec)
[24 Mar 2023 11:09] bin wang
suggested add  patch

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: malloc.patch (application/octet-stream, text), 2.07 KiB.

[24 Mar 2023 11:14] bin wang
export LD_PRELOAD=/root/libjemalloc.so 
mysql> show variables like "%malloc%";
+------------------------+------------------------------------------------------------+
| Variable_name          | Value                                                      |
+------------------------+------------------------------------------------------------+
| malloc_library | jemalloc 5.3.0-0-g54eaed1d8b56b1aa528be3bdd1877e59c56fa90c |
+------------------------+------------------------------------------------------------+
1 row in set (0.00 sec)

export LD_PRELOAD=/root/libtcmalloc.so 
mysql> show variables like "%malloc%";
+------------------------+--------------------------+
| Variable_name          | Value                    |
+------------------------+--------------------------+
| malloc_library | tcmalloc gperftools 2.10 |
+------------------------+--------------------------+
1 row in set (0.00 sec)
[24 Mar 2023 11:51] MySQL Verification Team
Hello bin wang,

Thank you for the report and contribution.

regards,
Umesh