Commit graph

48 commits

Author SHA1 Message Date
marko
d321ea1141 branches/zip: buf_buddy_relocate(): The src block may be partially freed.
Remove the Valgrind check about it.
2007-10-31 10:40:09 +00:00
marko
2d77ed4f40 branches/zip: Improve Valgrind instrumentation.
buf_buddy_relocate(): Allow the source block to contain uninitialized data.

buf0buddy.c: Replace the remaining VALGRIND_CHECK_ macros with the wrappers
defined in univ.i.
2007-10-31 09:00:08 +00:00
marko
7319444c08 branches/zip: Improve Valgrind instrumentation.
buf_LRU_free_block(): Check that the block descriptor contains valid data.

buf_buddy_relocate(): Check that the source block contains valid data.

buf_page_get_gen(): Do not dereference bpage after calling buf_relocate().
This avoids a bogus Valgrind warning; the memory itself was valid.

buf_page_hash_get(): Check that the returned block descriptor contains
valid data.
2007-10-30 09:27:09 +00:00
marko
37309546e0 branches/zip: Cast void* pointers to byte* when doing pointer arithmetics. 2007-10-25 07:03:02 +00:00
marko
372a25240a branches/zip: Improve Valgrind instrumentation.
UNIV_MEM_ASSERT_RW(): New macro, to check that the contents of a memory
area is defined.

UNIV_MEM_ASSERT_W(): New macro, to check that a memory area is writable.

UNIV_MEM_ASSERT_AND_FREE(): New macro, to check that the memory is
writable before declaring it free (unwritable).  This replaces UNIV_MEM_FREE()
in many places.

mem_init_buf(): Declare the memory undefined.

mem_erase_buf(): Declare the memory freed.
2007-09-06 11:36:35 +00:00
marko
54113d6d9f branches/zip: HASH_SEARCH(): Add the parameter TYPE, for the type of DATA.
C++ requires explicit type casts when converting from void*, and *.ic files
are now inlined in ha_innodb.cc.

fil_space_get_by_id(), fil_space_get_by_name(): New inline functions, to
replace occurrences of the HASH_SEARCH() macro in fil0fil.c.  This should
improve readability.
2007-08-01 08:13:22 +00:00
marko
e4910d4775 branches/zip: Add the pseudo table INFORMATION_SCHEMA.INNODB_BUDDY
for displaying buddy allocator statistics.

buf_buddy_used[], buf_buddy_relocated[]: Declare as global symbols.

mysql_declare_plugin(innobase): Add MYSQL_INFORMATION_SCHEMA_PLUGIN
for innobase_is_buddy ("INNODB_BUDDY").
2007-03-12 12:01:45 +00:00
marko
d56453be8e branches/zip: buf_LRU_search_and_free_block(): Avoid freeing compressed-only
pages when they do not occupy too much of the buffer pool.

buf0buddy.c, buf0buddy.h: Export buf_buddy_n_frames and buf_buddy_min_n_frames.
2007-02-16 09:22:50 +00:00
marko
e67d5c761c branches/zip: Add statistic counters to the buddy allocator.
buf_buddy_n_frames: Number of buffer frames allocated for the buddy system
buf_buddy_used[]: Counts of allocated blocks, by buddy size.
buf_buddy_relocated[]: Counts of blocks relocated, bu buddy size.

buf_buddy_alloc_clean(): Note the added configuration parameter
buf_buddy_min_n_frames: Preferred minimum buf_buddy_n_frames
2007-02-13 12:41:02 +00:00
marko
eb03297439 branches/zip: buf_page_init_for_read(): Defer the costly calls to
buf_buddy_alloc() until after the block has been found not to exist
in the buffer pool.

buf_buddy_alloc(), buf_buddy_alloc_low(): Make lru an output parameter.
Improve documentation.

buf_page_init_for_read(): Simplify the code.  Check buf_page_hash_get()
again if buf_buddy_alloc() released buf_pool->mutex.
2007-02-08 14:19:55 +00:00
marko
3b5c872916 branches/zip: buf_page_t: Add the in_page_hash and in_zip_hash
for extra validation in UNIV_DEBUG builds.
2007-01-24 10:36:05 +00:00
marko
f5652a6a1e branches/zip: Fix a bug in the buddy allocator.
buf_buddy_relocate_block(): New function, split from buf_buddy_relocate().
Return FALSE when buf_page_can_relocate() returns FALSE.

