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

Proposed by Sergei Glushchenko on 2014-02-25
Status: Merged
Approved by: Alexey Kopytov on 2014-03-01
Approved revision: 591
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) 2014-02-25 Approve on 2014-03-01
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.
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/xbstream.c'
2--- src/xbstream.c 2013-08-18 06:53:11 +0000
3+++ src/xbstream.c 2014-02-25 17:09:23 +0000
4@@ -199,9 +199,13 @@
5 {
6 uchar buf[XBSTREAM_BUFFER_SIZE];
7 size_t bytes;
8+#ifdef USE_POSIX_FADVISE
9+ size_t offset;
10+#endif
11
12 #ifdef USE_POSIX_FADVISE
13 posix_fadvise(file, 0, 0, POSIX_FADV_SEQUENTIAL);
14+ offset = my_tell(file, MYF(MY_WME));
15 #endif
16
17 while ((bytes = my_read(file, buf, XBSTREAM_BUFFER_SIZE,
18@@ -212,7 +216,9 @@
19 return 1;
20 }
21 #ifdef USE_POSIX_FADVISE
22- posix_fadvise(file, 0, 0, POSIX_FADV_DONTNEED);
23+ posix_fadvise(file, offset, XBSTREAM_BUFFER_SIZE,
24+ POSIX_FADV_DONTNEED);
25+ offset += XBSTREAM_BUFFER_SIZE;
26 #endif
27
28 }
29
30=== modified file 'src/xtrabackup.cc'
31--- src/xtrabackup.cc 2013-11-05 09:54:40 +0000
32+++ src/xtrabackup.cc 2014-02-25 17:09:23 +0000
33@@ -4285,7 +4285,7 @@
34 }
35
36 #ifdef USE_POSIX_FADVISE
37- posix_fadvise(node->handle, 0, 0, POSIX_FADV_DONTNEED);
38+ posix_fadvise(node->handle, offset, chunk, POSIX_FADV_DONTNEED);
39 #endif
40
41 /* check corruption and retry */
42@@ -5104,6 +5104,9 @@
43 uchar *buf = NULL;
44 const size_t buf_size = 1024 * 1024;
45 size_t bytes;
46+#ifdef USE_POSIX_FADVISE
47+ size_t offset;
48+#endif
49 ds_file_t *dst_file = NULL;
50 MY_STAT mystat;
51
52@@ -5133,9 +5136,13 @@
53
54 buf = (uchar *) ut_malloc(buf_size);
55
56+#ifdef USE_POSIX_FADVISE
57+ offset = 0;
58+#endif
59+
60 while ((bytes = my_read(src_file, buf, buf_size, MYF(MY_WME))) > 0) {
61 #ifdef USE_POSIX_FADVISE
62- posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
63+ posix_fadvise(src_file, offset, buf_size, POSIX_FADV_DONTNEED);
64 #endif
65 if (ds->write(dst_file, buf, bytes)) {
66 msg("xtrabackup: error: cannot write to stream "
67@@ -7091,6 +7098,8 @@
68 byte* incremental_buffer_base = NULL;
69 byte* incremental_buffer;
70
71+ size_t offset;
72+
73 ut_a(xtrabackup_incremental);
74
75 if (dbname) {
76@@ -7143,7 +7152,6 @@
77
78 #ifdef USE_POSIX_FADVISE
79 posix_fadvise(src_file, 0, 0, POSIX_FADV_SEQUENTIAL);
80- posix_fadvise(src_file, 0, 0, POSIX_FADV_DONTNEED);
81 #endif
82
83 xb_file_set_nocache(src_file, src_path, "OPEN");
84@@ -7156,10 +7164,6 @@
85 goto error;
86 }
87
88-#ifdef USE_POSIX_FADVISE
89- posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
90-#endif
91-
92 xb_file_set_nocache(dst_file, dst_path, "OPEN");
93
94 /* allocate buffer for incremental backup (4096 pages) */
95@@ -7177,11 +7181,10 @@
96
97 /* read to buffer */
98 /* first block of block cluster */
99+ offset = ((incremental_buffers * (page_size / 4))
100+ << page_size_shift);
101 success = xb_os_file_read(src_file, incremental_buffer,
102- ((incremental_buffers
103- * (page_size / 4))
104- << page_size_shift),
105- page_size);
106+ offset, page_size);
107 if (!success) {
108 goto error;
109 }
110@@ -7210,14 +7213,16 @@
111
112 /* read whole of the cluster */
113 success = xb_os_file_read(src_file, incremental_buffer,
114- ((incremental_buffers
115- * (page_size / 4))
116- << page_size_shift),
117- page_in_buffer * page_size);
118+ offset, page_in_buffer * page_size);
119 if (!success) {
120 goto error;
121 }
122
123+#ifdef USE_POSIX_FADVISE
124+ posix_fadvise(src_file, offset, page_in_buffer * page_size,
125+ POSIX_FADV_DONTNEED);
126+#endif
127+
128 for (page_in_buffer = 1; page_in_buffer < page_size / 4;
129 page_in_buffer++) {
130 ulint offset_on_page;
131@@ -7242,6 +7247,9 @@
132 if (!success) {
133 goto error;
134 }
135+#ifdef USE_POSIX_FADVISE
136+ posix_fadvise(dst_file, 0, 0, POSIX_FADV_DONTNEED);
137+#endif
138 }
139
140 incremental_buffers++;

Subscribers

People subscribed via source and target branches