Skip to content

Commit 6a562e8

Browse files
committed
implement bit_arr to speed up searching the first free slot in a pline
1 parent 3d59c61 commit 6a562e8

File tree

4 files changed

+666
-57
lines changed

4 files changed

+666
-57
lines changed

storage/innobase/buf/buf0flu.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3654,6 +3654,28 @@ buf_flush_request_force(
36543654
os_event_set(buf_flush_event);
36553655
}
36563656
#if defined (UNIV_PMEMOBJ_PART_PL)
3657+
void
3658+
pm_ppl_buf_flush_recv_note_modification(
3659+
PMEMobjpool* pop,
3660+
PMEM_PAGE_PART_LOG* ppl,
3661+
buf_block_t* block,
3662+
lsn_t start_lsn,
3663+
lsn_t end_lsn)
3664+
{
3665+
buf_page_mutex_enter(block);
3666+
3667+
block->page.newest_modification = end_lsn;
3668+
if (!block->page.oldest_modification) {
3669+
buf_pool_t* buf_pool = buf_pool_from_block(block);
3670+
3671+
buf_flush_insert_sorted_into_flush_list(
3672+
buf_pool, block, start_lsn);
3673+
} else {
3674+
ut_ad(block->page.oldest_modification <= start_lsn);
3675+
}
3676+
3677+
buf_page_mutex_exit(block);
3678+
}
36573679
/*
36583680
*Called by pm_ppl_checkpoint()
36593681
* */

