ITPub博客

首页 > 数据库 > MySQL > 测试软件:sysbench-mutex

测试软件:sysbench-mutex

原创 MySQL 作者:javenzhen 时间:2015-07-24 10:54:20 0 删除 编辑
1、测试在大并发的请求mutex的时候,系统的性能
2、测试环境,虚拟机4线程,PC服务器96线程

  1. root@pm1:/root# cat /proc/cpuinfo |grep "model name"
  2. model name : Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
  3. model name : Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
  4. model name : Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
  5. model name : Intel(R) Core(TM) i3-2100 CPU @ 3.10GHz
  1. [root@ ~]# cat /proc/cpuinfo |grep "model name"
  2. model name    : Intel(R) Xeon(R) CPU E7-4860 v2 @ 2.60GHz
  3. model name    : Intel(R) Xeon(R) CPU E7-4860 v2 @ 2.60GHz
  4. model name    : Intel(R) Xeon(R) CPU E7-4860 v2 @ 2.60GHz
  5. model name    : Intel(R) Xeon(R) CPU E7-4860 v2 @ 2.60GHz
  6. model name    : Intel(R) Xeon(R) CPU E7-4860 v2 @ 2.60GHz
  7. ................................................
3、运行测试
虚拟机环境使用最大4线程

  1. root@pm1:/root# sysbench --test=mutex --num-threads=4 --mutex-num=2000 --mutex-locks=10000 --mutex-loops=5000 run
  2. sysbench 0.5: multi-threaded system evaluation benchmark

  3. Running the test with following options:
  4. Number of threads: 4
  5. Random number generator seed is 0 and will be ignored


  6. Threads


  7. General statistics:
  8.     total time: 0.0060s
  9.     total number of events: 4
  10.     total time taken by event execution: 0.0144s
  11.     response time:
  12.          min: 0.72ms
  13.          avg: 3.61ms
  14.          max: 5.75ms
  15.          approx. 95 percentile: 5.75ms

  16. Threads fairness:
  17.     events (avg/stddev): 1.0000/0.00
  18.     execution time (avg/stddev): 0.0036/0.00
PC服务器使用4线程

  1. [root@ ~]# sysbench --test=mutex --num-threads=4 --mutex-num=2000 --mutex-locks=10000 --mutex-loops=5000 run
  2. sysbench 0.5: multi-threaded system evaluation benchmark

  3. Running the test with following options:
  4. Number of threads: 4
  5. Random number generator seed is 0 and will be ignored


  6. Threads


  7. General statistics:
  8.     total time: 0.0210s
  9.     total number of events: 4
  10.     total time taken by event execution: 0.0819s
  11.     response time:
  12.          min: 19.42ms
  13.          avg: 20.49ms
  14.          max: 20.93ms
  15.          approx. 95 percentile: 20.94ms

  16. Threads fairness:
  17.     events (avg/stddev): 1.0000/0.00
  18.     execution time (avg/stddev): 0.0205/0.00

对比上面的结果,mutex跟线程数的多少没有关系,而是与CPU主频有关系
下面在看一组96线程的mutex竞争

  1. [root@ ~]# sysbench --test=mutex --num-threads=96 --mutex-num=2000 --mutex-locks=10000 --mutex-loops=5000 run
  2. sysbench 0.5: multi-threaded system evaluation benchmark

  3. Running the test with following options:
  4. Number of threads: 96
  5. Random number generator seed is 0 and will be ignored


  6. Threads


  7. General statistics:
  8.     total time: 0.5325s
  9.     total number of events: 96
  10.     total time taken by event execution: 48.1514s
  11.     response time:
  12.          min: 428.05ms
  13.          avg: 501.58ms
  14.          max: 532.18ms
  15.          approx. 95 percentile: 530.29ms

  16. Threads fairness:
  17.     events (avg/stddev): 1.0000/0.00
  18.     execution time (avg/stddev): 0.5016/0.02
用满线程数测试mutex反而更慢了,也就是说mutex的竞争与线程是没有关系的
在看下系统CPU信息,是4个物理CPU,12核,96线程的机器

  1. [root@ ~]# grep "core id" /proc/cpuinfo | sort -u | wc -l
  2. 12
  3. [root@ ~]# grep "physical id" /proc/cpuinfo | sort -u | wc -l
  4. 4
  5. [root@ ~]# grep "processor" /proc/cpuinfo | sort -u | wc -l
  6. 96
综上,mutex请求的性能与CPU主频及物理CPU个数有关

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12219480/viewspace-1749359/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-01-27

  • 博文量
    41
  • 访问量
    124944