Realloc td->files to full size immediately
For adding many files, we do as many reallocs() as we have files. This is
slow, so do full allocs instead.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 088b77c..461f130 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -714,10 +714,15 @@
f->fd = -1;
- dprint(FD_FILE, "resize file array to %d files\n", cur_files + 1);
+ if (td->files_size <= td->files_index) {
+ int new_size = td->o.nr_files;
- td->files = realloc(td->files, (cur_files + 1) * sizeof(f));
- td->files[cur_files] = f;
+ dprint(FD_FILE, "resize file array to %d files\n", new_size);
+
+ td->files = realloc(td->files, new_size * sizeof(f));
+ td->files[cur_files] = f;
+ td->files_size = new_size;
+ }
/*
* init function, io engine may not be loaded yet