Skip to content

Commit 3bb60c8

Browse files
committed
free bug implement DAL
1 parent 8070d4f commit 3bb60c8

File tree

11 files changed

+579
-851
lines changed

11 files changed

+579
-851
lines changed

build_mysql.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
MYSQL_HOME=/home/vldb/mysql-plnvm
33

44
#debug mode
5-
IS_DEBUG=0
6-
#IS_DEBUG=1
5+
#IS_DEBUG=0
6+
IS_DEBUG=1
77

88
#BUILD_NAME="-DUNIV_TRACE_FLUSH_TIME"
99
#BUILD_NAME="-DUNIV_TRACE_FLUSH_TIME -DUNIV_SKIPLOG"

storage/innobase/buf/buf0buf.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5842,7 +5842,8 @@ buf_page_io_complete(
58425842
}
58435843

58445844
#if defined (UNIV_PMEMOBJ_PART_PL)
5845-
skip_recv_page:
5845+
//Add read page to hash table
5846+
58465847
#endif
58475848
/* If space is being truncated then avoid ibuf operation.
58485849
During re-init we have already freed ibuf entries. */

storage/innobase/buf/buf0flu.cc

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3565,7 +3565,6 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(
35653565
#if defined (UNIV_PMEMOBJ_PART_PL)
35663566
//wake up the sleeping threads to close them
35673567

3568-
os_event_set(gb_pmw->ppl->catcher->is_log_req_not_empty);
35693568
os_event_set(gb_pmw->ppl->flusher->is_log_req_not_empty);
35703569
#endif
35713570
my_thread_end();
@@ -3986,11 +3985,6 @@ pm_log_flusher_init(
39863985
flusher->n_requested = 0;
39873986
flusher->is_running = false;
39883987

3989-
//partition array
3990-
flusher->part_list_arr = static_cast <PMEM_MINI_BUF**> ( calloc(size, sizeof(PMEM_MINI_BUF*)));
3991-
for (i = 0; i < size; i++) {
3992-
flusher->part_list_arr[i] = NULL;
3993-
}
39943988

39953989
//flush array
39963990
flusher->flush_list_arr = static_cast <PMEM_PAGE_LOG_BUF**> ( calloc(size, sizeof(PMEM_PAGE_LOG_BUF*)));
@@ -4013,16 +4007,6 @@ pm_log_flusher_close(
40134007

40144008
switch (flusher->type){
40154009
case CATCHER_LOG_BUF:
4016-
//free partition list
4017-
for (i = 0; i < flusher->size; i++) {
4018-
if (flusher->part_list_arr[i]){
4019-
flusher->part_list_arr[i] = NULL;
4020-
}
4021-
}
4022-
if (flusher->flush_list_arr){
4023-
free(flusher->flush_list_arr);
4024-
flusher->flush_list_arr = NULL;
4025-
}
40264010
break;
40274011
case FLUSHER_LOG_BUF:
40284012
default:
@@ -4126,83 +4110,6 @@ DECLARE_THREAD(pm_log_flusher_coordinator)(
41264110
OS_THREAD_DUMMY_RETURN;
41274111
}
41284112

4129-
/*Worker thread of log catcher.
4130-
* number of threads are equal to the number of cleaner threds from config
4131-
@return a dummy parameter */
4132-
extern "C"
4133-
os_thread_ret_t
4134-
DECLARE_THREAD(pm_log_catcher_worker)(
4135-
/*==========================================*/
4136-
void* arg MY_ATTRIBUTE((unused)))
4137-
/*!< in: a dummy parameter required by
4138-
os_thread_create */
4139-
{
4140-
ulint i;
4141-
4142-
PMEM_LOG_FLUSHER* catcher = gb_pmw->ppl->catcher;
4143-
4144-
PMEM_MINI_BUF* pmbuf = NULL;
4145-
4146-
my_thread_init();
4147-
4148-
mutex_enter(&catcher->mutex);
4149-
catcher->n_workers++;
4150-
os_event_reset(catcher->is_log_all_closed);
4151-
mutex_exit(&catcher->mutex);
4152-
4153-
while (true) {
4154-
//worker thread wait until there is is_requested signal
4155-
retry:
4156-
os_event_wait(catcher->is_log_req_not_empty);
4157-
//looking for a full list in wait-list and flush it
4158-
mutex_enter(&catcher->mutex);
4159-
if (catcher->n_requested > 0) {
4160-
for (i = 0; i < catcher->size; i++) {
4161-
pmbuf = catcher->part_list_arr[i];
4162-
if (pmbuf != NULL)
4163-
{
4164-
/*call back function*/
4165-
//printf("\t [CATCHER] thread #%zu BEGIN partition catcher->size %zu catcher->n_reqs %zu pmbuf id %zu\n", i, catcher->size, catcher->n_requested, pmbuf->id);
4166-
pm_log_partition_mini_buf(gb_pmw->pop, gb_pmw->ppl, pmbuf);
4167-
4168-
catcher->n_requested--;
4169-
os_event_set(catcher->is_log_req_full);
4170-
//we can set the pointer to null after the pm_buf_flush_list finished
4171-
//printf("\t [CATCHER] thread #%zu END partition catcher->size %zu catcher->n_reqs %zu pmbuf id %zu\n", i, catcher->size, catcher->n_requested, pmbuf->id);
4172-
catcher->part_list_arr[i] = NULL;
4173-
break;
4174-
}
4175-
}
4176-
4177-
} //end if flusher->n_requested > 0
4178-
4179-
if (catcher->n_requested == 0) {
4180-
if (buf_page_cleaner_is_active) {
4181-
//buf_page_cleaner is running, start waiting
4182-
os_event_reset(catcher->is_log_req_not_empty);
4183-
}
4184-
else {
4185-
mutex_exit(&catcher->mutex);
4186-
break;
4187-
}
4188-
}
4189-
mutex_exit(&catcher->mutex);
4190-
} //end while thread
4191-
4192-
mutex_enter(&catcher->mutex);
4193-
catcher->n_workers--;
4194-
if (catcher->n_workers == 0) {
4195-
printf("The last catcher worker is closing\n");
4196-
//os_event_set(flusher->is_all_closed);
4197-
}
4198-
mutex_exit(&catcher->mutex);
4199-
4200-
my_thread_end();
4201-
4202-
os_thread_exit();
4203-
4204-
OS_THREAD_DUMMY_RETURN;
4205-
}
42064113

42074114
/*Worker thread of log flusher.
42084115
* Managed by the coordinator thread

storage/innobase/buf/buf0rea.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Created 11/5/1995 Heikki Tuuri
4040
#include "srv0start.h"
4141
#include "srv0srv.h"
4242

43-
#if defined (UNIV_PMEMOBJ_BUF)
43+
#if defined (UNIV_PMEMOBJ_BUF) || defined (UNIV_PMEMOBJ_PART_PL)
4444
#include "my_pmemobj.h"
4545
#include <libpmemobj.h>
4646
extern PMEM_WRAPPER* gb_pmw;
@@ -271,6 +271,12 @@ buf_read_page_low(
271271
if (sync) {
272272
/* The i/o is already completed when we arrive from
273273
fil_read */
274+
#if defined (UNIV_PMEMOBJ_PART_PL)
275+
pm_ppl_hash_add_at_page_read(
276+
gb_pmw->pop,
277+
gb_pmw->ppl,
278+
bpage);
279+
#endif
274280
if (!buf_page_io_complete(bpage)) {
275281
return(0);
276282
}

storage/innobase/fil/fil0fil.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6864,6 +6864,12 @@ fil_aio_wait(
68646864
}
68656865
#else //original
68666866
buf_page_io_complete(static_cast<buf_page_t*>(message));
6867+
#if defined (UNIV_PMEMOBJ_PART_PL)
6868+
pm_ppl_hash_add_at_page_read(
6869+
gb_pmw->pop,
6870+
gb_pmw->ppl,
6871+
static_cast<buf_page_t*>(message));
6872+
#endif //UNIV_PMEMOBJ_PART_PL
68676873
#endif /* UNIV_PMEMOBJ_BUF*/
68686874
}
68696875
return;

storage/innobase/include/mtr0log.ic

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ mlog_write_initial_log_record_low(
200200

201201
mach_write_to_2(begin_log_ptr + prev_len_off, rec_size);
202202
mtr->add_size_at(rec_size, n_recs - 1);
203+
204+
//new in DAL (Direct Add Log), add the previous log rec to PPL
205+
uint64_t prev_key = mtr->get_key_at(n_recs - 1);
206+
uint64_t rec_lsn = mtr->get_LSN_at(n_recs - 1);
207+
208+
mtr->add_rec_to_ppl(prev_key, begin_log_ptr + prev_off, rec_size, rec_lsn);
203209
}
204210
else {
205211
//this is the first log rec in the mtr, do nothing
@@ -221,19 +227,20 @@ mlog_write_initial_log_record_low(
221227
log_ptr += 2;
222228

223229
/*reserve 8-byte for LSN, we write it later when log recs are written to PPL partition log buffer */
224-
//lsn = ut_time_us(NULL);
225-
//mach_write_to_8(log_ptr, lsn);
230+
lsn = ut_time_us(NULL);
231+
mtr->add_LSN(lsn);
232+
mach_write_to_8(log_ptr, lsn);
226233
log_ptr += 8;
227234

228235
//add info
229236

230237
//We compute the key as InnoDB
231238
key = (space_id << 20) + space_id + page_no;
232239
mtr->add_key(key);
233-
//mtr->add_LSN(lsn);
234240
mtr->add_type(type);
235241
mtr->add_space(space_id);
236242
mtr->add_page(page_no);
243+
237244

238245
mtr->added_rec();
239246
return(log_ptr);

storage/innobase/include/mtr0mtr.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,12 @@ struct mtr_t {
616616
}
617617

618618
#if defined (UNIV_PMEMOBJ_PL)
619+
void add_rec_to_ppl(
620+
uint64_t key,
621+
byte* src,
622+
uint32_t size,
623+
uint64_t rec_lsn);
624+
619625
byte* get_buf(){
620626
return (m_impl.buf);
621627
}
@@ -673,6 +679,11 @@ struct mtr_t {
673679
void add_key(uint64_t key){
674680
m_impl.key_arr[m_impl.m_n_log_recs] = key;
675681
}
682+
uint64_t get_key_at(uint32_t i){
683+
assert(i >= 0 && i < m_impl.m_n_log_recs);
684+
return (m_impl.key_arr[i]);
685+
}
686+
676687
void add_LSN(uint64_t LSN){
677688
m_impl.LSN_arr[m_impl.m_n_log_recs] = LSN;
678689
}

0 commit comments

Comments
 (0)