Skip to content

Commit 2b5a0a2

Browse files
author
Jan Lindström
committed
Feature: In first write if we trim we set write_size to actual bytes
written and rest of the page is trimmed. In following writes there is no need to trim again if write_size only increases because rest of the page is already trimmed. If actual write size decreases we need to trim again. Need to research if this can happen frequently enough to make any effect.
1 parent e80f246 commit 2b5a0a2

File tree

7 files changed

+44
-21
lines changed

7 files changed

+44
-21
lines changed

storage/innobase/buf/buf0dblwr.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ buf_dblwr_write_block_to_datafile(
728728
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
729729
FALSE, buf_block_get_space(block), 0,
730730
buf_block_get_page_no(block), 0, UNIV_PAGE_SIZE,
731-
(void*) block->frame, (void*) block, 0);
731+
(void*) block->frame, (void*) block, (ulint *)&bpage->write_size);
732732
}
733733

734734
/********************************************************************//**

storage/innobase/buf/buf0flu.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ buf_flush_write_block_low(
942942
FALSE, buf_page_get_space(bpage), zip_size,
943943
buf_page_get_page_no(bpage), 0,
944944
zip_size ? zip_size : UNIV_PAGE_SIZE,
945-
frame, bpage, 0);
945+
frame, bpage, &bpage->write_size);
946946
} else if (flush_type == BUF_FLUSH_SINGLE_PAGE) {
947947
buf_dblwr_write_single_page(bpage);
948948
} else {

storage/innobase/fil/fil0fil.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fil_read(
441441
in aio this must be appropriately aligned */
442442
void* message, /*!< in: message for aio handler if non-sync
443443
aio used, else ignored */
444-
ulint write_size) /*!< in/out: Actual write size initialized
444+
ulint* write_size) /*!< in/out: Actual write size initialized
445445
after fist successfull trim
446446
operation for this page and if
447447
initialized we do not trim again if
@@ -475,7 +475,7 @@ fil_write(
475475
this must be appropriately aligned */
476476
void* message, /*!< in: message for aio handler if non-sync
477477
aio used, else ignored */
478-
ulint write_size) /*!< in/out: Actual write size initialized
478+
ulint* write_size) /*!< in/out: Actual write size initialized
479479
after fist successfull trim
480480
operation for this page and if
481481
initialized we do not trim again if
@@ -5288,7 +5288,7 @@ fil_io(
52885288
appropriately aligned */
52895289
void* message, /*!< in: message for aio handler if non-sync
52905290
aio used, else ignored */
5291-
ulint write_size) /*!< in/out: Actual write size initialized
5291+
ulint* write_size) /*!< in/out: Actual write size initialized
52925292
after fist successfull trim
52935293
operation for this page and if
52945294
initialized we do not trim again if

storage/innobase/include/fil0fil.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ fil_io(
753753
appropriately aligned */
754754
void* message, /*!< in: message for aio handler if non-sync
755755
aio used, else ignored */
756-
ulint write_size) /*!< in/out: Actual write size initialized
756+
ulint* write_size) /*!< in/out: Actual write size initialized
757757
after fist successfull trim
758758
operation for this page and if
759759
initialized we do not trim again if

storage/innobase/include/os0file.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,11 @@ pfs_os_aio_func(
724724
(can be used to identify a completed
725725
aio operation); ignored if mode is
726726
OS_AIO_SYNC */
727-
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
727+
ulint* write_size,/*!< in/out: Actual write size initialized
728+
after fist successfull trim
729+
operation for this page and if
730+
initialized we do not trim again if
731+
actual page size does not decrease. */
728732
const char* src_file,/*!< in: file name where func invoked */
729733
ulint src_line);/*!< in: line where the func invoked */
730734
/*******************************************************************//**
@@ -1057,7 +1061,7 @@ os_aio_func(
10571061
(can be used to identify a completed
10581062
aio operation); ignored if mode is
10591063
OS_AIO_SYNC */
1060-
ulint write_size);/*!< in/out: Actual write size initialized
1064+
ulint* write_size);/*!< in/out: Actual write size initialized
10611065
after fist successfull trim
10621066
operation for this page and if
10631067
initialized we do not trim again if

storage/innobase/include/os0file.ic

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ pfs_os_aio_func(
214214
(can be used to identify a completed
215215
aio operation); ignored if mode is
216216
OS_AIO_SYNC */
217-
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
217+
ulint* write_size,/*!< in/out: Actual write size initialized
218+
after fist successfull trim
219+
operation for this page and if
220+
initialized we do not trim again if
221+
actual page size does not decrease. */
218222
const char* src_file,/*!< in: file name where func invoked */
219223
ulint src_line)/*!< in: line where the func invoked */
220224
{
@@ -230,7 +234,7 @@ pfs_os_aio_func(
230234
src_file, src_line);
231235

232236
result = os_aio_func(type, mode, name, file, buf, offset,
233-
n, message1, message2, atomic_writes);
237+
n, message1, message2, write_size);
234238

