Commit d266262a authored by marko's avatar marko

branches/zip: Prepare for buffer pool allocation in several chunks.

buf_pool_t: Remove n_frames, max_size, and blocks_of_frames.
The current buffer pool size is in curr_size.

buf_pool_init(): Remove parameter max_size.

buf_pool_get_max_size(), buf_pool_is_block(): Remove.

buf_block_align(): Do not assume that the buffer pool is allocated
in one chunk.  Replace dependency on buf_pool->blocks_of_frames
with a call to buf_page_hash_get().
parent 89bacf34
......@@ -629,18 +629,12 @@ buf_pool_init(
/*==========*/
/* out, own: buf_pool object, NULL if not
enough memory or error */
ulint max_size, /* in: maximum size of the buf_pool in
blocks */
ulint curr_size) /* in: current size to use, must be <=
max_size, currently must be equal to
max_size */
ulint curr_size) /* in: current size to use */
{
byte* frame;
ulint i;
buf_block_t* block;
ulint n_frames = max_size;
ut_a(max_size == curr_size);
ulint n_frames = curr_size;
buf_pool = mem_alloc(sizeof(buf_pool_t));
......@@ -658,18 +652,15 @@ buf_pool_init(
return(NULL);
}
buf_pool->blocks = ut_malloc(sizeof(buf_block_t) * max_size);
buf_pool->blocks = ut_malloc(sizeof(buf_block_t) * curr_size);
if (buf_pool->blocks == NULL) {
return(NULL);
}
buf_pool->max_size = max_size;
buf_pool->curr_size = curr_size;
buf_pool->n_frames = n_frames;
/* Align pointer to the first frame */
frame = ut_align(buf_pool->frame_mem, UNIV_PAGE_SIZE);
......@@ -677,28 +668,20 @@ buf_pool_init(
buf_pool->frame_zero = frame;
buf_pool->high_end = frame + UNIV_PAGE_SIZE * n_frames;
buf_pool->blocks_of_frames = ut_malloc(sizeof(void*) * n_frames);
if (buf_pool->blocks_of_frames == NULL) {
return(NULL);
}
/* Init block structs and assign frames for them. Then we
assign the frames to the first blocks (we already mapped the
memory above). */
for (i = 0; i < max_size; i++) {
for (i = 0; i < curr_size; i++) {
block = buf_pool_get_nth_block(buf_pool, i);
frame = buf_pool->frame_zero + i * UNIV_PAGE_SIZE;
*(buf_pool->blocks_of_frames + i) = block;
buf_block_init(block, frame);
}
buf_pool->page_hash = hash_create(2 * max_size);
buf_pool->page_hash = hash_create(2 * curr_size);
buf_pool->n_pend_reads = 0;
......
......@@ -307,7 +307,7 @@ buf_LRU_buf_pool_running_out(void)
mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 4) {
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 4) {
ret = TRUE;
}
......@@ -338,7 +338,7 @@ loop:
mutex_enter(&(buf_pool->mutex));
if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 20) {
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->curr_size / 20) {
ut_print_timestamp(stderr);
fprintf(stderr,
......@@ -358,8 +358,10 @@ loop:
ut_error;
} else if (!recv_recovery_on && UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU) < buf_pool->max_size / 3) {
} else if (!recv_recovery_on
&& (UT_LIST_GET_LEN(buf_pool->free)
+ UT_LIST_GET_LEN(buf_pool->LRU))
< buf_pool->curr_size / 3) {
if (!buf_lru_switched_on_innodb_mon) {
......
......@@ -775,10 +775,10 @@ dict_init(void)
mutex_create(&dict_sys->mutex, SYNC_DICT);
dict_sys->table_hash = hash_create(buf_pool_get_max_size()
dict_sys->table_hash = hash_create(buf_pool_get_curr_size()
/ (DICT_POOL_PER_TABLE_HASH
* UNIV_WORD_SIZE));
dict_sys->table_id_hash = hash_create(buf_pool_get_max_size()
dict_sys->table_id_hash = hash_create(buf_pool_get_curr_size()
/ (DICT_POOL_PER_TABLE_HASH
* UNIV_WORD_SIZE));
dict_sys->size = 0;
......
......@@ -4446,7 +4446,7 @@ fil_aio_wait(
deadlocks in the i/o system. We keep tablespace 0 data files always
open, and use a special i/o thread to serve insert buffer requests. */
if (buf_pool_is_block(message)) {
if (fil_node->space->purpose == FIL_TABLESPACE) {
srv_set_io_thread_op_info(segment, "complete io for buf page");
buf_page_io_complete(message);
} else {
......
......@@ -73,11 +73,7 @@ buf_pool_init(
/*==========*/
/* out, own: buf_pool object, NULL if not
enough memory or error */
ulint max_size, /* in: maximum size of the buf_pool in
blocks */
ulint curr_size); /* in: current size to use, must be <=
max_size, currently must be equal to
max_size */
ulint curr_size); /* in: current size to use */
/*************************************************************************
Gets the current size of buffer buf_pool in bytes. */
UNIV_INLINE
......@@ -85,13 +81,6 @@ ulint
buf_pool_get_curr_size(void);
/*========================*/
/* out: size in bytes */
/*************************************************************************
Gets the maximum size of buffer pool in bytes. */
UNIV_INLINE
ulint
buf_pool_get_max_size(void);
/*=======================*/
/* out: size in bytes */
/************************************************************************
Gets the smallest oldest_modification lsn for any page in the pool. Returns
ut_dulint_zero if all modified pages have been flushed to disk. */
......@@ -429,15 +418,6 @@ buf_block_get_lock_hash_val(
/* out: lock hash value */
const buf_block_t* block) /* in: block */
__attribute__((const));
/***********************************************************************
Checks if a pointer points to the block array of the buffer pool (blocks, not
the frames). */
UNIV_INLINE
ibool
buf_pool_is_block(
/*==============*/
/* out: TRUE if pointer to block */
void* ptr); /* in: pointer to memory */
#ifdef UNIV_DEBUG
/*************************************************************************
Validates the buffer pool data structure. */
......@@ -855,22 +835,8 @@ struct buf_pool_struct{
this is aligned by the frame size */
byte* high_end; /* pointer to the end of the buffer
frames */
ulint n_frames; /* number of frames */
buf_block_t* blocks; /* array of buffer control blocks */
buf_block_t** blocks_of_frames;/* inverse mapping which can be used
to retrieve the buffer control block
of a frame; this is an array which
lists the blocks of frames in the
order frame_zero,
frame_zero + UNIV_PAGE_SIZE, ...
a control block is always assigned
for each frame, even if the frame does
not contain any data */
ulint max_size; /* number of control blocks ==
maximum pool size in pages */
ulint curr_size; /* current pool size in pages;
currently always the same as
max_size */
ulint curr_size; /* current pool size in pages */
hash_table_t* page_hash; /* hash table of the file pages */
ulint n_pend_reads; /* number of pending read operations */
......
......@@ -39,18 +39,7 @@ buf_pool_get_curr_size(void)
/*========================*/
/* out: size in bytes */
{
return((buf_pool->n_frames) * UNIV_PAGE_SIZE);
}
/*************************************************************************
Gets the maximum size of buffer buf_pool in bytes. */
UNIV_INLINE
ulint
buf_pool_get_max_size(void)
/*=======================*/
/* out: size in bytes */
{
return((buf_pool->n_frames) * UNIV_PAGE_SIZE);
return(buf_pool->curr_size * UNIV_PAGE_SIZE);
}
/***********************************************************************
......@@ -69,26 +58,6 @@ buf_pool_get_nth_block(
return(i + buf_pool->blocks);
}
/***********************************************************************
Checks if a pointer points to the block array of the buffer pool (blocks, not
the frames). */
UNIV_INLINE
ibool
buf_pool_is_block(
/*==============*/
/* out: TRUE if pointer to block */
void* ptr) /* in: pointer to memory */
{
if ((buf_pool->blocks <= (buf_block_t*)ptr)
&& ((buf_block_t*)ptr < buf_pool->blocks
+ buf_pool->max_size)) {
return(TRUE);
}
return(FALSE);
}
/************************************************************************
Gets the smallest oldest_modification lsn for any page in the pool. Returns
ut_dulint_zero if all modified pages have been flushed to disk. */
......@@ -229,33 +198,15 @@ buf_block_align(
byte* ptr) /* in: pointer to a frame */
{
buf_block_t* block;
buf_frame_t* frame_zero;
ut_ad(ptr);
frame_zero = buf_pool->frame_zero;
if (UNIV_UNLIKELY((ulint)ptr < (ulint)frame_zero)
|| UNIV_UNLIKELY((ulint)ptr > (ulint)(buf_pool->high_end))) {
ut_print_timestamp(stderr);
fprintf(stderr,
"InnoDB: Error: trying to access a stray pointer %p\n"
"InnoDB: buf pool start is at %p, end at %p\n"
"InnoDB: Probable reason is database corruption"
" or memory\n"
"InnoDB: corruption. If this happens in an"
" InnoDB database recovery, see\n"
"InnoDB: http://dev.mysql.com/doc/refman/5.1/en/"
"forcing-recovery.html\n"
"InnoDB: how to force recovery.\n",
ptr, frame_zero,
buf_pool->high_end);
ut_error;
}
ulint space_id, page_no;
block = *(buf_pool->blocks_of_frames + (((ulint)(ptr - frame_zero))
>> UNIV_PAGE_SIZE_SHIFT));
ptr = ut_align_down(ptr, UNIV_PAGE_SIZE);
page_no = mach_read_from_4(ptr + FIL_PAGE_OFFSET);
space_id = mach_read_from_4(ptr + FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID);
block = buf_page_hash_get(space_id, page_no);
ut_ad(block);
ut_ad(block->frame == ptr);
return(block);
}
......
......@@ -3296,7 +3296,7 @@ log_check_log_recs(
ut_memcpy(scan_buf, start, end - start);
recv_scan_log_recs(TRUE,
(buf_pool->n_frames
(buf_pool->curr_size
- recv_n_pool_free_frames) * UNIV_PAGE_SIZE,
FALSE, scan_buf, end - start,
ut_dulint_align_down(buf_start_lsn,
......
......@@ -2448,7 +2448,7 @@ recv_group_scan_log_recs(
group, start_lsn, end_lsn);
finished = recv_scan_log_recs(
TRUE, (buf_pool->n_frames - recv_n_pool_free_frames)
TRUE, (buf_pool->curr_size - recv_n_pool_free_frames)
* UNIV_PAGE_SIZE, TRUE, log_sys->buf, RECV_SCAN_SIZE,
start_lsn, contiguous_lsn, group_scanned_lsn);
start_lsn = end_lsn;
......
......@@ -1783,7 +1783,7 @@ srv_export_innodb_status(void)
= buf_get_latched_pages_number();
export_vars.innodb_buffer_pool_pages_total = buf_pool->curr_size;
export_vars.innodb_buffer_pool_pages_misc = buf_pool->max_size
export_vars.innodb_buffer_pool_pages_misc = buf_pool->curr_size
- UT_LIST_GET_LEN(buf_pool->LRU)
- UT_LIST_GET_LEN(buf_pool->free);
export_vars.innodb_page_size = UNIV_PAGE_SIZE;
......
......@@ -1230,7 +1230,7 @@ innobase_start_or_create_for_mysql(void)
fil_init(srv_max_n_open_files);
ret = buf_pool_init(srv_pool_size, srv_pool_size);
ret = buf_pool_init(srv_pool_size);
if (ret == NULL) {
fprintf(stderr,
......
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