Merge lp:~sergei.glushchenko/percona-xtrabackup/2.0-xb-bug1093385 into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 592
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/2.0-xb-bug1093385
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 140 lines (+30/-16)
2 files modified
src/xbstream.c (+7/-1)
src/xtrabackup.cc (+23/-15)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/2.0-xb-bug1093385
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+208190@code.launchpad.net

Description of the change

This patch makes posix_fadvise to specify ranges. This reduces IO done to make a backup.
My experiment showed that bytes read needed to copy 886M database reduced from 980M to 886M. I also checked that datafiles are not cached upon backup done and during the backup.
Since POSIX_FADV_DONTNEED on Linux works only for data already in cache I removed posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED) invocations upon file opening since we may benefit from data already in cache.

http://jenkins.percona.com/view/PXB%202.0/job/percona-xtrabackup-2.0-param/516/

failure on innodb56 seems to be unrelated to patch.

To post a comment you must log in.
Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/xbstream.c'
--- src/xbstream.c 2013-08-18 06:53:11 +0000
+++ src/xbstream.c 2014-02-25 17:09:23 +0000
@@ -199,9 +199,13 @@
199{199{
200 uchar buf[XBSTREAM_BUFFER_SIZE];200 uchar buf[XBSTREAM_BUFFER_SIZE];
201 size_t bytes;201 size_t bytes;
202#ifdef USE_POSIX_FADVISE
203 size_t offset;
204#endif
202205
203#ifdef USE_POSIX_FADVISE206#ifdef USE_POSIX_FADVISE
204 posix_fadvise(file, 0, 0, POSIX_FADV_SEQUENTIAL);207 posix_fadvise(file, 0, 0, POSIX_FADV_SEQUENTIAL);
208 offset = my_tell(file, MYF(MY_WME));
205#endif209#endif
206210
207 while ((bytes = my_read(file, buf, XBSTREAM_BUFFER_SIZE,211 while ((bytes = my_read(file, buf, XBSTREAM_BUFFER_SIZE,
@@ -212,7 +216,9 @@
212 return 1;216 return 1;
213 }217 }
214#ifdef USE_POSIX_FADVISE218#ifdef USE_POSIX_FADVISE
215 posix_fadvise(file, 0, 0, POSIX_FADV_DONTNEED);219 posix_fadvise(file, offset, XBSTREAM_BUFFER_SIZE,
220 POSIX_FADV_DONTNEED);
221 offset += XBSTREAM_BUFFER_SIZE;
216#endif222#endif
217223
218 }224 }
219225
=== modified file 'src/xtrabackup.cc'
--- src/xtrabackup.cc 2013-11-05 09:54:40 +0000
+++ src/xtrabackup.cc 2014-02-25 17:09:23 +0000
@@ -4285,7 +4285,7 @@
4285 }4285 }
42864286
4287#ifdef USE_POSIX_FADVISE4287#ifdef USE_POSIX_FADVISE
4288 posix_fadvise(node->handle, 0, 0, POSIX_FADV_DONTNEED);4288 posix_fadvise(node->handle, offset, chunk, POSIX_FADV_DONTNEED);
4289#endif4289#endif
42904290
4291 /* check corruption and retry */4291 /* check corruption and retry */
@@ -5104,6 +5104,9 @@
5104 uchar *buf = NULL;5104 uchar *buf = NULL;
5105 const size_t buf_size = 1024 * 1024;5105 const size_t buf_size = 1024 * 1024;
5106 size_t bytes;5106 size_t bytes;
5107#ifdef USE_POSIX_FADVISE
5108 size_t offset;
5109#endif
5107 ds_file_t *dst_file = NULL;5110 ds_file_t *dst_file = NULL;
5108 MY_STAT mystat;5111 MY_STAT mystat;
51095112
@@ -5133,9 +5136,13 @@
51335136
5134 buf = (uchar *) ut_malloc(buf_size);5137 buf = (uchar *) ut_malloc(buf_size);
51355138
5139#ifdef USE_POSIX_FADVISE
5140 offset = 0;
5141#endif
5142
5136 while ((bytes = my_read(src_file, buf, buf_size, MYF(MY_WME))) > 0) {5143 while ((bytes = my_read(src_file, buf, buf_size, MYF(MY_WME))) > 0) {
5137#ifdef USE_POSIX_FADVISE5144#ifdef USE_POSIX_FADVISE
5138 posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);5145 posix_fadvise(src_file, offset, buf_size, POSIX_FADV_DONTNEED);
5139#endif5146#endif
5140 if (ds->write(dst_file, buf, bytes)) {5147 if (ds->write(dst_file, buf, bytes)) {
5141 msg("xtrabackup: error: cannot write to stream "5148 msg("xtrabackup: error: cannot write to stream "
@@ -7091,6 +7098,8 @@
7091 byte* incremental_buffer_base = NULL;7098 byte* incremental_buffer_base = NULL;
7092 byte* incremental_buffer;7099 byte* incremental_buffer;
70937100
7101 size_t offset;
7102
7094 ut_a(xtrabackup_incremental);7103 ut_a(xtrabackup_incremental);
70957104
7096 if (dbname) {7105 if (dbname) {
@@ -7143,7 +7152,6 @@
71437152
7144#ifdef USE_POSIX_FADVISE7153#ifdef USE_POSIX_FADVISE
7145 posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);7154 posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);
7146 posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
7147#endif7155#endif
71487156
7149 xb_file_set_nocache(src_file, src_path, "OPEN");7157 xb_file_set_nocache(src_file, src_path, "OPEN");
@@ -7156,10 +7164,6 @@
7156 goto error;7164 goto error;
7157 }7165 }
71587166
7159#ifdef USE_POSIX_FADVISE
7160 posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
7161#endif
7162
7163 xb_file_set_nocache(dst_file, dst_path, "OPEN");7167 xb_file_set_nocache(dst_file, dst_path, "OPEN");
71647168
7165 /* allocate buffer for incremental backup (4096 pages) */7169 /* allocate buffer for incremental backup (4096 pages) */
@@ -7177,11 +7181,10 @@
71777181
7178 /* read to buffer */7182 /* read to buffer */
7179 /* first block of block cluster */7183 /* first block of block cluster */
7184 offset = ((incremental_buffers * (page_size / 4))
7185 << page_size_shift);
7180 success = xb_os_file_read(src_file, incremental_buffer,7186 success = xb_os_file_read(src_file, incremental_buffer,
7181 ((incremental_buffers7187 offset, page_size);
7182 * (page_size / 4))
7183 << page_size_shift),
7184 page_size);
7185 if (!success) {7188 if (!success) {
7186 goto error;7189 goto error;
7187 }7190 }
@@ -7210,14 +7213,16 @@
72107213
7211 /* read whole of the cluster */7214 /* read whole of the cluster */
7212 success = xb_os_file_read(src_file, incremental_buffer,7215 success = xb_os_file_read(src_file, incremental_buffer,
7213 ((incremental_buffers7216 offset, page_in_buffer * page_size);
7214 * (page_size / 4))
7215 << page_size_shift),
7216 page_in_buffer * page_size);
7217 if (!success) {7217 if (!success) {
7218 goto error;7218 goto error;
7219 }7219 }
72207220
7221#ifdef USE_POSIX_FADVISE
7222 posix_fadvise(src_file, offset, page_in_buffer * page_size,
7223 POSIX_FADV_DONTNEED);
7224#endif
7225
7221 for (page_in_buffer = 1; page_in_buffer < page_size / 4;7226 for (page_in_buffer = 1; page_in_buffer < page_size / 4;
7222 page_in_buffer++) {7227 page_in_buffer++) {
7223 ulint offset_on_page;7228 ulint offset_on_page;
@@ -7242,6 +7247,9 @@
7242 if (!success) {7247 if (!success) {
7243 goto error;7248 goto error;
7244 }7249 }
7250#ifdef USE_POSIX_FADVISE
7251 posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
7252#endif
7245 }7253 }
72467254
7247 incremental_buffers++;7255 incremental_buffers++;

Subscribers

People subscribed via source and target branches