Use Google's open-source tcmalloc Library

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.