Skip to content

Commit d6567a2

Browse files
committed
[Issue #169] Set stdio buffers to 64KB when running "restore"
1 parent 7d78d50 commit d6567a2

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/data.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,7 @@ restore_data_file_new(parray *parent_chain, pgFile *dest_file, FILE *out, const
976976
{
977977
int i;
978978
size_t total_write_len = 0;
979+
char buffer[65536];
979980

980981
for (i = parray_num(parent_chain) - 1; i >= 0; i--)
981982
{
@@ -1018,6 +1019,8 @@ restore_data_file_new(parray *parent_chain, pgFile *dest_file, FILE *out, const
10181019
elog(INFO, "Cannot open backup file \"%s\": %s", from_fullpath,
10191020
strerror(errno));
10201021

1022+
setbuf(in, buffer);
1023+
10211024
/*
10221025
* Restore the file.
10231026
* Datafiles are backed up block by block and every block
@@ -1195,7 +1198,7 @@ restore_non_data_file_internal(FILE *in, FILE *out, pgFile *file,
11951198
{
11961199
size_t read_len = 0;
11971200
int errno_tmp;
1198-
char buf[BLCKSZ];
1201+
char buf[65536]; /* 64kB buffer */
11991202

12001203
/* copy content */
12011204
for (;;)
@@ -1257,6 +1260,7 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
12571260

12581261
pgFile *tmp_file = NULL;
12591262
pgBackup *tmp_backup = NULL;
1263+
char buffer[65536];
12601264

12611265
/* Check if full copy of destination file is available in destination backup */
12621266
if (dest_file->write_size > 0)
@@ -1329,6 +1333,8 @@ restore_non_data_file(parray *parent_chain, pgBackup *dest_backup,
13291333
elog(ERROR, "Cannot open backup file \"%s\": %s", from_fullpath,
13301334
strerror(errno));
13311335

1336+
setbuf(in, buffer);
1337+
13321338
/* do actual work */
13331339
restore_non_data_file_internal(in, out, tmp_file, from_fullpath, to_fullpath);
13341340

src/restore.c

+4
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ restore_files_new(void *arg)
775775
int i;
776776
char to_fullpath[MAXPGPATH];
777777
FILE *out = NULL;
778+
char buffer[65536];
778779

779780
restore_files_arg_new *arguments = (restore_files_arg_new *) arg;
780781

@@ -857,6 +858,9 @@ restore_files_new(void *arg)
857858
to_fullpath, strerror(errno_tmp));
858859
}
859860

861+
if (!fio_is_remote_file(out))
862+
setbuf(out, buffer);
863+
860864
if (!dest_file->is_datafile || dest_file->is_cfs)
861865
elog(VERBOSE, "Restoring non-data file: \"%s\"", to_fullpath);
862866
else

0 commit comments

Comments
 (0)