diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-11-16 19:55:06 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-11-18 17:47:19 +0200 |
commit | aaef2e1d8c843d1e40b1ce0c5199c3abb3c5da28 (patch) | |
tree | e1cf32baf32aecdeafe8a3ad259b3d1f3a631ffc /storage/innobase/buf/buf0buddy.cc | |
parent | db915f738709a1988420e73522f5a3e6515d17e9 (diff) | |
download | mariadb-git-aaef2e1d8c843d1e40b1ce0c5199c3abb3c5da28.tar.gz |
MDEV-27058: Reduce the size of buf_block_t and buf_page_t
buf_page_t::frame: Moved from buf_block_t::frame.
All 'thin' buf_page_t describing compressed-only ROW_FORMAT=COMPRESSED
pages will have frame=nullptr, while all 'fat' buf_block_t
will have a non-null frame pointing to aligned innodb_page_size bytes.
This eliminates the need for separate states for
BUF_BLOCK_FILE_PAGE and BUF_BLOCK_ZIP_PAGE.
buf_page_t::lock: Moved from buf_block_t::lock. That is, all block
descriptors will have a page latch. The IO_PIN state that was used
for discarding or creating the uncompressed page frame of a
ROW_FORMAT=COMPRESSED block is replaced by a combination of read-fix
and page X-latch.
page_zip_des_t::fix: Replaces state_, buf_fix_count_, io_fix_, status
of buf_page_t with a single std::atomic<uint32_t>. All modifications
will use store(), fetch_add(), fetch_sub(). This space was previously
wasted to alignment on 64-bit systems. We will use the following encoding
that combines a state (partly read-fix or write-fix) and a buffer-fix
count:
buf_page_t::NOT_USED=0 (previously BUF_BLOCK_NOT_USED)
buf_page_t::MEMORY=1 (previously BUF_BLOCK_MEMORY)
buf_page_t::REMOVE_HASH=2 (previously BUF_BLOCK_REMOVE_HASH)
buf_page_t::FREED=3 + fix: pages marked as freed in the file
buf_page_t::UNFIXED=1U<<29 + fix: normal pages
buf_page_t::IBUF_EXIST=2U<<29 + fix: normal pages; may need ibuf merge
buf_page_t::REINIT=3U<<29 + fix: reinitialized pages (skip doublewrite)
buf_page_t::READ_FIX=4U<<29 + fix: read-fixed pages (also X-latched)
buf_page_t::WRITE_FIX=5U<<29 + fix: write-fixed pages (also U-latched)
buf_page_t::WRITE_FIX_IBUF=6U<<29 + fix: write-fixed; may have ibuf
buf_page_t::WRITE_FIX_REINIT=7U<<29 + fix: write-fixed (no doublewrite)
buf_page_t::write_complete(): Change WRITE_FIX or WRITE_FIX_REINIT to
UNFIXED, and WRITE_FIX_IBUF to IBUF_EXIST, before releasing the U-latch.
buf_page_t::read_complete(): Renamed from buf_page_read_complete().
Change READ_FIX to UNFIXED or IBUF_EXIST, before releasing the X-latch.
buf_page_t::can_relocate(): If the page latch is being held or waited for,
or the block is buffer-fixed or io-fixed, return false. (The condition
on the page latch is new.)
Outside buf_page_get_gen(), buf_page_get_low() and buf_page_free(), we
will acquire the page latch before fix(), and unfix() before unlocking.
buf_page_t::flush(): Replaces buf_flush_page(). Optimize the
handling of FREED pages.
buf_pool_t::release_freed_page(): Assume that buf_pool.mutex is held
by the caller.
buf_page_t::is_read_fixed(), buf_page_t::is_write_fixed(): New predicates.
buf_page_get_low(): Ignore guesses that are read-fixed because they
may not yet be registered in buf_pool.page_hash and buf_pool.LRU.
buf_page_optimistic_get(): Acquire latch before buffer-fixing.
buf_page_make_young(): Leave read-fixed blocks alone, because they
might not be registered in buf_pool.LRU yet.
recv_sys_t::recover_deferred(), recv_sys_t::recover_low():
Possibly fix MDEV-26326, by holding a page X-latch instead of
only buffer-fixing the page.
Diffstat (limited to 'storage/innobase/buf/buf0buddy.cc')
-rw-r--r-- | storage/innobase/buf/buf0buddy.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/storage/innobase/buf/buf0buddy.cc b/storage/innobase/buf/buf0buddy.cc index 125dac5333e..3d476fbac77 100644 --- a/storage/innobase/buf/buf0buddy.cc +++ b/storage/innobase/buf/buf0buddy.cc @@ -354,11 +354,11 @@ buf_buddy_block_free(void* buf) ut_a(!ut_align_offset(buf, srv_page_size)); HASH_SEARCH(hash, &buf_pool.zip_hash, fold, buf_page_t*, bpage, - ut_ad(bpage->state() == BUF_BLOCK_MEMORY + ut_ad(bpage->state() == buf_page_t::MEMORY && bpage->in_zip_hash), - ((buf_block_t*) bpage)->frame == buf); + bpage->frame == buf); ut_a(bpage); - ut_a(bpage->state() == BUF_BLOCK_MEMORY); + ut_a(bpage->state() == buf_page_t::MEMORY); ut_ad(bpage->in_zip_hash); ut_d(bpage->in_zip_hash = false); HASH_DELETE(buf_page_t, hash, &buf_pool.zip_hash, fold, bpage); @@ -383,10 +383,10 @@ buf_buddy_block_register( buf_block_t* block) /*!< in: buffer frame to allocate */ { const ulint fold = BUF_POOL_ZIP_FOLD(block); - ut_ad(block->page.state() == BUF_BLOCK_MEMORY); + ut_ad(block->page.state() == buf_page_t::MEMORY); - ut_a(block->frame); - ut_a(!ut_align_offset(block->frame, srv_page_size)); + ut_a(block->page.frame); + ut_a(!ut_align_offset(block->page.frame, srv_page_size)); ut_ad(!block->page.in_zip_hash); ut_d(block->page.in_zip_hash = true); @@ -462,8 +462,8 @@ byte *buf_buddy_alloc_low(ulint i, bool *lru) alloc_big: buf_buddy_block_register(block); - block = (buf_block_t*) buf_buddy_alloc_from( - block->frame, i, BUF_BUDDY_SIZES); + block = reinterpret_cast<buf_block_t*>( + buf_buddy_alloc_from(block->page.frame, i, BUF_BUDDY_SIZES)); func_exit: buf_pool.buddy_stat[i].used++; @@ -694,7 +694,7 @@ buf_buddy_realloc(void* buf, ulint size) block = reinterpret_cast<buf_block_t*>( buf_buddy_alloc_from( - block->frame, i, BUF_BUDDY_SIZES)); + block->page.frame, i, BUF_BUDDY_SIZES)); } buf_pool.buddy_stat[i].used++; |