Commit 04fb05b1 authored by inaam's avatar inaam

branches/zip: undo changes made in r1763.

These should have gone in branches/fts

Spotted by: Marko and Ken
parent 538665bc
...@@ -135,35 +135,16 @@ The LRU-list contains all the blocks holding a file page ...@@ -135,35 +135,16 @@ The LRU-list contains all the blocks holding a file page
except those for which the bufferfix count is non-zero. except those for which the bufferfix count is non-zero.
The pages are in the LRU list roughly in the order of the last The pages are in the LRU list roughly in the order of the last
access to the page, so that the oldest pages are at the end of the access to the page, so that the oldest pages are at the end of the
list. The LRU logic has two optimizations implemented in it. list. We also keep a pointer to near the end of the LRU list,
which we can use when we want to artificially age a page in the
Artificial aging of pages: buf_pool. This is used if we know that some page is not needed
-------------------------- again for some time: we insert the block right after the pointer,
This is achieved by maintaining a pointer at 3/8 from the tail of causing it to be replaced sooner than would noramlly be the case.
the LRU. All pages that are read in are inserted at this location. Currently this aging mechanism is used for read-ahead mechanism
The pages are moved to the front of LRU when they are *accessed*. of pages, and it can also be used when there is a scan of a full
How this helps? A regular read request will result in immediately table which cannot fit in the memory. Putting the pages near the
accessing the page and the block will be moved to the front of the of the LRU list, we make sure that most of the buf_pool stays in the
LRU. The reads done as part of read-ahead mechanism (random read-ahead, main memory, undisturbed.
linear read-ahead etc.) will leave these pages in the lower 3/8 of the
LRU. If these pages are not accessed they will be eventually evicted
without polluting the whole buffer cache.
Reduced LRU manipulation:
-------------------------
In a classic LRU each access to a page should result in putting it
to the front of LRU. LRU manipulation, however, can lead to mutex
contention. To avoid this, we only make a block "young" if we see
that it has slipped past the top 1/4th of the LRU.
We implement this heuristic by maintaining a freed_page_clock at the
buffer pool level and in each block as well. By comparing these two
values, without holding any locks, we can determine how far a block is
from the front of LRU.
Both these clocks start ticking only after victim eviction has started
in earnest (i.e.: no blocks in free list). Hence we cannot determine
location of a block during the initial warm up phase and, therefore, we
disable this optimization during that period. Look at
buf_block_peek_if_too_old() in include/buf0buf.ic
The chain of modified blocks contains the blocks The chain of modified blocks contains the blocks
holding file pages that have been modified in the memory holding file pages that have been modified in the memory
......
...@@ -38,11 +38,7 @@ buf_block_get_freed_page_clock( ...@@ -38,11 +38,7 @@ buf_block_get_freed_page_clock(
/************************************************************************ /************************************************************************
Recommends a move of a block to the start of the LRU list if there is danger Recommends a move of a block to the start of the LRU list if there is danger
of dropping from the buffer pool. NOTE: does not reserve the buffer pool of dropping from the buffer pool. NOTE: does not reserve the buffer pool
mutex. mutex. */
Note that freed_page_clock for both buf_pool and block starts ticking
only after the buffer_cache has warmed up. During the initial warmup
phase these values are set to zero. We always recommend to to move the
block to the start of the LRU in this case. */
UNIV_INLINE UNIV_INLINE
ibool ibool
buf_page_peek_if_too_old( buf_page_peek_if_too_old(
...@@ -51,10 +47,9 @@ buf_page_peek_if_too_old( ...@@ -51,10 +47,9 @@ buf_page_peek_if_too_old(
younger */ younger */
const buf_page_t* bpage) /* in: block to make younger */ const buf_page_t* bpage) /* in: block to make younger */
{ {
return(buf_pool->freed_page_clock == 0 return(buf_pool->freed_page_clock
|| (buf_pool->freed_page_clock >= buf_page_get_freed_page_clock(bpage)
>= buf_page_get_freed_page_clock(bpage) + 1 + (buf_pool->curr_size / 4));
+ 1 + (buf_pool->curr_size / 4)));
} }
/************************************************************************* /*************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment