zoukankan      html  css  js  c++  java
  • [转载]innodb 的预读

    innodb在io的优化上有个比较重要的特性为预读,innodb以64个page为一个extent,那么innodb的预读是以page为单位还是以extent?

    这样就进入了下面的话题:linear read-ahead和randomread-ahead;

    为了区分这两种预读的方式,我们可以把linear预读放到以extent为单位,而random 预读放到以extent中的page为单位;

    linear 预读着眼于将下一个extent提前读取到buffer pool中,

    而random预读着眼于将当前extent中的剩余的page提前读取到buffer pool 中:

    linear的预读方式有一个很重要的变量控制是否将下一个extent预读到buffer pool中:innodb_read_ahead_threshold:如果一个extent中的被顺序读取的page超过或者等于该参数变量的,innodb将会异步的将下一个extent读取到buffer pool中,比如该参数的值为30,那么当该extent中有30个pages 被 sequentially的读取,则会触发innodb linear预读,将下一个extent读到内存中;在没有该变量之前,当访问到extent的最后一个page的时候,innodb会决定是否将下一个extent放入到buffer pool中;

    该参数可以动态的修改:

    root@(none) 09:20:02>set global innodb_read_ahead_threshold=40;

    Query OK, 0 rows affected (0.00 sec)

    random的预读方式则是表示当同一个extent中的一些page在buffer pool中发现时,innodb会将该extent中的剩余page一并读到buffer pool中,由于random的预读方式给innodb code带来了一些不必要的复杂性,同时在性能也存在不稳定性,在5.5中已经将这种预读方式废弃。

    在监控innodb的预读时候,我们可以通过show innodb status中的 Pages read ahead和evicted without access 两个值来观察预读的情况:

    或者通过两个状态值:

    Innodb_buffer_pool_read_ahead 和 Innodb_buffer_pool_read_ahead_evicted.

    Innodb_buffer_pool_read_ahead:表示通过预读请求到buffer pool的pages;

    Innodb_buffer_pool_read_ahead_evicted:表示由于请求到buffer pool中没有被访问,而驱逐出buffer pool的pages;

    root@(none) 10:19:42>show global status like ‘%read_ahead%’;

    +—————————————+———+

    | Variable_name | Value |

    +—————————————+———+

    | Innodb_buffer_pool_read_ahead | 775378 |

    | Innodb_buffer_pool_read_ahead_evicted | 1888537 |

    而通过show innodb status得到的 Pages read ahead 和evicted without access 则表示每秒读入和读出的pages;

    Pages read ahead 1.00/s, evicted without access 9.99/s.

    ref:

  • 相关阅读:
    JavaWeb--HttpSession案例
    codeforces B. Balls Game 解题报告
    hdu 1711 Number Sequence 解题报告
    codeforces B. Online Meeting 解题报告
    ZOJ 3706 Break Standard Weight 解题报告
    codeforces C. Magic Formulas 解题报告
    codeforces B. Sereja and Mirroring 解题报告
    zoj 1109 Language of FatMouse 解题报告
    hdu 1361.Parencodings 解题报告
    hdu 1004 Let the Balloon Rise 解题报告
  • 原文地址:https://www.cnblogs.com/conanwang/p/5823400.html
Copyright © 2011-2022 走看看