Skip to content

Commit

Permalink
Feature: In first write if we trim we set write_size to actual bytes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jan Lindström committed Jan 9, 2014
1 parent e80f246 commit 2b5a0a2
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 21 deletions.
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0dblwr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ buf_dblwr_write_block_to_datafile(
fil_io(OS_FILE_WRITE | OS_AIO_SIMULATED_WAKE_LATER,
FALSE, buf_block_get_space(block), 0,
buf_block_get_page_no(block), 0, UNIV_PAGE_SIZE,
(void*) block->frame, (void*) block, 0);
(void*) block->frame, (void*) block, (ulint *)&bpage->write_size);
}

/********************************************************************//**
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ buf_flush_write_block_low(
FALSE, buf_page_get_space(bpage), zip_size,
buf_page_get_page_no(bpage), 0,
zip_size ? zip_size : UNIV_PAGE_SIZE,
frame, bpage, 0);
frame, bpage, &bpage->write_size);
} else if (flush_type == BUF_FLUSH_SINGLE_PAGE) {
buf_dblwr_write_single_page(bpage);
} else {
Expand Down
6 changes: 3 additions & 3 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ fil_read(
in aio this must be appropriately aligned */
void* message, /*!< in: message for aio handler if non-sync
aio used, else ignored */
ulint write_size) /*!< in/out: Actual write size initialized
ulint* write_size) /*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down Expand Up @@ -475,7 +475,7 @@ fil_write(
this must be appropriately aligned */
void* message, /*!< in: message for aio handler if non-sync
aio used, else ignored */
ulint write_size) /*!< in/out: Actual write size initialized
ulint* write_size) /*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down Expand Up @@ -5288,7 +5288,7 @@ fil_io(
appropriately aligned */
void* message, /*!< in: message for aio handler if non-sync
aio used, else ignored */
ulint write_size) /*!< in/out: Actual write size initialized
ulint* write_size) /*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/include/fil0fil.h
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ fil_io(
appropriately aligned */
void* message, /*!< in: message for aio handler if non-sync
aio used, else ignored */
ulint write_size) /*!< in/out: Actual write size initialized
ulint* write_size) /*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down
8 changes: 6 additions & 2 deletions storage/innobase/include/os0file.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,11 @@ pfs_os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
ulint* write_size,/*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
actual page size does not decrease. */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line);/*!< in: line where the func invoked */
/*******************************************************************//**
Expand Down Expand Up @@ -1057,7 +1061,7 @@ os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ulint write_size);/*!< in/out: Actual write size initialized
ulint* write_size);/*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down
8 changes: 6 additions & 2 deletions storage/innobase/include/os0file.ic
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ pfs_os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ibool atomic_writes, /*!<in TRUE if atomic writes are used */
ulint* write_size,/*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
actual page size does not decrease. */
const char* src_file,/*!< in: file name where func invoked */
ulint src_line)/*!< in: line where the func invoked */
{
Expand All @@ -230,7 +234,7 @@ pfs_os_aio_func(
src_file, src_line);

result = os_aio_func(type, mode, name, file, buf, offset,
n, message1, message2, atomic_writes);
n, message1, message2, write_size);

register_pfs_file_io_end(locker, n);

Expand Down
37 changes: 26 additions & 11 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ struct os_aio_slot_t{
freed after the write
has been completed */

ulint write_size; /*!< Actual write size initialized
ulint* write_size; /*!< Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down Expand Up @@ -4363,7 +4363,7 @@ os_aio_array_reserve_slot(
to write */
os_offset_t offset, /*!< in: file offset */
ulint len, /*!< in: length of the block to read or write */
ulint write_size) /*!< in: Actual write size initialized
ulint* write_size) /*!< in: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down Expand Up @@ -4783,7 +4783,7 @@ os_aio_func(
(can be used to identify a completed
aio operation); ignored if mode is
OS_AIO_SYNC */
ulint write_size)/*!< in/out: Actual write size initialized
ulint* write_size)/*!< in/out: Actual write size initialized
after fist successfull trim
operation for this page and if
initialized we do not trim again if
Expand Down Expand Up @@ -6163,13 +6163,20 @@ os_file_trim(
// because rest of the page is already trimmed. If actual write
// size decreases we need to trim again.
if (trim_len == 0 ||
(slot->write_size > 0 && len >= slot->write_size)) {
(slot->write_size &&
*slot->write_size > 0 &&
len >= *slot->write_size)) {

if (slot->write_size > 0 && len >= slot->write_size) {
#ifdef UNIV_DEBUG
fprintf(stderr, "Note: TRIM: write_size %lu trim_len %lu len %lu\n",
*slot->write_size, trim_len, len);
#endif

if (*slot->write_size > 0 && len >= *slot->write_size) {
srv_stats.page_compressed_trim_op_saved.inc();
}

slot->write_size = len;
*slot->write_size = len;

return (TRUE);
}
Expand All @@ -6191,19 +6198,23 @@ os_file_trim(
" fallocate(FALLOC_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE) ",
FALSE, __FILE__, __LINE__);

slot->write_size = 0;
if (slot->write_size) {
*slot->write_size = 0;
}

return (FALSE);
} else {
slot->write_size = len;
if (slot->write_size) {
*slot->write_size = len;
}
}
#else
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: [Warning] fallocate not supported on this installation."
" InnoDB: Disabling fallocate for now.");
os_fallocate_failed = TRUE;
slot->write_size = 0;
slot->write_size = NULL;

#endif /* HAVE_FALLOCATE ... */

Expand All @@ -6229,10 +6240,14 @@ os_file_trim(
" DeviceIOControl(FSCTL_FILE_LEVEL_TRIM) ",
FALSE, __FILE__, __LINE__);

slot->write_size = 0;
if (slot->write_size) {
slot->write_size = 0;
}
return (FALSE);
} else {
slot->write_size = len;
if (slot->write_size) {
slot->write_size = len;
}
}
#endif

Expand Down

0 comments on commit 2b5a0a2

Please sign in to comment.