~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/buf/buf0rea.c

  • Committer: Stewart Smith
  • Date: 2010-11-03 03:27:09 UTC
  • mto: (1902.1.1 build) (1910.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1903.
  • Revision ID: stewart@flamingspork.com-20101103032709-oyvfrc6eb8fzj0mr
fix docs warning: docs/unlock.rst:2: (WARNING/2) Title underline too short.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12
12
 
13
13
You should have received a copy of the GNU General Public License along with
14
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
 
Place, Suite 330, Boston, MA 02111-1307 USA
 
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
15
St, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
*****************************************************************************/
18
18
 
38
38
#include "srv0start.h"
39
39
#include "srv0srv.h"
40
40
 
41
 
/** The size in blocks of the area where the random read-ahead algorithm counts
42
 
the accessed pages when deciding whether to read-ahead */
43
 
#define BUF_READ_AHEAD_RANDOM_AREA      BUF_READ_AHEAD_AREA
44
 
 
45
 
/** There must be at least this many pages in buf_pool in the area to start
46
 
a random read-ahead */
47
 
#define BUF_READ_AHEAD_RANDOM_THRESHOLD (1 + BUF_READ_AHEAD_RANDOM_AREA / 2)
48
 
 
49
41
/** The linear read-ahead area size */
50
42
#define BUF_READ_AHEAD_LINEAR_AREA      BUF_READ_AHEAD_AREA
51
43
 
62
54
@return 1 if a read request was queued, 0 if the page already resided
63
55
in buf_pool, or if the page is in the doublewrite buffer blocks in
64
56
which case it is never read into the pool, or if the tablespace does
65
 
not exist or is being dropped */
 
57
not exist or is being dropped 
 
58
@return 1 if read request is issued. 0 if it is not */
66
59
static
67
60
ulint
68
61
buf_read_page_low(
165
158
}
166
159
 
167
160
/********************************************************************//**
168
 
Applies a random read-ahead in buf_pool if there are at least a threshold
169
 
value of accessed pages from the random read-ahead area. Does not read any
170
 
page, not even the one at the position (space, offset), if the read-ahead
171
 
mechanism is not activated. NOTE 1: the calling thread may own latches on
172
 
pages: to avoid deadlocks this function must be written such that it cannot
173
 
end up waiting for these latches! NOTE 2: the calling thread must want
174
 
access to the page given: this rule is set to prevent unintended read-aheads
175
 
performed by ibuf routines, a situation which could result in a deadlock if
176
 
the OS does not support asynchronous i/o.
177
 
@return number of page read requests issued; NOTE that if we read ibuf
178
 
pages, it may happen that the page at the given page number does not
179
 
get read even if we return a positive value! */
180
 
static
181
 
ulint
182
 
buf_read_ahead_random(
183
 
/*==================*/
184
 
        ulint   space,  /*!< in: space id */
185
 
        ulint   zip_size,/*!< in: compressed page size in bytes, or 0 */
186
 
        ulint   offset) /*!< in: page number of a page which the current thread
187
 
                        wants to access */
188
 
{
189
 
        (void)space;
190
 
        (void)zip_size;
191
 
        (void)offset;
192
 
        /* We have currently disabled random readahead */
193
 
        return(0);
194
 
 
195
 
}
196
 
 
197
 
/********************************************************************//**
198
161
High-level function which reads a page asynchronously from a file to the
199
162
buffer buf_pool if it is not already there. Sets the io_fix flag and sets
200
163
an exclusive lock on the buffer frame. The flag is cleared and the x-lock
201
 
released by the i/o-handler thread. Does a random read-ahead if it seems
202
 
sensible.
203
 
@return number of page read requests issued: this can be greater than
204
 
1 if read-ahead occurred */
 
164
released by the i/o-handler thread.
 
165
@return TRUE if page has been read in, FALSE in case of failure */
205
166
UNIV_INTERN
206
 
ulint
 
167
ibool
207
168
buf_read_page(
208
169
/*==========*/
209
170
        ulint   space,  /*!< in: space id */
212
173
{
213
174
        ib_int64_t      tablespace_version;
214
175
        ulint           count;
215
 
        ulint           count2;
216
176
        ulint           err;
217
177
 
218
178
        tablespace_version = fil_space_get_version(space);
219
179
 
220
 
        count = buf_read_ahead_random(space, zip_size, offset);
221
 
 
222
180
        /* We do the i/o in the synchronous aio mode to save thread
223
181
        switches: hence TRUE */
224
182
 
225
 
        count2 = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
226
 
                                   zip_size, FALSE,
227
 
                                   tablespace_version, offset);
228
 
        srv_buf_pool_reads+= count2;
 
183
        count = buf_read_page_low(&err, TRUE, BUF_READ_ANY_PAGE, space,
 
184
                                  zip_size, FALSE,
 
185
                                  tablespace_version, offset);
 
186
        srv_buf_pool_reads += count;
229
187
        if (err == DB_TABLESPACE_DELETED) {
230
188
                ut_print_timestamp(stderr);
231
189
                fprintf(stderr,
242
200
        /* Increment number of I/O operations used for LRU policy. */
243
201
        buf_LRU_stat_inc_io();
244
202
 
245
 
        return(count + count2);
 
203
        return(count);
246
204
}
247
205
 
248
206
/********************************************************************//**
369
327
                        fail_count++;
370
328
 
371
329
                } else if (pred_bpage) {
372
 
                        int res = (ut_ulint_cmp(
373
 
                                       buf_page_get_LRU_position(bpage),
374
 
                                       buf_page_get_LRU_position(pred_bpage)));
 
330
                       /* Note that buf_page_is_accessed() returns
 
331
                       the time of the first access.  If some blocks
 
332
                       of the extent existed in the buffer pool at
 
333
                       the time of a linear access pattern, the first
 
334
                       access times may be nonmonotonic, even though
 
335
                       the latest access times were linear.  The
 
336
                       threshold (srv_read_ahead_factor) should help
 
337
                       a little against this. */
 
338
                       int res = ut_ulint_cmp(
 
339
                               buf_page_is_accessed(bpage),
 
340
                               buf_page_is_accessed(pred_bpage));
375
341
                        /* Accesses not in the right order */
376
342
                        if (res != 0 && res != asc_or_desc) {
377
343
                                fail_count++;
514
480
        LRU policy decision. */
515
481
        buf_LRU_stat_inc_io();
516
482
 
517
 
        ++srv_read_ahead_seq;
 
483
        buf_pool->stat.n_ra_pages_read += count;
518
484
        return(count);
519
485
}
520
486