mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
branches/zip: Add buf_pool->zip_hash for keeping track on pages allocated
to the buddy system for allocating compressed pages and their descriptors. buf_buddy_free_block(): New function: Deallocate the buffer frame. buf_buddy_free(), buf_buddy_free_low(): Return void instead of a pointer to a freed buffer frame.
This commit is contained in:
parent
e2a384eb7f
commit
d387f148b4
5 changed files with 53 additions and 32 deletions
|
@ -13,6 +13,7 @@ Created December 2006 by Marko Makela
|
|||
#endif
|
||||
#undef THIS_MODULE
|
||||
#include "buf0buf.h"
|
||||
#include "buf0lru.h"
|
||||
#include "buf0flu.h"
|
||||
#include "page0page.h"
|
||||
|
||||
|
@ -54,6 +55,34 @@ buf_buddy_alloc_low(
|
|||
return(bpage);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Deallocate a buffer frame of UNIV_PAGE_SIZE. */
|
||||
static
|
||||
void
|
||||
buf_buddy_free_block(
|
||||
/*=================*/
|
||||
void* buf) /* in: buffer frame to deallocate */
|
||||
{
|
||||
ulint fold = (ulint) buf / UNIV_PAGE_SIZE;
|
||||
buf_page_t* bpage;
|
||||
buf_block_t* block;
|
||||
|
||||
#ifdef UNIV_SYNC_DEBUG
|
||||
ut_a(mutex_own(&buf_pool->mutex));
|
||||
#endif /* UNIV_SYNC_DEBUG */
|
||||
ut_a(buf == ut_align_down(buf, UNIV_PAGE_SIZE));
|
||||
|
||||
HASH_SEARCH(hash, buf_pool->zip_hash, fold, bpage,
|
||||
((buf_block_t*) bpage)->frame == buf);
|
||||
ut_a(bpage);
|
||||
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_MEMORY);
|
||||
|
||||
block = (buf_block_t*) bpage;
|
||||
mutex_enter(&block->mutex);
|
||||
buf_LRU_block_free_non_file_page(block);
|
||||
mutex_exit(&block->mutex);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
Try to relocate a block. */
|
||||
static
|
||||
|
@ -188,15 +217,11 @@ buf_buddy_relocate(
|
|||
}
|
||||
|
||||
/**************************************************************************
|
||||
Release a block to buf_pool->zip_free[]. */
|
||||
Deallocate a block. */
|
||||
|
||||
void*
|
||||
void
|
||||
buf_buddy_free_low(
|
||||
/*===============*/
|
||||
/* out: pointer to the beginning of a block of
|
||||
size BUF_BUDDY_HIGH that should be freed to
|
||||
the underlying allocator, or NULL if released
|
||||
to buf_pool->zip_free[] */
|
||||
void* buf, /* in: block to free */
|
||||
ulint i) /* in: index of buf_pool->zip_free[] */
|
||||
{
|
||||
|
@ -246,7 +271,8 @@ buddy_free:
|
|||
}
|
||||
|
||||
/* The whole block is free. */
|
||||
return(buf);
|
||||
buf_buddy_free_block(buf);
|
||||
return;
|
||||
}
|
||||
|
||||
ut_a(bpage != buf);
|
||||
|
@ -289,6 +315,4 @@ buddy_free:
|
|||
bpage = buf;
|
||||
bpage->state = BUF_BLOCK_ZIP_FREE;
|
||||
UT_LIST_ADD_FIRST(list, buf_pool->zip_free[i], bpage);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
|
|
@ -845,6 +845,7 @@ buf_pool_init(void)
|
|||
srv_buf_pool_curr_size = buf_pool->curr_size * UNIV_PAGE_SIZE;
|
||||
|
||||
buf_pool->page_hash = hash_create(2 * buf_pool->curr_size);
|
||||
buf_pool->zip_hash = hash_create(2 * buf_pool->curr_size);
|
||||
|
||||
buf_pool->n_pend_reads = 0;
|
||||
|
||||
|
@ -1067,6 +1068,7 @@ buf_pool_page_hash_rebuild(void)
|
|||
/* Free, create, and populate the hash table. */
|
||||
hash_table_free(buf_pool->page_hash);
|
||||
buf_pool->page_hash = page_hash = hash_create(2 * buf_pool->curr_size);
|
||||
/* TODO: buf_pool->zip_hash */
|
||||
|
||||
chunk = buf_pool->chunks;
|
||||
n_chunks = buf_pool->n_chunks;
|
||||
|
|
|
@ -53,15 +53,11 @@ buf_buddy_alloc(
|
|||
__attribute__((malloc));
|
||||
|
||||
/**************************************************************************
|
||||
Release a block to buf_pool->zip_free[]. */
|
||||
Release a block. */
|
||||
UNIV_INLINE
|
||||
void*
|
||||
void
|
||||
buf_buddy_free(
|
||||
/*===========*/
|
||||
/* out: pointer to the beginning of a block of
|
||||
size BUF_BUDDY_HIGH that should be freed to
|
||||
the underlying allocator, or NULL if released
|
||||
to buf_pool->zip_free[] */
|
||||
void* buf, /* in: block to free */
|
||||
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */
|
||||
__attribute__((nonnull));
|
||||
|
|
|
@ -28,15 +28,11 @@ buf_buddy_alloc_low(
|
|||
__attribute__((malloc));
|
||||
|
||||
/**************************************************************************
|
||||
Release a block to buf_pool->zip_free[]. */
|
||||
Deallocate a block. */
|
||||
|
||||
void*
|
||||
void
|
||||
buf_buddy_free_low(
|
||||
/*===============*/
|
||||
/* out: pointer to the beginning of a block of
|
||||
size BUF_BUDDY_HIGH that should be freed to
|
||||
the underlying allocator, or NULL if released
|
||||
to buf_pool->zip_free[] */
|
||||
void* buf, /* in: block to free */
|
||||
ulint i) /* in: index of buf_pool->zip_free[] */
|
||||
__attribute__((nonnull));
|
||||
|
@ -98,15 +94,11 @@ buf_buddy_alloc(
|
|||
}
|
||||
|
||||
/**************************************************************************
|
||||
Release a block to buf_pool->zip_free[]. */
|
||||
Deallocate a block. */
|
||||
UNIV_INLINE
|
||||
void*
|
||||
void
|
||||
buf_buddy_free(
|
||||
/*===========*/
|
||||
/* out: pointer to the beginning of a block of
|
||||
size BUF_BUDDY_HIGH that should be freed to
|
||||
the underlying allocator, or NULL if released
|
||||
to buf_pool->zip_free[] */
|
||||
void* buf, /* in: block to free */
|
||||
ulint size) /* in: block size, up to UNIV_PAGE_SIZE / 2 */
|
||||
{
|
||||
|
@ -114,7 +106,7 @@ buf_buddy_free(
|
|||
ut_a(mutex_own(&buf_pool->mutex));
|
||||
#endif /* UNIV_SYNC_DEBUG */
|
||||
|
||||
return(buf_buddy_free_low(buf, buf_buddy_get_slot(size)));
|
||||
buf_buddy_free_low(buf, buf_buddy_get_slot(size));
|
||||
}
|
||||
|
||||
#ifdef UNIV_MATERIALIZE
|
||||
|
|
|
@ -915,8 +915,9 @@ struct buf_page_struct{
|
|||
is currently bufferfixed */
|
||||
|
||||
page_zip_des_t zip; /* compressed page */
|
||||
buf_page_t* hash; /* node used in chaining to the page
|
||||
hash table */
|
||||
buf_page_t* hash; /* node used in chaining to
|
||||
buf_pool->page_hash or
|
||||
buf_pool->zip_hash */
|
||||
|
||||
/* 2. Page flushing fields; protected by buf_pool->mutex */
|
||||
|
||||
|
@ -1095,8 +1096,14 @@ struct buf_pool_struct{
|
|||
ulint n_chunks; /* number of buffer pool chunks */
|
||||
buf_chunk_t* chunks; /* buffer pool chunks */
|
||||
ulint curr_size; /* current pool size in pages */
|
||||
hash_table_t* page_hash; /* hash table of the file pages */
|
||||
|
||||
hash_table_t* page_hash; /* hash table of buf_page_t or
|
||||
buf_block_t file pages,
|
||||
buf_page_in_file() == TRUE,
|
||||
indexed by (space_id, offset) */
|
||||
hash_table_t* zip_hash; /* hash table of buf_block_t blocks
|
||||
whose frames are allocated to the
|
||||
zip buddy system,
|
||||
indexed by block->frame */
|
||||
ulint n_pend_reads; /* number of pending read operations */
|
||||
|
||||
time_t last_printout_time; /* when buf_print was last time
|
||||
|
|
Loading…
Reference in a new issue