Commit 53c7aaf3 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-14077 Incremental backup extremly slow

Remove the main bottleneck -  the memset() call mentioned in the bug.
Use os_mem_alloc_large() instead of malloc()/memset().
parent d2ffafe0
......@@ -27,6 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
#include "write_filt.h"
#include "fil_cur.h"
#include "xtrabackup.h"
#include <os0proc.h>
/************************************************************************
Write-through page write filter. */
......@@ -68,18 +69,21 @@ wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
{
char meta_name[FN_REFLEN];
xb_delta_info_t info;
ulint buf_size;
xb_wf_incremental_ctxt_t *cp =
&(ctxt->u.wf_incremental_ctxt);
ctxt->cursor = cursor;
/* allocate buffer for incremental backup (4096 pages) */
buf_size = (cursor->page_size / 4 + 1) * cursor->page_size;
cp->delta_buf_base = static_cast<byte *>(ut_malloc(buf_size));
memset(cp->delta_buf_base, 0, buf_size);
cp->delta_buf = static_cast<byte *>
(ut_align(cp->delta_buf_base, cursor->page_size));
cp->delta_buf_size = (cursor->page_size / 4) * cursor->page_size;
cp->delta_buf = (unsigned char *)os_mem_alloc_large(&cp->delta_buf_size);
if (!cp->delta_buf) {
msg("[%02u] mariabackup: Error: "
"cannot allocate %zu bytes\n",
cursor->thread_n, (size_t) cp->delta_buf_size);
return (FALSE);
}
/* write delta meta info */
snprintf(meta_name, sizeof(meta_name), "%s%s", dst_name,
......@@ -183,10 +187,7 @@ static void
wf_incremental_deinit(xb_write_filt_ctxt_t *ctxt)
{
xb_wf_incremental_ctxt_t *cp = &(ctxt->u.wf_incremental_ctxt);
if (cp->delta_buf_base != NULL) {
ut_free(cp->delta_buf_base);
}
os_mem_free_large(cp->delta_buf, cp->delta_buf_size);
}
/************************************************************************
......
......@@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
/* Incremental page filter context */
typedef struct {
byte *delta_buf_base;
ulint delta_buf_size;
byte *delta_buf;
ulint npages;
} xb_wf_incremental_ctxt_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment