Skip to content

Commit

Permalink
Set actual compressed page size also on read code path to buffer pool so
Browse files Browse the repository at this point in the history
that we can later use it to avoid unnecessary trim operations.
  • Loading branch information
Jan Lindström committed Mar 4, 2014
1 parent fd38dca commit 7322270
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 17 deletions.
2 changes: 1 addition & 1 deletion storage/innobase/buf/buf0rea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ buf_read_page_low(
*err = fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, zip_size, offset, 0, zip_size,
bpage->zip.data, bpage, 0);
bpage->zip.data, bpage, &bpage->write_size);
} else {
ut_a(buf_page_get_state(bpage) == BUF_BLOCK_FILE_PAGE);

Expand Down
10 changes: 9 additions & 1 deletion storage/innobase/fil/fil0pagecompress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ fil_decompress_page(
byte* page_buf, /*!< in: preallocated buffer or NULL */
byte* buf, /*!< out: buffer from which to read; in aio
this must be appropriately aligned */
ulint len) /*!< in: length of output buffer.*/
ulint len, /*!< in: length of output buffer.*/
ulint* write_size) /*!< in/out: Actual payload size of
the compressed data. */
{
int err = 0;
ulint actual_size = 0;
Expand Down Expand Up @@ -277,6 +279,12 @@ fil_decompress_page(
ut_error;
}

/* Store actual payload size of the compressed data. This pointer
points to buffer pool. */
if (write_size) {
*write_size = actual_size;
}

if (compression_alg == FIL_PAGE_COMPRESSION_ZLIB) {

#ifdef UNIV_DEBUG
Expand Down
4 changes: 3 additions & 1 deletion storage/innobase/include/fil0pagecompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ fil_decompress_page(
byte* page_buf, /*!< in: preallocated buffer or NULL */
byte* buf, /*!< out: buffer from which to read; in aio
this must be appropriately aligned */
ulint len); /*!< in: length of output buffer.*/
ulint len, /*!< in: length of output buffer.*/
ulint* write_size); /*!< in/out: Actual payload size of
the compressed data. */

/****************************************************************//**
Get space id from fil node
Expand Down
12 changes: 7 additions & 5 deletions storage/innobase/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2821,7 +2821,7 @@ os_file_read_func(

if (ret && len == n) {
if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, len);
fil_decompress_page(NULL, (byte *)buf, len, NULL);
}
return(TRUE);
}
Expand All @@ -2836,7 +2836,7 @@ os_file_read_func(

if ((ulint) ret == n) {
if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n);
fil_decompress_page(NULL, (byte *)buf, n, NULL);
}

return(TRUE);
Expand Down Expand Up @@ -5164,7 +5164,7 @@ os_aio_windows_handle(

if (slot->type == OS_FILE_READ) {
if (fil_page_is_compressed(slot->buf)) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len);
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else {
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
Expand Down Expand Up @@ -5278,7 +5278,7 @@ os_aio_linux_collect(

if (slot->type == OS_FILE_READ) {
if (fil_page_is_compressed(slot->buf)) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len);
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else {
if (slot->page_compress_success &&
Expand Down Expand Up @@ -6219,7 +6219,9 @@ os_file_trim(
" InnoDB: [Warning] fallocate not supported on this installation."
" InnoDB: Disabling fallocate for now.");
os_fallocate_failed = TRUE;
slot->write_size = NULL;
if (slot->write_size) {
*slot->write_size = 0;
}

#endif /* HAVE_FALLOCATE ... */

Expand Down
2 changes: 1 addition & 1 deletion storage/xtradb/buf/buf0rea.cc
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ buf_read_page_low(
*err = _fil_io(OS_FILE_READ | wake_later
| ignore_nonexistent_pages,
sync, space, 0, offset, 0, UNIV_PAGE_SIZE,
((buf_block_t*) bpage)->frame, bpage, 0, trx);
((buf_block_t*) bpage)->frame, bpage, &bpage->write_size, trx);
}

if (sync) {
Expand Down
10 changes: 9 additions & 1 deletion storage/xtradb/fil/fil0pagecompress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ fil_decompress_page(
byte* page_buf, /*!< in: preallocated buffer or NULL */
byte* buf, /*!< out: buffer from which to read; in aio
this must be appropriately aligned */
ulint len) /*!< in: length of output buffer.*/
ulint len, /*!< in: length of output buffer.*/
ulint* write_size) /*!< in/out: Actual payload size of
the compressed data. */
{
int err = 0;
ulint actual_size = 0;
Expand Down Expand Up @@ -273,6 +275,12 @@ fil_decompress_page(
ut_error;
}

/* Store actual payload size of the compressed data. This pointer
points to buffer pool. */
if (write_size) {
*write_size = actual_size;
}

if (compression_alg == FIL_PAGE_COMPRESSION_ZLIB) {

#ifdef UNIV_DEBUG
Expand Down
4 changes: 3 additions & 1 deletion storage/xtradb/include/fil0pagecompress.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ fil_decompress_page(
byte* page_buf, /*!< in: preallocated buffer or NULL */
byte* buf, /*!< out: buffer from which to read; in aio
this must be appropriately aligned */
ulint len); /*!< in: length of output buffer.*/
ulint len, /*!< in: length of output buffer.*/
ulint* write_size); /*!< in/out: Actual payload size of
the compressed data. */

/****************************************************************//**
Get space id from fil node
Expand Down
14 changes: 8 additions & 6 deletions storage/xtradb/os/os0file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3009,7 +3009,7 @@ os_file_read_func(

if (ret && len == n) {
if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, len);
fil_decompress_page(NULL, (byte *)buf, len, NULL);
}
return(TRUE);
}
Expand All @@ -3025,7 +3025,7 @@ os_file_read_func(
if ((ulint) ret == n) {

if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n);
fil_decompress_page(NULL, (byte *)buf, n, NULL);
}

return(TRUE);
Expand Down Expand Up @@ -3129,7 +3129,7 @@ os_file_read_no_error_handling_func(
if ((ulint) ret == n) {

if (fil_page_is_compressed((byte *)buf)) {
fil_decompress_page(NULL, (byte *)buf, n);
fil_decompress_page(NULL, (byte *)buf, n, NULL);
}

return(TRUE);
Expand Down Expand Up @@ -5223,7 +5223,7 @@ os_aio_windows_handle(

if (slot->type == OS_FILE_READ) {
if (fil_page_is_compressed(slot->buf)) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len);
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else {
if (slot->page_compress_success && fil_page_is_compressed(slot->page_buf)) {
Expand Down Expand Up @@ -5337,7 +5337,7 @@ os_aio_linux_collect(

if (slot->type == OS_FILE_READ) {
if (fil_page_is_compressed(slot->buf)) {
fil_decompress_page(slot->page_buf, slot->buf, slot->len);
fil_decompress_page(slot->page_buf, slot->buf, slot->len, slot->write_size);
}
} else {
if (slot->page_compress_success &&
Expand Down Expand Up @@ -6284,7 +6284,9 @@ os_file_trim(
" InnoDB: [Warning] fallocate not supported on this installation."
" InnoDB: Disabling fallocate for now.");
os_fallocate_failed = TRUE;
slot->write_size = NULL;
if (slot->write_size) {
*slot->write_size = 0;
}

#endif /* HAVE_FALLOCATE ... */

Expand Down

0 comments on commit 7322270

Please sign in to comment.