Commit 42b61b35 authored by Geoff Simmons's avatar Geoff Simmons

add stats to the writer measuring time spent polling and writing

parent 58ed9e04
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "miniobj.h" #include "miniobj.h"
#include "vsb.h" #include "vsb.h"
#include "vmb.h" #include "vmb.h"
#include "vtim.h"
typedef enum { typedef enum {
WRT_NOTSTARTED = 0, WRT_NOTSTARTED = 0,
...@@ -88,6 +89,7 @@ static unsigned long waits = 0; ...@@ -88,6 +89,7 @@ static unsigned long waits = 0;
static unsigned long writes = 0; static unsigned long writes = 0;
static unsigned long errors = 0; static unsigned long errors = 0;
static unsigned long timeouts = 0; static unsigned long timeouts = 0;
static double pollt = 0., writet = 0.;
typedef struct writer_data_s { typedef struct writer_data_s {
unsigned magic; unsigned magic;
...@@ -200,7 +202,9 @@ wrt_write(tx_t *tx) ...@@ -200,7 +202,9 @@ wrt_write(tx_t *tx)
ready = 0; ready = 0;
do { do {
double start = VTIM_mono();
nfds = poll(fds, 1, timeout); nfds = poll(fds, 1, timeout);
pollt += VTIM_mono() - start;
if (nfds < 0) if (nfds < 0)
assert(errno == EAGAIN || errno == EINTR); assert(errno == EAGAIN || errno == EINTR);
} while (nfds < 0); } while (nfds < 0);
...@@ -226,7 +230,10 @@ wrt_write(tx_t *tx) ...@@ -226,7 +230,10 @@ wrt_write(tx_t *tx)
} }
} }
if (ready) { if (ready) {
if (fprintf(fo, "%s", VSB_data(os)) < 0) { double start = VTIM_mono();
int ret = fprintf(fo, "%s", VSB_data(os));
writet += VTIM_mono() - start;
if (ret < 0) {
LOG_Log(LOG_ERR, "Output error %d (%s), DATA DISCARDED: %s", LOG_Log(LOG_ERR, "Output error %d (%s), DATA DISCARDED: %s",
errno, strerror(errno), VSB_data(os)); errno, strerror(errno), VSB_data(os));
errors++; errors++;
...@@ -353,9 +360,11 @@ WRT_Stats(void) ...@@ -353,9 +360,11 @@ WRT_Stats(void)
{ {
LOG_Log(LOG_INFO, LOG_Log(LOG_INFO,
"Writer (%s): seen=%lu writes=%lu bytes=%lu errors=%lu timeouts=%lu" "Writer (%s): seen=%lu writes=%lu bytes=%lu errors=%lu timeouts=%lu"
" waits=%lu free_tx=%u free_rec=%u free_chunk=%u", " waits=%lu free_tx=%u free_rec=%u free_chunk=%u pollt=%.6f"
" writet=%.6f",
statename[wrt_data.state], deqs, writes, bytes, errors, timeouts, statename[wrt_data.state], deqs, writes, bytes, errors, timeouts,
waits, wrt_nfree_tx, wrt_nfree_recs, wrt_nfree_chunks); waits, wrt_nfree_tx, wrt_nfree_recs, wrt_nfree_chunks, pollt,
writet);
} }
int int
......
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