235239
register_pfs_file_io_end(locker, n);
236240

storage/innobase/os/os0file.cc

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ struct os_aio_slot_t{
196196
freed after the write
197197
has been completed */
198198

199-
ulint write_size; /*!< Actual write size initialized
199+
ulint* write_size; /*!< Actual write size initialized
200200
after fist successfull trim
201201
operation for this page and if
202202
initialized we do not trim again if
@@ -4363,7 +4363,7 @@ os_aio_array_reserve_slot(
43634363
to write */
43644364
os_offset_t offset, /*!< in: file offset */
43654365
ulint len, /*!< in: length of the block to read or write */
4366-
ulint write_size) /*!< in: Actual write size initialized
4366+
ulint* write_size) /*!< in: Actual write size initialized
43674367
after fist successfull trim
43684368
operation for this page and if
43694369
initialized we do not trim again if
@@ -4783,7 +4783,7 @@ os_aio_func(
47834783
(can be used to identify a completed
47844784
aio operation); ignored if mode is
47854785
OS_AIO_SYNC */
4786-
ulint write_size)/*!< in/out: Actual write size initialized
4786+
ulint* write_size)/*!< in/out: Actual write size initialized
47874787
after fist successfull trim
47884788
operation for this page and if
47894789
initialized we do not trim again if
@@ -6163,13 +6163,20 @@ os_file_trim(
61636163
// because rest of the page is already trimmed. If actual write
61646164
// size decreases we need to trim again.
61656165
if (trim_len == 0 ||
6166-
(slot->write_size > 0 && len >= slot->write_size)) {
6166+
(slot->write_size &&
6167+
*slot->write_size > 0 &&
6168+
len >= *slot->write_size)) {
61676169

6168-
if (slot->write_size > 0 && len >= slot->write_size) {
6170+
#ifdef UNIV_DEBUG
6171+
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu\n",
6172+
*slot->write_size, trim_len, len);
6173+
#endif
6174+
6175+
if (*slot->write_size > 0 && len >= *slot->write_size) {
61696176
srv_stats.page_compressed_trim_op_saved.inc();
61706177
}
61716178

6172-
slot->write_size = len;
6179+
*slot->write_size = len;
61736180

61746181
return (TRUE);
61756182
}
@@ -6191,19 +6198,23 @@ os_file_trim(
61916198
" fallocate(FALLOC_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE) ",
61926199
FALSE, __FILE__, __LINE__);
61936200

6194-
slot->write_size = 0;
6201+
if (slot->write_size) {
6202+
*slot->write_size = 0;
6203+
}
61956204

61966205
return (FALSE);
61976206
} else {
6198-
slot->write_size = len;
6207+
if (slot->write_size) {
6208+
*slot->write_size = len;
6209+
}
61996210
}
62006211
#else
62016212
ut_print_timestamp(stderr);
62026213
fprintf(stderr,
62036214
" InnoDB: [Warning] fallocate not supported on this installation."
62046215
" InnoDB: Disabling fallocate for now.");
62056216
os_fallocate_failed = TRUE;
6206-
slot->write_size = 0;
6217+
slot->write_size = NULL;
62076218

62086219
#endif /* HAVE_FALLOCATE ... */
62096220

@@ -6229,10 +6240,14 @@ os_file_trim(
62296240
" DeviceIOControl(FSCTL_FILE_LEVEL_TRIM) ",
62306241
FALSE, __FILE__, __LINE__);
62316242

6232-
slot->write_size = 0;
6243+
if (slot->write_size) {
6244+
slot->write_size = 0;
6245+
}
62336246
return (FALSE);
62346247
} else {
6235-
slot->write_size = len;
6248+
if (slot->write_size) {
6249+
slot->write_size = len;
6250+
}
62366251
}
62376252
#endif
62386253

0 commit comments

Comments
 (0)