Fix some formatting in buf_buddy_free_low() and buf_page_init_for_read().
2007-01-19 12:27:47 +00:00
marko
d8536b0de8 branches/zip: Make mutex_own() work with UNIV_DEBUG, without UNIV_SYNC_DEBUG. 2007-01-18 18:29:12 +00:00
marko
696db2a49f branches/zip: buf_buddy_alloc_clean(): Remove bogus assertion ut_a(bpage)
and update the comments.
2007-01-16 08:59:39 +00:00
marko
b91b8f4937 branches/zip: Improve Valgrind diagnostics.
buf_buddy_relocate(): Document that src may have been split and some of
it may be in buf_pool->zip_free[j] for some j<i, thus mach_read_from_4()
may be reading from free memory.  Check buffer pages only for addressability,
not for being completely initialized.  Ensure that block descriptors are
completely initialized.

buf_buddy_remove_from_free(): Check prev->state and next->state in
UNIV_DEBUG && UNIV_DEBUG_VALGRIND builds.

buf_buddy_free_low(): Flag the entire block valid prior to invoking
buf_buddy_remove_from_free() in order to avoid a Valgrind warning about
the debug assertion on bpage->state.  Remove the Valgrind check for
buddy being completely allocated.  If it has been split to smaller blocks,
some of those blocks may be free.
2007-01-12 22:23:12 +00:00
marko
e7d8e53793 branches/zip: buf_buddy_relocate(): Add Valgrind checks. 2007-01-12 14:30:18 +00:00
marko
8420d4b668 branches/zip: Add the buf_pool->zip_free[] accessor functions
buf_buddy_add_to_free() and buf_buddy_remove_from_free().
Remove some bogus Valgrind warnings.  Improve Valgrind instrumentation.
2007-01-12 14:18:22 +00:00
marko
5637695ad2 branches/zip: Improve Valgrind instrumentation of allocated memory.
UNIV_MEM_FREE(): Declare a memory area free.
UNIV_MEM_ALLOC(): Declare a memory area allocated (but uninitialized).
UNIV_MEM_DESC(): Associate a memory area with a control block.
UNIV_MEM_UNDESC(): Unassociate a control block.

trx_sys_create_doublewrite_buf(): Clear the buffer with memset().

buf_page_init(): Add a bogus UNIV_MEM_VALID(block->frame) to silence
valid warnings about InnoDB data pages containing uninitialized data.

buf_LRU_get_free_only(): Add UNIV_MEM_ALLOC(block->frame).

buf_LRU_get_free_block(): Add UNIV_MEM_DESC(block->page.zip.data, block).

buf_LRU_free_block(): Add UNIV_MEM_DESC(b->zip.data, b) when allocating
a compressed-only control block for a compressed page.

buf_LRU_block_free_non_file_page(): Replace UNIV_MEM_INVALID() with
UNIV_MEM_FREE().

buf_LRU_block_remove_hashed_page(): Add UNIV_MEM_UNDESC(bpage) when
deallocating a compressed-only control block.  Add
UNIV_MEM_INVALID(block->frame).  (The frame should be flagged free
by buf_LRU_block_free_non_file_page() moments later.)

buf0buddy.c: Disable some extra checks in Valgrind-instrumented builds.
Add UNIV_MEM_VALID(), UNIV_MEM_INVALID(), UNIV_MEM_FREE(), UNIV_MEM_ALLOC()
as necessary.
2007-01-12 12:36:40 +00:00
marko
069514dee7 branches/zip: buf_relocate(): Copy the block. Invalidate the source block.
buf_buddy_block_free(), buf_buddy_free_low(): Flag the freed bytes
uninitialized.

buf_page_init_for_read(), buf_buddy_relocate(): Do not refer to bpage
after invoking buf_relocate().

buf_buddy_relocate(): Flag src uninitialized.
2007-01-12 09:14:15 +00:00
marko
d01ae09cca branches/zip: buf_buddy_free(): Add debug code for detecting live
objects in the free area.
2007-01-09 16:11:11 +00:00
marko
10c92bd7ac branches/zip: buf_buddy_alloc_clean(): Restart the scan after a
successful buf_LRU_free_block().

