MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
buf0rea.cc File Reference
#include "buf0rea.h"
#include "fil0fil.h"
#include "mtr0mtr.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "buf0lru.h"
#include "buf0dblwr.h"
#include "ibuf0ibuf.h"
#include "log0recv.h"
#include "trx0sys.h"
#include "os0file.h"
#include "srv0start.h"
#include "srv0srv.h"
#include "mysql/plugin.h"
#include "mysql/service_thd_wait.h"
Include dependency graph for buf0rea.cc:

Go to the source code of this file.

Macros

#define BUF_READ_AHEAD_RANDOM_THRESHOLD(b)   (5 + BUF_READ_AHEAD_AREA(b) / 8)
#define BUF_READ_AHEAD_PEND_LIMIT   2

Functions

UNIV_INTERN ulint buf_read_ahead_random (ulint space, ulint zip_size, ulint offset, ibool inside_ibuf)
UNIV_INTERN ibool buf_read_page (ulint space, ulint zip_size, ulint offset)
UNIV_INTERN ibool buf_read_page_async (ulint space, ulint offset)
UNIV_INTERN ulint buf_read_ahead_linear (ulint space, ulint zip_size, ulint offset, ibool inside_ibuf)
UNIV_INTERN void buf_read_ibuf_merge_pages (bool sync, const ulint *space_ids, const ib_int64_t *space_versions, const ulint *page_nos, ulint n_stored)
UNIV_INTERN void buf_read_recv_pages (ibool sync, ulint space, ulint zip_size, const ulint *page_nos, ulint n_stored)

Detailed Description

The database buffer read

Created 11/5/1995 Heikki Tuuri

Definition in file buf0rea.cc.

Macro Definition Documentation

#define BUF_READ_AHEAD_PEND_LIMIT   2
If there are buf_pool->curr_size per the number below pending reads, then

read-ahead is not done: this is to prevent flooding the buffer pool with i/o-fixed buffer blocks

Definition at line 52 of file buf0rea.cc.

#define BUF_READ_AHEAD_RANDOM_THRESHOLD (   b)    (5 + BUF_READ_AHEAD_AREA(b) / 8)
There must be at least this many pages in buf_pool in the area to start

a random read-ahead

Definition at line 46 of file buf0rea.cc.

Function Documentation

UNIV_INTERN ulint buf_read_ahead_linear ( ulint  space,
ulint  zip_size,
ulint  offset,
ibool  inside_ibuf 
)

Applies linear read-ahead if in the buf_pool the page is a border page of a linear read-ahead area and all the pages in the area have been accessed. Does not read any page if the read-ahead mechanism is not activated. Note that the algorithm looks at the 'natural' adjacent successor and predecessor of the page, which on the leaf level of a B-tree are the next and previous page in the chain of leaves. To know these, the page specified in (space, offset) must already be present in the buf_pool. Thus, the natural way to use this function is to call it when a page in the buf_pool is accessed the first time, calling this function just after it has been bufferfixed. NOTE 1: as this function looks at the natural predecessor and successor fields on the page, what happens, if these are not initialized to any sensible value? No problem, before applying read-ahead we check that the area to read is within the span of the space, if not, read-ahead is not applied. An uninitialized value may result in a useless read operation, but only very improbably. NOTE 2: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! NOTE 3: the calling thread must want access to the page given: this rule is set to prevent unintended read-aheads performed by ibuf routines, a situation which could result in a deadlock if the OS does not support asynchronous io.

Returns
number of page read requests issued
Parameters
spacein: space id
zip_sizein: compressed page size in bytes, or 0
offsetin: page number; see NOTE 3 above
inside_ibufin: TRUE if we are inside ibuf routine

Definition at line 498 of file buf0rea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ulint buf_read_ahead_random ( ulint  space,
ulint  zip_size,
ulint  offset,
ibool  inside_ibuf 
)

Applies a random read-ahead in buf_pool if there are at least a threshold value of accessed pages from the random read-ahead area. Does not read any page, not even the one at the position (space, offset), if the read-ahead mechanism is not activated. NOTE 1: the calling thread may own latches on pages: to avoid deadlocks this function must be written such that it cannot end up waiting for these latches! NOTE 2: the calling thread must want access to the page given: this rule is set to prevent unintended read-aheads performed by ibuf routines, a situation which could result in a deadlock if the OS does not support asynchronous i/o.

Returns
number of page read requests issued; NOTE that if we read ibuf pages, it may happen that the page at the given page number does not get read even if we return a positive value!
number of page read requests issued
Parameters
spacein: space id
zip_sizein: compressed page size in bytes, or 0
offsetin: page number of a page which the current thread wants to access
inside_ibufin: TRUE if we are inside ibuf routine

Definition at line 237 of file buf0rea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN void buf_read_ibuf_merge_pages ( bool  sync,
const ulint *  space_ids,
const ib_int64_t *  space_versions,
const ulint *  page_nos,
ulint  n_stored 
)

Issues read requests for pages which the ibuf module wants to read in, in order to contract the insert buffer tree. Technically, this function is like a read-ahead function.

Parameters
syncin: true if the caller wants this function to wait for the highest address page to get read in, before this function returns
space_idsin: array of space ids
space_versionsin: the spaces must have this version number (timestamp), otherwise we discard the read; we use this to cancel reads if DISCARD + IMPORT may have changed the tablespace size
page_nosin: array of page numbers to read, with the highest page number the last in the array
n_storedin: number of elements in the arrays

Definition at line 760 of file buf0rea.cc.

Here is the call graph for this function:

UNIV_INTERN ibool buf_read_page ( ulint  space,
ulint  zip_size,
ulint  offset 
)

High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there. Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread.

Returns
TRUE if page has been read in, FALSE in case of failure
Parameters
spacein: space id
zip_sizein: compressed page size in bytes, or 0
offsetin: page number

Definition at line 394 of file buf0rea.cc.

Here is the call graph for this function:

Here is the caller graph for this function:

UNIV_INTERN ibool buf_read_page_async ( ulint  space,
ulint  offset 
)

High-level function which reads a page asynchronously from a file to the buffer buf_pool if it is not already there. Sets the io_fix flag and sets an exclusive lock on the buffer frame. The flag is cleared and the x-lock released by the i/o-handler thread.

Returns
TRUE if page has been read in, FALSE in case of failure
Parameters
spacein: space id
offsetin: page number

Definition at line 437 of file buf0rea.cc.

Here is the call graph for this function:

UNIV_INTERN void buf_read_recv_pages ( ibool  sync,
ulint  space,
ulint  zip_size,
const ulint *  page_nos,
ulint  n_stored 
)

Issues read requests for pages which recovery wants to read in.

Parameters
syncin: TRUE if the caller wants this function to wait for the highest address page to get read in, before this function returns
spacein: space id
zip_sizein: compressed page size in bytes, or 0
page_nosin: array of page numbers to read, with the highest page number the last in the array
n_storedin: number of page numbers in the array

Definition at line 836 of file buf0rea.cc.

Here is the call graph for this function: