MySQL 5.6.14 Source Code Document
|
#include "buf0buddy.h"
#include "buf0buf.h"
#include "buf0lru.h"
#include "buf0flu.h"
#include "page0zip.h"
#include "srv0start.h"
Go to the source code of this file.
Classes | |
struct | CheckZipFree |
Macros | |
#define | THIS_MODULE |
#define | BUF_BUDDY_STAMP_OFFSET FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID |
#define | BUF_BUDDY_STAMP_FREE (SRV_LOG_SPACE_FIRST_ID) |
#define | BUF_BUDDY_STAMP_NONFREE (0XFFFFFFFF) |
#define | buf_buddy_mem_invalid(buf, i) ut_ad((i) <= BUF_BUDDY_SIZES) |
#define | buf_buddy_stamp_nonfree(buf, i) |
#define | BUF_BUDDY_LIST_VALIDATE(bp, i) |
Enumerations | |
enum | buf_buddy_state_t { BUF_BUDDY_STATE_FREE, BUF_BUDDY_STATE_USED, BUF_BUDDY_STATE_PARTIALLY_USED } |
Functions | |
UNIV_INLINE | __attribute__ ((warn_unused_result)) bool buf_buddy_stamp_is_free(const buf_buddy_free_t *buf) |
UNIV_INLINE void | buf_buddy_stamp_free (buf_buddy_free_t *buf, ulint i) |
UNIV_INLINE void * | buf_buddy_get (byte *page, ulint size) |
Binary buddy allocator for compressed pages
Created December 2006 by Marko Makela
Definition in file buf0buddy.cc.
#define BUF_BUDDY_LIST_VALIDATE | ( | bp, | |
i | |||
) |
Definition at line 189 of file buf0buddy.cc.
#define BUF_BUDDY_STAMP_FREE (SRV_LOG_SPACE_FIRST_ID) |
Value that we stamp on all buffers that are currently on the zip_free
list. This value is stamped at BUF_BUDDY_STAMP_OFFSET offset
Definition at line 74 of file buf0buddy.cc.
#define BUF_BUDDY_STAMP_NONFREE (0XFFFFFFFF) |
Stamp value for non-free buffers. Will be overwritten by a non-zero
value by the consumer of the block
Definition at line 78 of file buf0buddy.cc.
Stamps a buddy nonfree.
in/out] | buf block to stamp | |
[in] | i | block size |
Definition at line 145 of file buf0buddy.cc.
#define BUF_BUDDY_STAMP_OFFSET FIL_PAGE_ARCH_LOG_NO_OR_SPACE_ID |
When freeing a buf we attempt to coalesce by looking at its buddy
and deciding whether it is free or not. To ascertain if the buddy is free we look for BUF_BUDDY_STAMP_FREE at BUF_BUDDY_STAMP_OFFSET within the buddy. The question is how we can be sure that it is safe to look at BUF_BUDDY_STAMP_OFFSET. The answer lies in following invariants: All blocks allocated by buddy allocator are used for compressed page frame. A compressed table always have space_id < SRV_LOG_SPACE_FIRST_ID BUF_BUDDY_STAMP_OFFSET always points to the space_id field in a frame. – The above is true because we look at these fields when the corresponding buddy block is free which implies that: The block we are looking at must have an address aligned at the same size that its free buddy has. For example, if we have a free block of 8K then its buddy's address must be aligned at 8K as well. It is possible that the block we are looking at may have been further divided into smaller sized blocks but its starting address must still remain the start of a page frame i.e.: it cannot be middle of a block. For example, if we have a free block of size 8K then its buddy may be divided into blocks of, say, 1K, 1K, 2K, 4K but the buddy's address will still be the starting address of first 1K compressed page. What is important to note is that for any given block, the buddy's address cannot be in the middle of a larger block i.e.: in above example, our 8K block cannot have a buddy whose address is aligned on 8K but it is part of a larger 16K block. Offset within buf_buddy_free_t where free or non_free stamps are written.
Definition at line 70 of file buf0buddy.cc.
enum buf_buddy_state_t |
Return type of buf_buddy_is_free()
BUF_BUDDY_STATE_FREE |
If the buddy to completely free |
BUF_BUDDY_STATE_USED |
Buddy currently in used |
BUF_BUDDY_STATE_PARTIALLY_USED |
Some sub-blocks in the buddy are in use |
Definition at line 85 of file buf0buddy.cc.
UNIV_INLINE __attribute__ | ( | (warn_unused_result) | ) | const |
Check if a buddy is stamped free.
< in: block to check
Checks if a buf is free i.e.: in the zip_free[].
BUF_BUDDY_STATE_FREE | if fully free |
BUF_BUDDY_STATE_USED | if currently in use |
BUF_BUDDY_STATE_PARTIALLY_USED | if partially in use. |
Definition at line 115 of file buf0buddy.cc.
UNIV_INLINE void* buf_buddy_get | ( | byte * | page, |
ulint | size | ||
) |
Get the offset of the buddy of a compressed page frame.
page | in: compressed page |
size | in: page size in bytes |
Definition at line 158 of file buf0buddy.cc.
UNIV_INLINE void buf_buddy_stamp_free | ( | buf_buddy_free_t * | buf, |
ulint | i | ||
) |
Stamps a buddy free.
buf | in/out: block to stamp |
i | in: block size |
Definition at line 129 of file buf0buddy.cc.