您的位置:首页 > 博客中心 > 数据库 >

TCMalloc 对MYSQL 性能 优化的分析

时间:2022-03-14 15:50

TCMalloc 对MYSQL 性能 优化的分析

 

  • Author:Echo Chen(陈斌)

  • Email:chenb19870707@gmail.com

  • Blog:

  • Date:October 10th, 2014

     

           

          虽然经过研究发现TCMalloc不适合我们现有的游戏框架,但意外收获发现TCMalloc可以大幅度提高MYSQL 性能及内存占用,这里给出配置及测试的结果:

     

    一、配置

        

          关于TCMalloc的安装,在《》 一文中已经详细给出,下面给出将TCMalloc配置到MYSQL的步骤:

     

    1.修改MySQL启动脚本(依据MySQL安装位置):

     

    
    
    
    

                                       未使用TCMalloc

    OLTP test statistics:
        queries performed:
            read:                            140112
            write:                           50019
            other:                           20008
            total:                           210139
        transactions:                        10000  (756.11 per sec.)
        deadlocks:                           8      (0.60 per sec.)
        read/write requests:                 190131 (14376.02 per sec.)
        other operations:                    20008  (1512.83 per sec.)

    Test execution summary:
        total time:                          13.2256s
        total number of events:              10000
        total time taken by event execution: 211.4342
        per-request statistics:
             min:                                  2.96ms
             avg:                                 21.14ms
             max:                                423.52ms
             approx.  95 percentile:     56.25ms

                                    使用TCMalloc

    OLTP test statistics:
        queries performed:
            read:                            140084
            write:                           50017
            other:                           20006
            total:                           210107
        transactions:                        10000  (862.83 per sec.)
        deadlocks:                           6      (0.52 per sec.)
        read/write requests:                 190101 (16402.39 per sec.)
        other operations:                    20006  (1726.17 per sec.)

    Test execution summary:
        total time:                          11.5898s
        total number of events:              10000
        total time taken by event execution: 185.2397
        per-request statistics:
             min:                                  2.81ms
             avg:                                 18.52ms
             max:                                430.03ms
             approx.  95 percentile:              36.49ms


          可以看到使用TCMalloc性能明显优于未使用,这里主要原因是mysql是多线程小内存分配,TCMalloc由于每个线程均有线程缓冲区,所以对这样的小对象分配无竞争,效率非常好,可以看到TCMalloc对MYSQL优化效果不错 ,建议使用。

     

    -

    Echo Chen:

    -

  • 热门排行

    今日推荐

    热门手游