Skip to content

Commit 923f7f5

Browse files
committed
Modify the code for DWB-on
1 parent e99ee0d commit 923f7f5

File tree

15 files changed

+151
-58
lines changed

15 files changed

+151
-58
lines changed

storage/innobase/buf/.buf0buf.cc.swp

16 KB
Binary file not shown.
52 KB
Binary file not shown.

storage/innobase/buf/.buf0flu.cc.swp

148 KB
Binary file not shown.

storage/innobase/buf/.buf0lru.cc.swp

104 KB
Binary file not shown.

storage/innobase/buf/buf0buf.cc

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ buf_chunk_init(
15741574
UT_LIST_ADD_LAST(buf_pool->free, &block->page);
15751575

15761576
ut_d(block->page.in_free_list = TRUE);
1577-
ut_ad(buf_pool_from_block(block) == buf_pool);
1577+
ut_ad(buf_pool_from_block(block) == buf_pool);
15781578

15791579
block++;
15801580
frame += UNIV_PAGE_SIZE;
@@ -2048,7 +2048,7 @@ nvdimm_buf_pool_init(
20482048
}
20492049
}
20502050

2051-
nvdimm_buf_LRU_old_ratio_update(95, FALSE);
2051+
nvdimm_buf_LRU_old_ratio_update(100 * 3 / 8, FALSE);
20522052