buf_LRU_free_block(): Note that buf_pool->mutex may be temporarily released.
2007-01-09 12:39:50 +00:00
marko
b75e9777dd branches/zip: buf_pool_page_hash_rebuild(): Rebuild also buf_pool->zip_hash
and add compressed-only pages to buf_pool->page_hash.

BUF_POOL_ZIP_FOLD(), BUF_POOL_ZIP_FOLD_PTR(), BUF_POOL_ZIP_FOLD_BPAGE():
Macros for computing buf_pool->zip_hash fold values.  Make use of these
in buf0buddy.c.

buf0buddy.c: Replace some ptr == ut_align_down(ptr, ...) in assertions with
!ut_align_offset(ptr, ...).
2007-01-05 10:49:56 +00:00
marko
14b99876d0 branches/zip: Allow dirty blocks to be relocated. Allow a transition
to BUF_BLOCK_ZIP_DIRTY (discarding the uncompressed page corresponding
to a modified compressed page that has not been flushed to disk).

buf_page_can_relocate(): New function, modelled after
buf_flush_ready_for_replace().

buf_LRU_free_block(): Allow the transition to BUF_BLOCK_ZIP_DIRTY.

buf_flush_insert_into_flush_list(): Make the prototype public.

buf_buddy_relocate(): Remove an unnecessary switch statement.
Use buf_page_can_relocate() instead of buf_flush_ready_for_replace().

buf_page_peek(): Made UNIV_INLINE.

Document UNIV_ZIP_DEBUG.
2007-01-04 21:40:10 +00:00
marko
4861c59c59 branches/zip: Fix two bugs in the relocation of block descriptors.
Improve diagnostics.

buf_buddy_relocate(): Do not assume all small blocks to contain only one
buf_page_t object.  Require an exact size match, as in the case of
compressed pages.

buf_relocate(): Relocate buf_pool->LRU_old if needed.
Validate the LRU list in debug builds.

buf_LRU_block_remove_hashed_page(): Do not overwrite FIL_PAGE_OFFSET
or FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID.  The memory will be invalidated
in debug builds of buf_buddy_free().

buf0buddy.c: Add assertions for not holding buf_pool->zip_mutex.
The calling thread should not be holding any block->mutex, but it might
be too time-consuming to assert against that, even #ifdef UNIV_SYNC_DEBUG.
2007-01-04 15:45:42 +00:00
marko
0792d70524 branches/zip: Minor cleanup.
buf_buddy_get(): New function in buf0buddy.c, to replace the macro
in buf0buddy.h.

buf_buddy_get_offset(): Remove.

buf_buddy_get_slot(): Remove the prototype from buf0buddy.h.  This function
is for internal use in buf0buddy.ic.
2006-12-29 09:13:57 +00:00
marko
a9f0595aba branches/zip: Fix two bugs in the buddy allocator.
buf_buddy_block_free(): Remove the block from buf_pool->zip_hash.

buf_buddy_alloc_clean(): Test for buf_page_in_file() before
invoking buf_LRU_free_block().  The LRU list also contains "half-freed"
blocks (state == BUF_BLOCK_REMOVE_HASH).
2006-12-21 14:59:41 +00:00
marko
13049a9e3a branches/zip: Allow the buddy allocator to work for 16-kilobyte pages,
twice the maximum block size of the buddy system.

buf_page_t: Note that state may change from BUF_BLOCK_READY_FOR_USE
to BUF_BLOCK_MEMORY without buf_page_get_mutex() protection
[only buf_pool->mutex].

buf_buddy_get_slot(): Extend the output to BUF_BUDDY_SIZES.

buf_buddy_alloc(), buf_buddy_free(): Allow sizes up to UNIV_PAGE_SIZE.

buf_buddy_alloc_low(), buf_buddy_free_low(), buf_buddy_alloc_clean():
Allow i==BUF_BUDDY_SIZES.
2006-12-20 15:56:58 +00:00
marko
a03c082c8f branches/zip: buf_buddy_free_low(): When trying to relocate to a block on
the free list, remove the free block from the free list, so that the list
item pointers will not be overwritten.
2006-12-20 13:29:02 +00:00
marko
2c6685709b branches/zip: Fix bugs in the buddy allocator and add assertions.
buf_buddy_free(), buf_buddy_free_low(): Document that the data must
not be pointed to by the buffer pool.  Add ut_ad(!buf_pool_contains_zip())
assertions to catch pointers to freed blocks.

