在mysql-safe的脚本中可以使用–malloc-lib=[lib_name]来指定内存分配的库,而不是使用系统的malloc()方法,对于MySQL5.6.33这个选项的值必须是下面几个目录中的一个/usr/lib /usr/lib64 /usr/lib/i386-linux-gnu或/usr/lib/x86_64-linux-gnu,这个版本之前的可以指定路径,在5.6的二进制分发版有个快捷的方式可以使用tcmalloc库,但是在某些特定的情况下快捷方式是无法起作用的,所以你应该指定路径名。在5.6.31版本中,mysql分发版本中不在包含tcmalloc库。
配合方法
在mysqld_safe脚本文件中添加
export LD_PRELOAD=/usr/lib/libtcmalloc_minimal.so
在cnf文件中的mysqld_safe部分添加:
malloc-lib=/usr/lib/libtcmalloc_minimal.so
下面是57在设置的时候错误提示
mysqld_safe –malloc-lib must be located in one of the directories: /usr/lib /usr/lib64 /usr/lib/i386-linux-gnu /usr/lib/x86_64-linux-gnu
加载成功的提示
mysqld_safe Adding ‘/usr/lib/libtcmalloc_minimal.so’ to LD_PRELOAD for mysqld
lsof -n| grep tcmalloc
mysqld 2029 my8888 mem REG 253,1 754332 25285728 /usr/lib/libtcmalloc_minimal.so
mysqld 2029 2030 my8888 mem REG 253,1 754332 25285728 /usr/lib/libtcmalloc_minimal.so
mysqld 2029 2031 my8888 mem REG 253,1 754332 25285728 /usr/lib/libtcmalloc_minimal.so
mysqld 2029 2032 my8888 mem REG 253,1 754332 25285728 /usr/lib/libtcmalloc_minimal.so
mysqld 2029 2033 my8888 mem REG 253,1 754332 25285728 /usr/lib/libtcmalloc_minimal.so
mysqld 2029 2034 my8888 mem REG 253,1 754332 25285728 /usr/lib/libtcmalloc_minimal.so
目前测试数据有问题,一会更新下
对比100并发下只读的表现:
使用系统的分配方法:
Running the test with following options:
Number of threads: 100
Initializing random number generator from current time
Initializing worker threads…
Threads started!
SQL statistics:
queries performed:
read: 6255396
write: 1787256
other: 893628
total: 8936280
transactions: 446814 (744.37 per sec.)
queries: 8936280 (14887.42 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 600.2570s
total number of events: 446814
Latency (ms):
min: 5.05
avg: 134.31
max: 590.65
95th percentile: 219.36
sum: 60011211.56
Threads fairness:
events (avg/stddev): 4468.1400/250.03
execution time (avg/stddev): 600.1121/0.07
查看系统资源使用
使用tcmalloc的方式
Number of threads: 100
Initializing random number generator from current time
Initializing worker threads…
Threads started!
SQL statistics:
queries performed:
read: 6323982
write: 1806852
other: 903426
total: 9034260
transactions: 451713 (752.49 per sec.)
queries: 9034260 (15049.76 per sec.)
ignored errors: 0 (0.00 per sec.)
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 600.2925s
total number of events: 451713
Latency (ms):
min: 5.07
avg: 132.85
max: 702.87
95th percentile: 231.53
sum: 60012157.46
Threads fairness:
events (avg/stddev): 4517.1300/37.77
execution time (avg/stddev): 600.1216/0.09
下面是系统资源使用情况
看到系统的cpu使用情况比较有意思,使用默认的分配方式的时候,用户的cpu使用比较低,系统的使用比较高,而使用tcmalloc的方式,用户的cpu使用高,系统的cpu使用低。在只读的环境下可以看到tps是有上升的表现,但是幅度还不是很大。
下面测试下50用户下的读写情况
3473



被折叠的 条评论
为什么被折叠?