20532053
return(DB_SUCCESS);
20542054
}
@@ -5358,11 +5358,15 @@ buf_page_init_for_read(
53585358

53595359
#ifdef UNIV_NVDIMM_CACHE
53605360
if (mode == BUF_MOVE_TO_NVDIMM) {
5361-
if (page_id.space() == 32) { /* Stock */
5362-
buf_pool = &nvdimm_buf_pool_ptr[1];
5363-
} else if (page_id.space() == 30) {
5361+
if (page_id.space() == 30) {
53645362
buf_pool = &nvdimm_buf_pool_ptr[0];
5365-
} else {
5363+
}
5364+
#ifdef UNIV_NVDIMM_CACHE_ST
5365+
else if (page_id.space() == 32) { /* Stock */
5366+
buf_pool = &nvdimm_buf_pool_ptr[1];
5367+
}
5368+
#endif /* UNIV_NVDIMM_CACHE_ST */
5369+
else {
53665370
ut_error;
53675371
}
53685372
} else {
@@ -6143,8 +6147,9 @@ buf_page_io_complete(
61436147
if (buf_pool->instance_no == 8
61446148
&& remains < nvdimm_pc_threshold) {
61456149
os_event_set(buf_flush_nvdimm_event);
6146-
} else if (buf_pool->instance_no == 9
6147-
&& remains < nvdimm_pc_threshold * 4) {
6150+
} else
6151+
if (buf_pool->instance_no == 9
6152+
&& remains < nvdimm_pc_threshold * 2) {
61486153
os_event_set(buf_flush_nvdimm_stock_event);
61496154
}*/
61506155
}

storage/innobase/buf/buf0dblwr.cc

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ buf_dblwr_update(
727727
if (!srv_use_doublewrite_buf
728728
|| buf_dblwr == NULL
729729
|| fsp_is_system_temporary(bpage->id.space())
730-
#ifdef UNIV_NVDIMM_CACHE
731-
|| bpage->cached_in_nvdimm
732-
#endif /* UNIV_NVDIMM_CACHE */
730+
//#ifdef UNIV_NVDIMM_CACHE
731+
// || bpage->cached_in_nvdimm
732+
//#endif /* UNIV_NVDIMM_CACHE */
733733
) {
734734
return;
735735
}
@@ -764,21 +764,48 @@ buf_dblwr_update(
764764
break;
765765
case BUF_FLUSH_SINGLE_PAGE:
766766
{
767-
const ulint size = 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE;
768-
ulint i;
769-
mutex_enter(&buf_dblwr->mutex);
770-
for (i = srv_doublewrite_batch_size; i < size; ++i) {
771-
if (buf_dblwr->buf_block_arr[i] == bpage) {
772-
buf_dblwr->s_reserved--;
773-
buf_dblwr->buf_block_arr[i] = NULL;
774-
buf_dblwr->in_use[i] = false;
775-
break;
776-
}
777-
}
778-
779-
/* The block we are looking for must exist as a
780-
reserved block. */
781-
ut_a(i < size);
767+
#ifdef UNIV_NVDIMM_CACHE
768+
if (!bpage->moved_to_nvdimm && !bpage->cached_in_nvdimm) {
769+
const ulint size = 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE;
770+
ulint i;
771+
mutex_enter(&buf_dblwr->mutex);
772+
for (i = srv_doublewrite_batch_size; i < size; ++i) {
773+
if (buf_dblwr->buf_block_arr[i] == bpage) {
774+
buf_dblwr->s_reserved--;
775+
buf_dblwr->buf_block_arr[i] = NULL;
776+
buf_dblwr->in_use[i] = false;
777+
break;
778+
}
779+
}
780+
781+
/* The block we are looking for must exist as a
782+
reserved block. */
783+
if (i >= size) {
784+
ib::info() << bpage->id.space() << " "
785+
<< bpage->id.page_no() << " in " << bpage->buf_pool_index
786+
<< " cached? " << bpage->cached_in_nvdimm
787+
<< " moved? " << bpage->moved_to_nvdimm
788+
<< " " << i << " ? " << size << " " << srv_doublewrite_batch_size;
789+
}
790+
ut_a(i < size);
791+
}
792+
#else
793+
const ulint size = 2 * TRX_SYS_DOUBLEWRITE_BLOCK_SIZE;
794+
ulint i;
795+
mutex_enter(&buf_dblwr->mutex);
796+
for (i = srv_doublewrite_batch_size; i < size; ++i) {
797+
if (buf_dblwr->buf_block_arr[i] == bpage) {
798+
buf_dblwr->s_reserved--;
799+
buf_dblwr->buf_block_arr[i] = NULL;
800+
buf_dblwr->in_use[i] = false;
801+
break;
802+
}
803+
}
804+
805+
/* The block we are looking for must exist as a
806+
reserved block. */
807+
ut_a(i < size);
808+
#endif /* UNIV_NVDIMM_CACHE */
782809
}
783810
os_event_set(buf_dblwr->s_event);
784811
mutex_exit(&buf_dblwr->mutex);
@@ -897,7 +924,14 @@ buf_dblwr_write_block_to_datafile(
897924
bool sync) /*!< in: true if sync IO
898925
is requested */
899926
{
900-
ut_a(buf_page_in_file(bpage));
927+
928+
if (!buf_page_in_file(bpage)) {
929+
ib::info() << bpage->id.space() << " "
930+
<< bpage->id.page_no() << " in " << bpage->buf_pool_index
931+
<< " " << sync << " " << buf_page_get_state(bpage);
932+
}
933+
934+
ut_a(buf_page_in_file(bpage));
901935

902936
ulint type = IORequest::WRITE;
903937

@@ -1152,6 +1186,11 @@ buf_dblwr_add_to_batch(
11521186
ut_ad(buf_dblwr->first_free == buf_dblwr->b_reserved);
11531187
ut_ad(buf_dblwr->b_reserved <= srv_doublewrite_batch_size);
11541188

1189+
ib::info() << bpage->id.space() << " " << bpage->id.page_no()
1190+
<< " in " << bpage->buf_pool_index
1191+
<< " with " << bpage->flush_type
1192+
<< " dwb total = " << buf_dblwr->first_free;
1193+
11551194
if (buf_dblwr->first_free == srv_doublewrite_batch_size) {
11561195
mutex_exit(&(buf_dblwr->mutex));
11571196

storage/innobase/buf/buf0flu.cc

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,13 @@ mysql_pfs_key_t page_cleaner_thread_key;
9191

9292
#ifdef UNIV_NVDIMM_CACHE
9393
mysql_pfs_key_t page_flush_nvdimm_thread_key;
94-
mysql_pfs_key_t page_flush_nvdimm_stock_thread_key;
9594
os_event_t buf_flush_nvdimm_event;
96-
os_event_t buf_flush_nvdimm_stock_event;
9795
bool buf_nvdimm_page_cleaner_is_active = false;
96+
#ifdef UNIV_NVDIMM_CACHE_ST
97+
mysql_pfs_key_t page_flush_nvdimm_stock_thread_key;
98+
os_event_t buf_flush_nvdimm_stock_event;
9899
bool buf_nvdimm_stock_page_cleaner_is_active = false;
100+
#endif /* UNIV_NVDIMM_CACHE_ST */
99101
#endif /* UNIV_NVDIMM_CACHE */
100102

101103
/** Event to synchronise with the flushing. */
@@ -1021,7 +1023,6 @@ buf_flush_write_block_low(
10211023
ut_ad(!buf_pool_mutex_own(buf_pool));
10221024
#endif /* UNIV_DEBUG */
10231025

1024-
buf_pool_t* buf_pool = buf_pool_from_bpage(bpage);
10251026
DBUG_PRINT("ib_buf", ("flush %s %u page " UINT32PF ":" UINT32PF,
10261027
sync ? "sync" : "async", (unsigned) flush_type,
10271028
bpage->id.space(), bpage->id.page_no()));
@@ -1108,10 +1109,10 @@ buf_flush_write_block_low(
11081109
buf_page_io_complete(bpage, true);
11091110

11101111
buf_pool_t* buf_pool = buf_pool_from_bpage(nvdimm_page);
1111-
/*ib::info() << nvdimm_page->id.space() << " "
1112+
ib::info() << nvdimm_page->id.space() << " "
11121113
<< nvdimm_page->id.page_no() << " is moved to "
11131114
<< nvdimm_page->buf_pool_index << " ?= " << buf_pool->instance_no << " and " << bpage->buf_pool_index
1114-
<< " total = " << UT_LIST_GET_LEN(buf_pool->free);*/
1115+
<< " total = " << UT_LIST_GET_LEN(buf_pool->free);
11151116
} else {
11161117
if (!srv_use_doublewrite_buf
11171118
|| buf_dblwr == NULL
@@ -1126,13 +1127,11 @@ buf_flush_write_block_low(
11261127

11271128
IORequest request(type);
11281129

1129-
/*if (bpage->cached_in_nvdimm) {
1130-
ib::info() << bpage->id.space() << " " << bpage->id.page_no()
1131-
<< " is written from " << bpage->cached_in_nvdimm
1132-
<< " flush-type: " << flush_type
1133-
<< " with oldest: " << bpage->oldest_modification
1134-
<< " newest: " << bpage->newest_modification;
1135-
}*/
1130+
/*ib::info() << bpage->id.space() << " " << bpage->id.page_no()
1131+
<< " is batch written from " << bpage->cached_in_nvdimm
1132+
<< " flush-type: " << flush_type
1133+
<< " with oldest: " << bpage->oldest_modification
1134+
<< " newest: " << bpage->newest_modification;*/
11361135

11371136
fil_io(request,
11381137
sync, bpage->id, bpage->size, 0, bpage->size.physical(),
@@ -1300,7 +1299,8 @@ buf_flush_page(
13001299
lsn_t lsn_gap = bpage->oldest_modification - before_lsn;
13011300

13021301
/* FIXME: Ad-hoc method */
1303-
if (250000000 < lsn_gap && lsn_gap < 500000000) {
1302+
if (250000000 < lsn_gap && lsn_gap < 750000000) {
1303+
//if (0 < lsn_gap && lsn_gap < 500000000) {
13041304
//ib::info() << "stock in " << bpage->id.space()
13051305
// << " " << bpage->id.page_no() << " " << bpage->flush_type << " " << lsn_gap;
13061306
bpage->moved_to_nvdimm = true;
@@ -1317,15 +1317,29 @@ buf_flush_page(
13171317
&& is_uncompressed
13181318
&& !rw_lock_sx_lock_nowait(rw_lock, BUF_IO_WRITE)) {
13191319

1320-
if (!fsp_is_system_temporary(bpage->id.space())) {
1321-
/* avoiding deadlock possibility involves
1322-
doublewrite buffer, should flush it, because
1323-
it might hold the another block->lock. */
1324-
buf_dblwr_flush_buffered_writes();
1325-
} else {
1326-
buf_dblwr_sync_datafiles();
1327-
}
1328-
1320+
/*#ifdef UNIV_NVDIMM_CACHE
1321+
if (!bpage->moved_to_nvdimm) {
1322+
if (!fsp_is_system_temporary(bpage->id.space())) {
1323+
*/ /* avoiding deadlock possibility involves
1324+
doublewrite buffer, should flush it, because
1325+
it might hold the another block->lock. */
1326+
/* buf_dblwr_flush_buffered_writes();
1327+
} else {
1328+
buf_dblwr_sync_datafiles();
1329+
}
1330+
} else {
1331+
buf_dblwr_sync_datafiles();
1332+
}
1333+
#else*/
1334+
if (!fsp_is_system_temporary(bpage->id.space())) {
1335+
/* avoiding deadlock possibility involves
1336+
doublewrite buffer, should flush it, because
1337+
it might hold the another block->lock. */
1338+
buf_dblwr_flush_buffered_writes();
1339+
} else {
1340+
buf_dblwr_sync_datafiles();
1341+
}
1342+
//#endif /* UNIV_NVDIMM_CACHE */
13291343
rw_lock_sx_lock_gen(rw_lock, BUF_IO_WRITE);
13301344
}
13311345

@@ -4168,7 +4182,7 @@ DECLARE_THREAD(buf_flush_nvdimm_page_cleaner_thread)(
41684182
buf_nvdimm_page_cleaner_is_active = true;
41694183

41704184
ulint n_flushed = 0;
4171-
ulint next_loop_time = ut_time_ms() + 500;
4185+
ulint next_loop_time = ut_time_ms() + 1000;
41724186
ulint last_activity = srv_get_activity_count();
41734187

41744188
os_event_wait(buf_flush_nvdimm_event);
@@ -4195,11 +4209,11 @@ DECLARE_THREAD(buf_flush_nvdimm_page_cleaner_thread)(
41954209
if (ret_sleep == OS_SYNC_TIME_EXCEEDED) {
41964210
ulint curr_time = ut_time_ms();
41974211

4198-
if (curr_time > next_loop_time + 1500) {
4212+
if (curr_time > next_loop_time + 3000) {
41994213
if (warn_count == 0) {
42004214
ib::info()
42014215
<< "NVDIMM Page cleaner took "
4202-
<< 500 + curr_time - next_loop_time;
4216+
<< 1000 + curr_time - next_loop_time;
42034217
if (warn_interval > 300) {
42044218
warn_interval = 600;
42054219
} else {
@@ -4216,7 +4230,7 @@ DECLARE_THREAD(buf_flush_nvdimm_page_cleaner_thread)(
42164230
warn_count = 0;
42174231
}
42184232

4219-
next_loop_time = curr_time + 500;
4233+
next_loop_time = curr_time + 1000;
42204234
}
42214235

42224236
/* TODO: Need to fix for shutdown */
@@ -4268,6 +4282,7 @@ DECLARE_THREAD(buf_flush_nvdimm_page_cleaner_thread)(
42684282
OS_THREAD_DUMMY_RETURN;
42694283
}
42704284

4285+
#ifdef UNIV_NVDIMM_CACHE_ST
42714286
/******************************************************************//**
42724287
NVDIMM page_cleaner thread tasked with flushing dirty STOCK pages
42734288
from the buffer pools.
@@ -4387,4 +4402,5 @@ DECLARE_THREAD(buf_flush_nvdimm_stock_cleaner_thread)(
43874402
os_thread_exit();
43884403
OS_THREAD_DUMMY_RETURN;
43894404
}
4405+
#endif /* UNIV_NVDIMM_CACHE_ST */
43904406
#endif /* UNIV_NVDIMM_CACHE */

storage/innobase/buf/buf0lru.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,9 +1415,12 @@ buf_LRU_get_free_block(
14151415
os_event_set(buf_flush_event);
14161416
} else if (buf_pool->instance_no == srv_buf_pool_instances) {
14171417
os_event_set(buf_flush_nvdimm_event);
1418-
} else {
1418+
}
1419+
#ifdef UNIV_NVDIMM_CACHE_ST
1420+
else {
14191421
os_event_set(buf_flush_nvdimm_stock_event);
14201422
}
1423+
#endif /* UNIV_NVDIMM_CACHE_ST */
14211424
#else
14221425
os_event_set(buf_flush_event);
14231426
#endif /* UNIV_NVDIMM_CACHE */
64 KB
Binary file not shown.

storage/innobase/include/buf0buf.ic

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,12 @@ buf_pool_from_bpage(
109109
return(&buf_pool_ptr[i]);
110110
} else if (i == srv_buf_pool_instances) { /* Order-Line and New-Orders */
111111
return(&nvdimm_buf_pool_ptr[0]);
112-
} else { /* Stock */
112+
}
113+
#ifdef UNIV_NVDIMM_CACHE_ST
114+
if { /* Stock */
113115
return(&nvdimm_buf_pool_ptr[1]);
114116
}
117+
#endif /* UNIV_NVDIMM_CACHE_ST */
115118
#else
116119
ut_ad(i < srv_buf_pool_instances);
117120
return(&buf_pool_ptr[i]);

storage/innobase/include/buf0flu.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ extern os_event_t buf_flush_event;
4747

4848
#ifdef UNIV_NVDIMM_CACHE
4949
extern os_event_t buf_flush_nvdimm_event;
50-
extern os_event_t buf_flush_nvdimm_stock_event;
5150
extern bool buf_nvdimm_page_cleaner_is_active;
51+
#ifdef UNIV_NVDIMM_CACHE_ST
52+
extern os_event_t buf_flush_nvdimm_stock_event;
5253
extern bool buf_nvdimm_stock_page_cleaner_is_active;
54+
#endif /* UNIV_NVDIMM_CACHE_ST */
5355
#endif /* UNIV_NVDIMM_CACHE */
5456

5557
class ut_stage_alter_t;
@@ -245,6 +247,7 @@ DECLARE_THREAD(buf_flush_nvdimm_page_cleaner_thread)(
245247
void* arg); /*!< in: a dummy parameter required by
246248
os_thread_create */
247249

250+
#ifdef UNIV_NVDIMM_CACHE_ST
248251
/******************************************************************//**
249252
page_cleaner thread tasked with flushing dirty STOCK pages from the
250253
NVDIMM buffer pools. */
@@ -254,15 +257,16 @@ DECLARE_THREAD(buf_flush_nvdimm_stock_cleaner_thread)(
254257
/*===============================================*/
255258
void* arg); /*!< in: a dummy parameter required by
256259
os_thread_create */
260+
#endif /* UNIV_NVDIMM_CACHE_ST */
257261

258262
/*********************************************************************//**
259263
Wait for any possible LRU flushes that are in progress to end. */
260264
void
261265
buf_flush_wait_nvdimm_LRU_batch_end(
262266
/*==============================*/
263267
buf_pool_t* buf_pool); /*!< in: buffer pool instance */
264-
265268
#endif /* UNIV_NVDIMM_CACHE */
269+
266270
/******************************************************************//**
267271
page_cleaner thread tasked with flushing dirty pages from the buffer
268272
pools. As of now we'll have only one coordinator of this thread.

storage/innobase/include/srv0srv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,9 @@ extern mysql_pfs_key_t io_write_thread_key;
519519
extern mysql_pfs_key_t page_cleaner_thread_key;
520520
#ifdef UNIV_NVDIMM_CACHE
521521
extern mysql_pfs_key_t page_flush_nvdimm_thread_key;
522+
#ifdef UNIV_NVDIMM_CACHE_ST
522523
extern mysql_pfs_key_t page_flush_nvdimm_stock_thread_key;
524+
#endif /* UNIV_NVDIMM_CACHE_ST */
523525
#endif /* UNIV_NVDIMM_CACHE */
524526
extern mysql_pfs_key_t recv_writer_thread_key;
525527
extern mysql_pfs_key_t srv_error_monitor_thread_key;

storage/innobase/log/log0log.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,7 @@ logs_empty_and_mark_files_at_shutdown(void)
22202220
}
22212221
}
22222222

2223+
#ifdef UNIV_NVDIMM_CACHE_ST
22232224
count = 0;
22242225
while (buf_nvdimm_stock_page_cleaner_is_active) {
22252226
++count;
@@ -2230,6 +2231,7 @@ logs_empty_and_mark_files_at_shutdown(void)
22302231
count = 0;
22312232
}
22322233
}
2234+
#endif /* UNIV_NVDIMM_CACHE_ST */
22332235
#endif /* UNIV_NVDIMM_CACHE */
22342236

22352237
log_mutex_enter();

0 commit comments

Comments
 (0)