Validate the zip_free[] lists #ifdef UNIV_DEBUG.

buf_buddy_relocate(): Ensure that the size of the compressed page
matches.  The buddy block can be split, and the control block can be
pointing to a smaller compressed page than the one whose relocation
is being attempted.
2006-12-20 11:38:19 +00:00
marko
9326dca349 branches/zip: Correct some bugs in the buddy allocator and add debug code.
buf_buddy_alloc_zip() [UNIV_DEBUG]: Byte-fill the allocated blocks with ~i.

buf_buddy_block_free() [UNIV_DEBUG]: Clear the frame before releasing it
to the buffer pool.

buf_buddy_alloc_from() [UNIV_DEBUG]: Byte-fill the free blocks with j.

buf_buddy_relocate(): Allow the buf_page_hash_get() lookup to fail,
and note the reason.

buf_buddy_free_low(): Correctly compute the address of the combined free block.

buf_page_struct: Clarify the mutex protection rules.  Note that
the pointer zip.data is also protected by buf_pool->mutex.
2006-12-19 12:38:18 +00:00
marko
82ce646283 branches/zip: buf_buddy_free_low(): Examine the state bits inside the
block before traversing the free list.
2006-12-18 12:55:04 +00:00
marko
88c6f95b59 branches/zip: buf_buddy_free_low(): Use a byte pointer in arithmetics.
buf_buddy_get(): Document that "page" should be a pointer to char or byte.
2006-12-18 12:39:39 +00:00
marko
be0832471b branches/zip: Fix some bugs in the buddy allocator.
buf_buddy_alloc_zip(): Calculate the address with char* aritmetics.

buf_buddy_alloc_clean(): Acquire a mutex on the block before
calling buf_LRU_free_block().

buf_buddy_relocate(): Remove the bogus assertion about src and dst
being buddies of each other.  Use mach_read_from_4() instead of
page_get_space_id() and page_get_page_no() to avoid page alignment
assertions.

buf_buddy_free_low(): Replace bogus assertions.
2006-12-18 11:23:58 +00:00
marko
a687ccdf74 branches/zip: Minor improvements.
buf_LRU_block_remove_hashed_page(): Return the new state of the block.

Only call buf_LRU_block_free_hashed_page()
if buf_LRU_block_remove_hashed_page() did not return BUF_BLOCK_ZIP_FREE,
that is, the control block was not freed.

buf_LRU_insert_zip_clean(): New function, for inserting a compressed-only
block into buf_pool->zip_clean in the LRU order.

buf_LRU_block_remove_hashed_page(), buf_LRU_free_block():
Add the flag "zip" for controlling if the compressed page of an uncompressed
page should be removed.  For now, assume zip==TRUE.

buf_LRU_get_free_block(): Replace the test for UT_LIST_GET_LEN(buf_pool->free)
with a test for the return value of buf_LRU_get_free_only().  Do not
free zip.data, as it must already have been freed.

buf_flush_insert_into_flush_list(), buf_flush_insert_sorted_into_flush_list():
Remove compressed-only blocks from the buf_pool->zip_clean list.

buf_flush_remove(): Restore compressed-only blocks to
the buf_pool->zip_clean list.

buf_page_init_for_read(): Uncompress compressed-only blocks when possible.
Currently, there cannot be any compressed-only blocks in the buffer pool;
they would be inserted by buf_LRU_free_block(bpage, zip=FALSE).
2006-12-15 15:05:18 +00:00
marko
255a9a878a branches/zip: Refactor some code for relocating buffer control blocks.
buf_relocate(): New function, split from buf_buddy_relocate().
2006-12-14 15:15:51 +00:00
marko
2208d25976 branches/zip: Make use of the previously unused state BUF_BLOCK_MEMORY.
buf_LRU_get_free_block(): Document that the block is in the state
BUF_BLOCK_READY_FOR_USE.

buf_block_alloc(): Change the state of the block to BUF_BLOCK_MEMORY
and document it.

Replace those invocations of buf_block_alloc() with
buf_LRU_get_free_block() where the allocated block is used for buffer
pool input and output.  However, temporary copies of B-tree pages
during reorganization are not used for file I/O, and such blocks are
still allocated with buf_block_alloc().
2006-12-13 14:58:54 +00:00
marko
886e6b9fc4 branches/zip: Make the buddy allocator reclaim blocks from the end of
the LRU list regardless of their size.

