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

Commit 3c48b9f0 authored by Roland Haas's avatar Roland Haas
Browse files

mpitar: add more timers to async writer

parent 2de07b19
//#define DO_TIMING
#include "async_writer.hh"
#include "timer.hh"
#include <cassert>
#include <cstdlib>
......@@ -8,6 +10,10 @@
#include <sys/types.h>
#include <unistd.h>
timer timer_write_worker_wait("write_worker_wait");
timer timer_write_worker_write("write_worker_write");
timer timer_write_master_wait("write_master_wait");
async_writer::async_writer(FILE* out_fh, const size_t max_bytes_queued_) :
bytes_queued(0), fh(out_fh), max_bytes_queued(max_bytes_queued_),
thread_active(false)
......@@ -53,10 +59,12 @@ void async_writer::write(const void* buf, size_t count, void (*free_func)(void*)
write_cmd.write_block.buf = buf;
write_cmd.write_block.free_func = free_func;
timer_write_master_wait.start(__LINE__);
pthread_mutex_lock(&bytes_lock);
while(bytes_queued >= max_bytes_queued)
pthread_cond_wait(&bytes_wait, &bytes_lock);
pthread_mutex_lock(&queue_lock);
timer_write_master_wait.stop(__LINE__);
bytes_queued += count;
cmd_queue.push(write_cmd);
......@@ -74,7 +82,9 @@ void async_writer::seek(long offset)
seek_cmd.seek_block.cmd = CMD_SEEK;
seek_cmd.seek_block.offset = offset;
timer_write_master_wait.start(__LINE__);
pthread_mutex_lock(&queue_lock);
timer_write_master_wait.stop(__LINE__);
cmd_queue.push(seek_cmd);
......
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