Patching Dec 9, 2021 6-7a CST- All GitLab services may be unavailable for 5-10 minutes

Commit 2de07b19 authored by Roland Haas's avatar Roland Haas
Browse files

mpitar: move some timers into async writer

parent f431f2e7
......@@ -82,7 +82,9 @@
std::vector<timer*> timer::all_timers;
timer timer_all("all");
timer timer_stat("stat"), timer_open("open");
timer timer_read("read"), timer_write("write"), timer_seek("seek");
timer timer_read("read"), timer_seek("seek");
timer timer_write_index("write_index");
timer timer_write_master_write("write_master_write");
timer timer_worker_wait("worker_wait"), timer_master_wait("master_wait");
#define DIM(v) (sizeof(v)/sizeof(v[0]))
......@@ -253,9 +255,9 @@ void master(const char *out_fn, fileentries& entries)
* filename, \0, decimal file size, \0, decimal offset into output, \0
* using 20 decimal digits is enough for 64 bit numbers */
send_buffers.at(buf0num+send_id) += ent.serialize();
timer_write.start(__LINE__);
timer_write_index.start(__LINE__);
fprintf(idx_fh, "%zu %s\n", off, fn.c_str());
timer_write.stop(__LINE__);
timer_write_index.stop(__LINE__);
off += sz;
}
if(!send_buffers[buf0num+send_id].empty()) {
......@@ -303,7 +305,7 @@ void master(const char *out_fn, fileentries& entries)
printf("\n");
/* add index file to tar */
timer_write.start(__LINE__);
timer_write_index.start(__LINE__);
fprintf(idx_fh, "%zu %s\n", off, idx_fn);
int ierr_fclose = fclose(idx_fh);
if(ierr_fclose != 0) {
......@@ -311,7 +313,7 @@ void master(const char *out_fn, fileentries& entries)
strerror(errno));
exit(1);
}
timer_write.stop(__LINE__);
timer_write_index.stop(__LINE__);
timer_stat.start(__LINE__);
tarentry idx_ent(idx_fn, off);
timer_stat.stop(__LINE__);
......@@ -321,13 +323,13 @@ void master(const char *out_fn, fileentries& entries)
/* terminate tar file */
static char buffer[2*BLOCKSIZE];
out_writer.seek(off);
timer_write.start(__LINE__);
timer_write_master_write.start(__LINE__);
out_writer.write(buffer, 2*BLOCKSIZE, NULL);
timer_write.stop(__LINE__);
timer_write.start(__LINE__);
timer_write_master_write.stop(__LINE__);
out_writer.finalize();
timer_write_master_write.start(__LINE__);
int ierr_close = fclose(out_fh);
timer_write.stop(__LINE__);
timer_write_master_write.stop(__LINE__);
if(ierr_close != 0) {
fprintf(stderr, "Could not write to '%s': %s\n", out_fn,
strerror(errno));
......@@ -435,10 +437,10 @@ void worker(const char *out_fn)
} while(!done || !files.empty());
/* this will usually induce a delay while caches are flushed */
timer_write.start(__LINE__);
out_writer.finalize();
timer_write_master_write.start(__LINE__);
int ierr_close = fclose(out_fh);
timer_write.stop(__LINE__);
timer_write_master_write.stop(__LINE__);
if(ierr_close != 0) {
fprintf(stderr, "Could not write to '%s': %s\n", out_fn,
strerror(errno));
......@@ -488,12 +490,10 @@ static void copy_file_content(async_writer& out_writer, const char *out_fn,
}
timer_seek.stop(__LINE__);
timer_write.start(__LINE__);
void *data = malloc(hdr.size());
assert(data);
memcpy(data, static_cast<const void*>(hdr.data()), hdr.size());
out_writer.write(data, hdr.size());
timer_write.stop(__LINE__);
file_off += hdr.size();
if(!ent.is_reg())
return;
......@@ -520,9 +520,7 @@ static void copy_file_content(async_writer& out_writer, const char *out_fn,
exit(1);
}
offset += read_sz;
timer_write.start(__LINE__);
out_writer.write(fbuf, read_sz);
timer_write.stop(__LINE__);
}
assert(offset == size);
file_off += size;
......@@ -530,9 +528,7 @@ static void copy_file_content(async_writer& out_writer, const char *out_fn,
static char block[BLOCKSIZE]; /* bunch of zeros for padding to block size */
if(size % BLOCKSIZE) {
const size_t padsize = BLOCKSIZE - (size % BLOCKSIZE);
timer_write.start(__LINE__);
out_writer.write(block, padsize, NULL);
timer_write.stop(__LINE__);
file_off += padsize;
}
timer_open.start(__LINE__);
......
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