您的位置:首页 > 其它

函数buf_pool_init

2015-11-22 16:41 225 查看
/********************************************************************//**
Creates the buffer pool.
@return    DB_SUCCESS if success, DB_ERROR if not enough memory or error */
UNIV_INTERN
ulint
buf_pool_init(
/*==========*/
ulint    total_size,    /*!< in: size of the total pool in bytes */
ulint    n_instances)    /*!< in: number of instances */
{
ulint        i;
//n_instances 一般为1
const ulint    size    = total_size / n_instances;

ut_ad(n_instances > 0);
ut_ad(n_instances <= MAX_BUFFER_POOLS); //#define MAX_BUFFER_POOLS (1 << MAX_BUFFER_POOLS_BITS) 1<<6
ut_ad(n_instances == srv_buf_pool_instances);

/* We create an extra buffer pool instance, this instance is used
for flushing the flush lists, to keep track of n_flush for all
the buffer pools and also used as a waiting object during flushing. */

    //UNIV_INTERN buf_pool_t* buf_pool_ptr; 通过heap heap = mem_heap_create_func(n, MEM_HEAP_DYNAMIC, file_name, line); 实现 详见
buf_pool_ptr = mem_zalloc(n_instances * sizeof *buf_pool_ptr);

for (i = 0; i < n_instances; i++) {
buf_pool_t*    ptr    = &buf_pool_ptr[i];

if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) { //详见

/* Free all the instances created so far. */
buf_pool_free(i);

return(DB_ERROR);
}
}

buf_pool_set_sizes();
buf_LRU_old_ratio_update(100 * 3/ 8, FALSE);

btr_search_sys_create(buf_pool_get_curr_size() / sizeof(void*) / 64);

return(DB_SUCCESS);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: