Commit graph

18 commits

Author SHA1 Message Date
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