Tcmalloc (thread-caching malloc) is a member of Google-perftools, an open-source tool developed by Google. Compared with the standard glibc library's malloc, tcmalloc has much higher efficiency and speed in memory allocation, which can greatly improve the performance of the MySQL server in high concurrency, reduce system load.
For the implementation principle and test report of tcmalloc, see tcmalloc: malloc of thread cache.
Install tcmalloc for MySQL (Linux environment ):
1. Install the libunwind library for the 64-bit operating system. Do not install the 32-bit operating system. The libunwind Library provides the basic stack trigger function for 64-bit CPU and operating system-based programs, these include the APIs used to output stack tracing, APIs used to program stack unrolling, and APIs that support the C ++ exception handling mechanism.
Wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz
Tar zxvf libunwind-0.99-alpha.tar.gz
CD libunwind-0.99-alpha/
./Configure
Make & make install
2. Install Google-perftools:
Wget http://google-perftools.googlecode.com/files/google-perftools-0.97.tar.gz
Tar zxvf google-perftools-0.97.tar.gz
CD google-perftools-0.97/
./Configure
Make & make install
3. Modify the MySQL STARTUP script (depending on your MySQL installation location ):
VI/usr/local/MySQL/bin/mysqld_safe
In the next line of # executing mysqld_safe, add:
Reference export ld_preload = "/usr/local/lib/libtcmalloc. So"
Save and exit, and then restart the MySQL server.
4. Run the lsof command to check whether tcmalloc is effective:
/Usr/sbin/lsof-N | grep tcmalloc
If the following information is found, tcmalloc has taken effect:
Mysqld
10847 MySQL mem Reg 1203756 20484960/usr/local/lib/libtcmalloc. so.0.0.0