~skinny.moey/drizzle/innodb-replication

« back to all changes in this revision

Viewing changes to plugin/innobase/include/buf0buf.ic

  • Committer: Brian Aker
  • Date: 2010-11-08 22:35:57 UTC
  • mfrom: (1802.1.114 trunk)
  • Revision ID: brian@tangent.org-20101108223557-w3xzwp9hjjtjhtc1
MergeĀ inĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
19
 
20
20
You should have received a copy of the GNU General Public License along with
21
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
 
Place, Suite 330, Boston, MA 02111-1307 USA
 
21
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
22
St, Fifth Floor, Boston, MA 02110-1301 USA
23
23
 
24
24
*****************************************************************************/
25
25
 
72
72
/*=====================*/
73
73
        const buf_page_t*       bpage)  /*!< in: block to make younger */
74
74
{
75
 
        return(buf_pool->freed_page_clock
76
 
               >= buf_page_get_freed_page_clock(bpage)
77
 
               + 1 + (buf_pool->curr_size / 4));
 
75
        if (UNIV_UNLIKELY(buf_pool->freed_page_clock == 0)) {
 
76
                /* If eviction has not started yet, do not update the
 
77
                statistics or move blocks in the LRU list.  This is
 
78
                either the warm-up phase or an in-memory workload. */
 
79
                return(FALSE);
 
80
        } else if (buf_LRU_old_threshold_ms && bpage->old) {
 
81
                unsigned        access_time = buf_page_is_accessed(bpage);
 
82
 
 
83
                if (access_time > 0
 
84
                    && (ut_time_ms() - access_time)
 
85
                    >= buf_LRU_old_threshold_ms) {
 
86
                        return(TRUE);
 
87
                }
 
88
 
 
89
                buf_pool->stat.n_pages_not_made_young++;
 
90
                return(FALSE);
 
91
        } else {
 
92
                /* FIXME: bpage->freed_page_clock is 31 bits */
 
93
                return((buf_pool->freed_page_clock & ((1UL << 31) - 1))
 
94
                       > ((ulint) bpage->freed_page_clock
 
95
                          + (buf_pool->curr_size
 
96
                             * (BUF_LRU_OLD_RATIO_DIV - buf_LRU_old_ratio)
 
97
                             / (BUF_LRU_OLD_RATIO_DIV * 4))));
 
98
        }
78
99
}
79
100
 
80
101
/*********************************************************************//**
118
139
 
119
140
        return(lsn);
120
141
}
121
 
 
122
 
/*******************************************************************//**
123
 
Increments the buf_pool clock by one and returns its new value. Remember
124
 
that in the 32 bit version the clock wraps around at 4 billion!
125
 
@return new clock value */
126
 
UNIV_INLINE
127
 
ulint
128
 
buf_pool_clock_tic(void)
129
 
/*====================*/
130
 
{
131
 
        ut_ad(buf_pool_mutex_own());
132
 
 
133
 
        buf_pool->ulint_clock++;
134
 
 
135
 
        return(buf_pool->ulint_clock);
136
 
}
137
142
#endif /* !UNIV_HOTBACKUP */
138
143
 
139
144
/*********************************************************************//**
280
285
}
281
286
 
282
287
/*********************************************************************//**
283
 
Determine the approximate LRU list position of a block.
284
 
@return LRU list position */
285
 
UNIV_INLINE
286
 
ulint
287
 
buf_page_get_LRU_position(
288
 
/*======================*/
289
 
        const buf_page_t*       bpage)  /*!< in: control block */
290
 
{
291
 
        ut_ad(buf_page_in_file(bpage));
292
 
        ut_ad(buf_pool_mutex_own());
293
 
 
294
 
        return(bpage->LRU_position);
295
 
}
296
 
 
297
 
/*********************************************************************//**
298
288
Gets the mutex of a block.
299
289
@return pointer to mutex protecting bpage */
300
290
UNIV_INLINE
476
466
        ut_ad(bpage->in_LRU_list);
477
467
 
478
468
#ifdef UNIV_LRU_DEBUG
479
 
        if (UT_LIST_GET_PREV(LRU, bpage) && UT_LIST_GET_NEXT(LRU, bpage)
480
 
            && UT_LIST_GET_PREV(LRU, bpage)->old
481
 
            == UT_LIST_GET_NEXT(LRU, bpage)->old) {
482
 
                ut_a(UT_LIST_GET_PREV(LRU, bpage)->old == old);
 
469
        ut_a((buf_pool->LRU_old_len == 0) == (buf_pool->LRU_old == NULL));
 
470
        /* If a block is flagged "old", the LRU_old list must exist. */
 
471
        ut_a(!old || buf_pool->LRU_old);
 
472
 
 
473
        if (UT_LIST_GET_PREV(LRU, bpage) && UT_LIST_GET_NEXT(LRU, bpage)) {
 
474
                const buf_page_t*       prev = UT_LIST_GET_PREV(LRU, bpage);
 
475
                const buf_page_t*       next = UT_LIST_GET_NEXT(LRU, bpage);
 
476
                if (prev->old == next->old) {
 
477
                        ut_a(prev->old == old);
 
478
                } else {
 
479
                        ut_a(!prev->old);
 
480
                        ut_a(buf_pool->LRU_old == (old ? bpage : next));
 
481
                }
483
482
        }
484
483
#endif /* UNIV_LRU_DEBUG */
485
484
 
487
486
}
488
487
 
489
488
/*********************************************************************//**
490
 
Determine if a block has been accessed in the buffer pool.
491
 
@return TRUE if accessed */
 
489
Determine the time of first access of a block in the buffer pool.
 
490
@return ut_time_ms() at the time of first access, 0 if not accessed */
492
491
UNIV_INLINE
493
 
ibool
 
492
unsigned
494
493
buf_page_is_accessed(
495
494
/*=================*/
496
495
        const buf_page_t*       bpage)  /*!< in: control block */
497
496
{
498
497
        ut_ad(buf_page_in_file(bpage));
499
498
 
500
 
        return(bpage->accessed);
 
499
        return(bpage->access_time);
501
500
}
502
501
 
503
502
/*********************************************************************//**
507
506
buf_page_set_accessed(
508
507
/*==================*/
509
508
        buf_page_t*     bpage,          /*!< in/out: control block */
510
 
        ibool           accessed)       /*!< in: accessed */
 
509
        ulint           time_ms)        /*!< in: ut_time_ms() */
511
510
{
512
511
        ut_a(buf_page_in_file(bpage));
513
 
        ut_ad(mutex_own(buf_page_get_mutex(bpage)));
 
512
        ut_ad(buf_pool_mutex_own());
514
513
 
515
 
        bpage->accessed = accessed;
 
514
        if (!bpage->access_time) {
 
515
                /* Make this the time of the first access. */
 
516
                bpage->access_time = time_ms;
 
517
        }
516
518
}
517
519
 
518
520
/*********************************************************************//**