storage/innobase/include/my_pmemobj.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,17 @@ struct plog_hash_t {
571571
* A hashed line has array of log blocks share the same hashed value and log buffer
572572
* */
573573
struct __pmem_page_log_hashed_line {
574+
/*general lock protect data in PART 1 and PART 3*/
574575
PMEMrwlock lock;
575576

577+
/*PART 1, writing log rec to logbuf*/
576578
int hashed_id;
577579
TOID(PMEM_PAGE_LOG_BUF) logbuf; //pointer to current log buffer (head)
578580
TOID(PMEM_PAGE_LOG_BUF) tail_logbuf; //pointer to the oldest log buffer (tail)
579581

582+
os_event_t log_flush_event;
583+
bool is_flushing;
584+
580585
uint64_t diskaddr; //log file offset, update when flush log, reset when purging file
581586
uint64_t write_diskaddr; //diskaddr that log recs are durable write write_diskaddr < diskaddr
582587

@@ -589,7 +594,9 @@ struct __pmem_page_log_hashed_line {
589594
uint64_t recv_diskaddr; //the diskaddr begin the recover, min of log blocks diskaddr
590595
uint64_t recv_off; //the offset begin the recover
591596
uint64_t recv_lsn; //min lsn of block's beginLSN in this line
592-
/*end test */
597+
598+
/*PART 2, metadata: log_block array, hashtable, std::map*/
599+
PMEMrwlock meta_lock;
593600

594601
TOID_ARRAY(TOID(PMEM_PAGE_LOG_BLOCK)) arr;
595602
uint64_t n_blocks; //the current non-free blocks
@@ -602,6 +609,7 @@ struct __pmem_page_log_hashed_line {
602609

603610
std::map<uint64_t, uint32_t>* offset_map;
604611

612+
/*PART 3: recovery*/
605613
//Alternative to recv_sys_t in InnoDB, allocate in DRAM when recovery
606614
PMEM_RECV_LINE* recv_line;
607615
bool is_redoing;
@@ -1118,6 +1126,11 @@ void
11181126
pm_ppl_init_in_mem(
11191127
PMEMobjpool* pop,
11201128
PMEM_PAGE_PART_LOG* ppl);
1129+
1130+
void
1131+
pm_ppl_free_in_mem(
1132+
PMEMobjpool* pop,
1133+
PMEM_PAGE_PART_LOG* ppl);
11211134
void
11221135
pm_page_part_log_hash_create(
11231136
PMEMobjpool* pop,
@@ -1541,6 +1554,14 @@ pm_ppl_recv_apply_hashed_line(
15411554
PMEM_PAGE_LOG_HASHED_LINE* pline,
15421555
ibool allow_ibuf);
15431556

1557+
void
1558+
pm_ppl_buf_flush_recv_note_modification(
1559+
PMEMobjpool* pop,
1560+
PMEM_PAGE_PART_LOG* ppl,
1561+
buf_block_t* block,
1562+
lsn_t start_lsn,
1563+
lsn_t end_lsn);
1564+
15441565
void
15451566
pm_ppl_check_input_rec(
15461567
byte* ptr,
@@ -1575,18 +1596,21 @@ pm_ppl_remove_fil_spaces();
15751596
//////////// BIT ARRAY /////////
15761597
void
15771598
pm_bit_set(
1599+
PMEM_PAGE_LOG_HASHED_LINE* pline,
15781600
long long* arr,
15791601
size_t block_size,
15801602
uint64_t bit_i);
15811603

15821604
void
15831605
pm_bit_clear(
1606+
PMEM_PAGE_LOG_HASHED_LINE* pline,
15841607
long long* arr,
15851608
size_t block_size,
15861609
uint64_t bit_i);
15871610

15881611
int32_t
15891612
pm_search_first_free_slot(
1613+
PMEM_PAGE_LOG_HASHED_LINE* pline,
15901614
long long* bit_arr,
15911615
uint16_t n_bit_blocks,
15921616
uint16_t block_size);

storage/innobase/log/log0recv.cc

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ this must be less than UNIV_PAGE_SIZE as it is stored in the buffer pool */
8282
#define RECV_DATA_BLOCK_SIZE (MEM_MAX_ALLOC_IN_BUF - sizeof(recv_data_t))
8383

8484
/** Read-ahead area in applying log records to file pages */
85+
#if defined (UNIV_PMEMOBJ_PART_PL)
86+
#define RECV_READ_AHEAD_AREA 16
87+
#else //original
8588
#define RECV_READ_AHEAD_AREA 32
89+
#endif //UNIV_PMEMOBJ_PART_PL
8690

8791
/** The recovery system */
8892
recv_sys_t* recv_sys = NULL;
@@ -5950,10 +5954,13 @@ pm_ppl_recv_recover_page_func(
59505954
if (modification_to_page) {
59515955
ut_a(block);
59525956

5953-
log_flush_order_mutex_enter();
5954-
//buf_flush_recv_note_modification(block, start_lsn, end_lsn);
5955-
buf_flush_recv_note_modification(block, start_lsn, start_lsn);
5956-
log_flush_order_mutex_exit();
5957+
//log_flush_order_mutex_enter();
5958+
//buf_flush_recv_note_modification(block, start_lsn, start_lsn);
5959+
//log_flush_order_mutex_exit();
5960+
5961+
/*the flush_order_mutex may has high contention, try to simulate buf_flush_recv_note_modification()*/
5962+
pm_ppl_buf_flush_recv_note_modification(
5963+
pop, ppl, block, start_lsn, start_lsn);
59575964
}
59585965

59595966
/* Make sure that committing mtr does not change the modification lsn values of page */
@@ -6309,9 +6316,7 @@ pm_ppl_recv_apply_hashed_log_recs(
63096316
recv_line->is_ibuf_avail = allow_ibuf;
63106317
//Asign pline to a redoer thread
63116318
redoer->hashed_line_arr[i] = pline;
6312-
63136319
}
6314-
63156320

63166321
/*trigger REDOer threads phase 2.
63176322
* Call pm_ppl_recv_apply_hashed_line() */
@@ -6575,16 +6580,7 @@ pm_ppl_recv_apply_hashed_line(
65756580
mtr_commit(&mtr);
65766581
} else {
65776582
/* page is not cached, fetch it from disk and apply is done in IO thread -> pm_ppl_recv_recover_page_func */
6578-
6579-
/*read-ahead approach*/
65806583
pm_ppl_recv_read_in_area (pop, ppl, recv_line, page_id);
6581-
/*single read approach*/
6582-
6583-
// recv_line->n_read_reqs++;
6584-
6585-
// bool read_ok = buf_read_page(page_id, page_size);
6586-
6587-
// assert(read_ok);
65886584
}
65896585
}
65906586
cnt++;

0 commit comments

Comments
 (0)