函数buf_LRU_old_adjust_len

时间:2022-04-30 16:29:40

调整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;
        }
    }
}