码迷,mamicode.com
首页 > 其他好文 > 详细

函数buf_LRU_old_adjust_len

时间:2015-11-24 22:04:06      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

调整LUR_old位置,放到八分之五位置,是新的,后八分之三是旧的

512个页全变成新的,然后从后往前数,数到8分之3,设置为旧的

/*******************************************************************//**
Moves the LRU_old pointer so that the length of the old blocks list
is inside the allowed limits. */
UNIV_INLINE
void
buf_LRU_old_adjust_len(
/*===================*/
    buf_pool_t*    buf_pool)    /*!< in: buffer pool instance */
{
    ulint    old_len;
    ulint    new_len;

    

    old_len = buf_pool->LRU_old_len;
    new_len = ut_min(UT_LIST_GET_LEN(buf_pool->LRU)
             * buf_pool->LRU_old_ratio / BUF_LRU_OLD_RATIO_DIV,
             UT_LIST_GET_LEN(buf_pool->LRU)
             - (BUF_LRU_OLD_TOLERANCE
                + BUF_LRU_NON_OLD_MIN_LEN));

    for (;;) {
        buf_page_t*    LRU_old = buf_pool->LRU_old;

        ut_a(LRU_old);
        ut_ad(LRU_old->in_LRU_list);

        /* Update the LRU_old pointer if necessary */

        //#define BUF_LRU_OLD_TOLERANCE    20
        if (old_len + BUF_LRU_OLD_TOLERANCE < new_len) {

            buf_pool->LRU_old = LRU_old = UT_LIST_GET_PREV(LRU, LRU_old);

            old_len = ++buf_pool->LRU_old_len;
            buf_page_set_old(LRU_old, TRUE);

        } else if (old_len > new_len + BUF_LRU_OLD_TOLERANCE) {

            buf_pool->LRU_old = UT_LIST_GET_NEXT(LRU, LRU_old);
            old_len = --buf_pool->LRU_old_len;
            buf_page_set_old(LRU_old, FALSE);
        } else {
            return;
        }
    }
}

 

函数buf_LRU_old_adjust_len

标签:

原文地址:http://www.cnblogs.com/taek/p/4992908.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!