MySQL Performance Test (comparison before and after tcmalloc)

Source: Internet
Author: User
"Tcmalloc (thread-caching malloc) is one of the Google-perftools tools. Compared with the standard glibc library's malloc, tcmalloc has much higher efficiency and speed in memory allocation, it can improve the performance of the MySQL server in high concurrency and reduce the system load. "

Today I started to test the impact of tcmalloc on MySQL, the following is the process of my test: hardware: CPU: Intel (r) Xeon (r) CPU 5110@1.60GHz (four core) memory: 4G
Software: OS: centos release 5.3 (final) MySQL edition: 5.5.12-Log

Test tool:

Sysbench

Tpcc (available)

 

MySQL parameters:

Sync_binlog = 1transaction-isolation = READ-COMMITTEDinnodb_buffer_pool_size = 2500minnodb_thread_concurrency = 9innodb_flush_log_at_trx_commit = 1innodb_io_capacity = 400

 

To avoid block device I/O bottlenecks, data is basically read in the memory.

Load 1 kW records:

# Sysbench -- test = OLTP -- DB-driver = MySQL -- mysql-user = root -- mysql-host = 127.0.0.1 -- mysql-DB = sbtest -- mysql-socket =/tmp/MySQL. sock -- mysql-table-engine = InnoDB -- OLTP-table-size = 10000000 prepare

Install tcmalloc:

# Tar-zxvf google-perftools-1.7.tar.gz
# Cd google-perftools-1.7
# Mkdir/tmp/TC
#./Configure -- prefix =/tmp/TC -- disable-CPU-Profiler -- disable-heap-checker -- disable-debugalloc -- enable-Minimal
# Make & make install -- the compilation reports an error, saying no G ++
# Yum install gcc-C ++ libstdc ++-devel
# Cp/tmp/TC/lib/libtcmalloc_minimal.so.0.1.0/usr/local/lib
# Ln-S/usr/local/lib/libtcmalloc_minimal.so.0.1.0/usr/local/lib/libtcmalloc. So
# Ln-S/usr/local/lib/libtcmalloc_minimal.so.0.1.0/usr/local/lib/libtcmalloc. so.0
# Ln-S/usr/local/lib/libtcmalloc_minimal.so.0.1.0/usr/local/lib/libtcmalloc. so.0.1.0

"MySQL is added to the dynamic library to modify the MySQL server startup script mysqld_safe. Add the following line after" # executing mysqld_safe ": Export ld_preload ="/usr/local/lib/libtcmalloc. so "aims to load the tcmalloc dynamic library before starting MySQL. Restart MySQL Server: /usr/local/MySQL/bin/mysqladmin shutdown/usr/local/MySQL/bin/mysqld_safe-user = MySQL & verify that tcmalloc uses lsof to check whether the tcmalloc library has been loaded in the MySQL process: "# lsof-N | grep tcmalloc

Mysqld 10472 MySQL mem Reg 253,0 873557 15970541/usr/local/lib/libtcmalloc_minimal.so.0.1.0

 

Sysbench run statement:


# Time sysbench -- test = OLTP -- DB-driver = MySQL -- mysql-user = root -- mysql-host = 127.0.0.1 -- mysql-socket =/tmp/MySQL. sock -- mysql-table-engine = InnoDB -- mysql-DB = sbtest -- num-threads = [1... 64] -- Max-Requests = 10000 -- OLTP-read-only = on -- OLTP-table-size = 10000000 run


 

The test results are as follows:

The horizontal axis is the number of concurrent threads.

The vertical axis is the amount of transactions completed per second (read-only)

It is learned from the document that tcmalloc improves performance from two aspects:

First, the speed of executing a malloc/free operation;

Second, it reduces lock contention in multi-threaded programs. Small objects have almost reached zero contention. For large objects, tcmalloc tries to use a fine-grained and effective spin lock.

Refer:

Http://code.google.com/p/google-perftools/

Http://my.oschina.net/captaintheron/blog/2797

Http://shiningray.cn/tcmalloc-thread-caching-malloc.html

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.