buf_buddy_alloc_clean_zip(): Rename to buf_buddy_alloc_clean(),
now that also uncompressed blocks can be reclaimed.
Use buf_buddy_alloc_zip() instead of reusing the freed block
directly, since buf_buddy_free() may combine blocks.
2006-12-12 16:28:22 +00:00
marko
72c4ca2025 branches/zip: Minor improvements to the buddy allocator.
buf_buddy_alloc(), buf_buddy_alloc_low(): Add parameter "lru" for
enabling allocation from the list of least-recently-used blocks.

buf_buddy_alloc_low(): Release buf_pool->mutex while calling
buf_LRU_get_free_block().
2006-12-12 12:14:58 +00:00
marko
a1b5040567 branches/zip: Make the code compile with all debugging enabled
buf_buddy_relocate(): Replace ut_align_down() with ut_align_offset()
in assertions.

buf0buddy.h: Include buf0buf.h and sync0sync.h.
2006-12-11 15:48:37 +00:00
marko
8e3e3d16d3 branches/zip: Implement the whole allocation algorithm of compressed pages.
buf_LRU_free_block(): Free compressed-only pages and their
descriptors with buf_buddy_free().

buf_LRU_get_free_only(): New function for returning a block from
buf_pool->free if one is available.  Split from buf_LRU_get_free_block().

buf_buddy_alloc_zip(): Rename from buf_buddy_alloc_low() and make static.
Remove parameter "split".  Always try to split.

buf_buddy_free_block(): Rename to buf_buddy_block_free().

buf_buddy_block_register(): New function for registering buf_block_t
objects reserved by the allocator.

buf_buddy_alloc_from(): New function for allocating an object from a
bigger object, and putting the unused parts on the free list.

buf_buddy_alloc_clean_zip(): New function for allocating memory by
replacing an unmodified compressed page.

buf_buddy_alloc_low(): New function for allocating memory, either from
the free lists of compressed pages, from the global free list, or from
unmodified pages in the buffer pool.
2006-12-11 14:27:43 +00:00
marko
edaacca092 branches/zip: buf_buddy_relocate(): Split some lines differently on
popular demand.
2006-12-11 09:59:06 +00:00
marko
76c69c3610 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.
2006-12-11 09:54:13 +00:00
marko
2d7dc7e6b8 branches/zip: buf_buddy_relocate(): Relocate buf_page_t objects that represent
clean compressed pages (BUF_BLOCK_ZIP_PAGE).
2006-12-11 08:43:55 +00:00
marko
5b24b43055 branches/zip: buf_buddy_free_low(): Attempt to relocate the buddy of a
free block in order to create two adjacent free blocks that can be
recombined.  Add some debug assertions.

buf_buddy_relocate(): New function: Try to relocate a free block.
2006-12-08 14:44:28 +00:00
marko
07d7f05ff6 branches/zip: Add buf_buddy_free() and buf_buddy_free_low(). 2006-12-07 15:22:44 +00:00
marko
4fdc425820 branches/zip: Rename buf_buddy_alloc_free() to buf_buddy_alloc() and
buf_buddy_alloc_free_low() to buf_buddy_alloc_low().
2006-12-07 15:05:06 +00:00
marko
dbb8790ddf branches/zip: buf_buddy_alloc_free(), buf_buddy_alloc_free_low():
Add parameter "split" for enabling splits.
2006-12-07 14:58:58 +00:00
marko
e8babaee1b branches/zip: Add the first bits of the binary buddy system for allocating
compressed pages from the buffer pool.

Makefile.am: Add buf0buddy.h, buf0buddy.ic.

buf/Makefile.am: Add buf0buddy.c.

Introduce the constants BUF_BUDDY_LOW and BUF_BUDDY_SIZES.

buf_pool_t: Add zip_mutex and the lists zip_clean and zip_free[].

buf_page_get_mutex(): Return &buf_pool->zip_mutex instead of NULL.

buf_buddy_get_offset(), buf_buddy_get(), buf_buddy_get_slot(),
buf_buddy_alloc_free(), buf_buddy_alloc_free_low(): New functions.
2006-12-07 13:29:04 +00:00