Commit 0308de94 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-17138 follow-up: Optimize fseg_create()

fseg_create(): Initialize FSEG_FRAG_ARRY by a single MLOG_MEMSET record.

flst_zero_addr(), flst_init(): Optimize away redundant writes.

fseg_free_page_low(): Write FIL_NULL by MLOG_MEMSET.
parent 3da895a7
......@@ -1881,7 +1881,6 @@ fseg_create(
buf_block_t* block = 0; /* remove warning */
fseg_header_t* header = 0; /* remove warning */
ulint n_reserved;
ulint i;
DBUG_ENTER("fseg_create");
......@@ -1927,9 +1926,8 @@ fseg_create(
seg_id = mach_read_from_8(space_header + FSP_SEG_ID);
mlog_write_ull(space_header + FSP_SEG_ID, seg_id + 1, mtr);
mlog_write_ull(inode + FSEG_ID, seg_id, mtr);
mlog_write_ulint(inode + FSEG_NOT_FULL_N_USED, 0, MLOG_4BYTES, mtr);
ut_ad(!mach_read_from_4(inode + FSEG_NOT_FULL_N_USED));
flst_init(inode + FSEG_FREE, mtr);
flst_init(inode + FSEG_NOT_FULL, mtr);
......@@ -1937,9 +1935,10 @@ fseg_create(
mlog_write_ulint(inode + FSEG_MAGIC_N, FSEG_MAGIC_N_VALUE,
MLOG_4BYTES, mtr);
for (i = 0; i < FSEG_FRAG_ARR_N_SLOTS; i++) {
fseg_set_nth_frag_page_no(inode, i, FIL_NULL, mtr);
}
compile_time_assert(FSEG_FRAG_SLOT_SIZE == 4);
compile_time_assert(FIL_NULL == 0xffffffff);
mlog_memset(inode + FSEG_FRAG_ARR,
FSEG_FRAG_SLOT_SIZE * FSEG_FRAG_ARR_N_SLOTS, 0xff, mtr);
if (page == 0) {
block = fseg_alloc_free_page_low(space,
......@@ -2772,15 +2771,16 @@ fseg_free_page_low(
if (state != XDES_FSEG) {
/* The page is in the fragment pages of the segment */
for (ulint i = 0;; i++) {
if (fseg_get_nth_frag_page_no(seg_inode, i, mtr)
== offset) {
fseg_set_nth_frag_page_no(seg_inode, i,
FIL_NULL, mtr);
break;
!= offset) {
continue;
}
compile_time_assert(FIL_NULL == 0xffffffff);
mlog_memset(seg_inode + FSEG_FRAG_ARR
+ i * FSEG_FRAG_SLOT_SIZE, 4, 0xff, mtr);
break;
}
fsp_free_page(space, offset, log, mtr);
......
......@@ -85,8 +85,12 @@ inline void flst_init(buf_block_t* block, uint16_t ofs, mtr_t* mtr)
@param[in,out] mtr mini-transaction */
inline void flst_zero_addr(fil_faddr_t* faddr, mtr_t* mtr)
{
mlog_memset(faddr + FIL_ADDR_PAGE, 4, 0xff, mtr);
mlog_write_ulint(faddr + FIL_ADDR_BYTE, 0, MLOG_2BYTES, mtr);
if (mach_read_from_4(faddr + FIL_ADDR_PAGE) != FIL_NULL) {
mlog_memset(faddr + FIL_ADDR_PAGE, 4, 0xff, mtr);
}
if (mach_read_from_2(faddr + FIL_ADDR_BYTE)) {
mlog_write_ulint(faddr + FIL_ADDR_BYTE, 0, MLOG_2BYTES, mtr);
}
}
/********************************************************************//**
......
......@@ -82,7 +82,9 @@ flst_init(
MTR_MEMO_PAGE_X_FIX
| MTR_MEMO_PAGE_SX_FIX));
mlog_write_ulint(base + FLST_LEN, 0, MLOG_4BYTES, mtr);
if (mach_read_from_4(base + FLST_LEN)) {
mlog_write_ulint(base + FLST_LEN, 0, MLOG_4BYTES, mtr);
}
flst_zero_addr(base + FLST_FIRST, mtr);
flst_zero_addr(base + FLST_LAST, mtr);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment