From b1be1edd8b761859416315da673d33643f8cd8aa Mon Sep 17 00:00:00 2001 From: kanoi Date: Sat, 16 May 2015 15:03:32 +1000 Subject: [PATCH] ckdb/php - add diffinv to shift replies and show on the shift page --- pool/page_shifts.php | 3 +++ src/ckdb.h | 2 +- src/ckdb_cmd.c | 50 ++++++++++++++++++++++++++++++-------------- 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/pool/page_shifts.php b/pool/page_shifts.php index 8902f004..e8efac11 100644 --- a/pool/page_shifts.php +++ b/pool/page_shifts.php @@ -10,6 +10,7 @@ function doshifts($data, $user) $pg .= "Start"; $pg .= "Length"; $pg .= "Your Diff"; + $pg .= "Inv Diff"; $pg .= "Avg Hs"; $pg .= "Shares"; $pg .= "Avg Share"; @@ -54,6 +55,8 @@ function doshifts($data, $user) $pg .= ''.howmanyhrs($elapsed).''; $diffacc = $ans[$pre.'diffacc:'.$i]; $pg .= ''.difffmt($diffacc).''; + $diffinv = $ans[$pre.'diffinv:'.$i]; + $pg .= ''.difffmt($diffinv).''; $hr = $diffacc * pow(2,32) / $elapsed; $pg .= ''.dsprate($hr).''; $shareacc = $ans[$pre.'shareacc:'.$i]; diff --git a/src/ckdb.h b/src/ckdb.h index e435455c..0c9f80bb 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.0" -#define CKDB_VERSION DB_VERSION"-1.111" +#define CKDB_VERSION DB_VERSION"-1.112" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index b3e48434..656ac868 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -4808,7 +4808,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, tv_t marker_end = { 0L, 0L }; int rows, want, i, where_all; int64_t maxrows; - double wm_count; + double wm_count, d; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -4892,8 +4892,14 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, while (ms_item && ms->markerid == wm->markerid && ms->userid == users->userid) { ms_add.diffacc += ms->diffacc; + ms_add.diffsta += ms->diffsta; + ms_add.diffdup += ms->diffdup; + ms_add.diffhi += ms->diffhi; ms_add.diffrej += ms->diffrej; ms_add.shareacc += ms->shareacc; + ms_add.sharesta += ms->sharesta; + ms_add.sharedup += ms->sharedup; + ms_add.sharehi += ms->sharehi; ms_add.sharerej += ms->sharerej; want = worker_offset(selects, ms->workername); @@ -4904,8 +4910,10 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, want, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); - double_to_buf(ms->diffrej, reply, sizeof(reply)); - snprintf(tmp, sizeof(tmp), "%d_diffrej:%d=%s%c", + d = ms->diffsta + ms->diffdup + + ms->diffhi + ms->diffrej; + double_to_buf(d, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "%d_diffinv:%d=%s%c", want, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -4914,8 +4922,10 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, want, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); - double_to_buf(ms->sharerej, reply, sizeof(reply)); - snprintf(tmp, sizeof(tmp), "%d_sharerej:%d=%s%c", + d = ms->sharesta + ms->sharedup + + ms->sharehi + ms->sharerej; + double_to_buf(d, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "%d_shareinv:%d=%s%c", want, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); } @@ -4999,8 +5009,10 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); - double_to_buf(ms_add.diffrej, reply, sizeof(reply)); - snprintf(tmp, sizeof(tmp), "%d_diffrej:%d=%s%c", + d = ms_add.diffsta + ms_add.diffdup + + ms_add.diffhi + ms_add.diffrej; + double_to_buf(d, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "%d_diffinv:%d=%s%c", where_all, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -5011,8 +5023,10 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); - double_to_buf(ms_add.sharerej, reply, sizeof(reply)); - snprintf(tmp, sizeof(tmp), "%d_sharerej:%d=%s%c", + d = ms_add.sharesta + ms_add.sharedup + + ms_add.sharehi + ms_add.sharerej; + double_to_buf(d, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "%d_shareinv:%d=%s%c", where_all, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -5037,7 +5051,7 @@ static char *cmd_shifts(__maybe_unused PGconn *conn, char *cmd, char *id, APPEND_REALLOC(buf, off, len, tmp); snprintf(tmp, sizeof(tmp), "%d_flds=%s%c", i, - "diffacc,diffrej,shareacc,sharerej", FLDSEP); + "diffacc,diffinv,shareacc,shareinv", FLDSEP); APPEND_REALLOC(buf, off, len, tmp); } } @@ -5666,7 +5680,7 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id, tv_t marker_end = { 0L, 0L }; int rows; int64_t maxrows; - double wm_count; + double wm_count, d; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -5728,8 +5742,10 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id, 0, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); - double_to_buf(ms->diffrej, reply, sizeof(reply)); - snprintf(tmp, sizeof(tmp), "%d_diffrej:%d=%s%c", + d = ms->diffsta + ms->diffdup + ms->diffhi + + ms->diffrej; + double_to_buf(d, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "%d_diffinv:%d=%s%c", 0, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); @@ -5738,8 +5754,10 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id, 0, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); - double_to_buf(ms->sharerej, reply, sizeof(reply)); - snprintf(tmp, sizeof(tmp), "%d_sharerej:%d=%s%c", + d = ms->sharesta + ms->sharedup + ms->sharehi + + ms->sharerej; + double_to_buf(d, reply, sizeof(reply)); + snprintf(tmp, sizeof(tmp), "%d_shareinv:%d=%s%c", 0, rows, reply, FLDSEP); APPEND_REALLOC(buf, off, len, tmp); } @@ -5824,7 +5842,7 @@ static char *cmd_pshift(__maybe_unused PGconn *conn, char *cmd, char *id, snprintf(tmp, sizeof(tmp), "%d_pool=%s%c", 0, "all", FLDSEP); APPEND_REALLOC(buf, off, len, tmp); snprintf(tmp, sizeof(tmp), "%d_flds=%s%c", - 0, "diffacc,diffrej,shareacc,sharerej", FLDSEP); + 0, "diffacc,diffinv,shareacc,shareinv", FLDSEP); APPEND_REALLOC(buf, off, len, tmp); snprintf(tmp, sizeof(tmp), "prefix_all=%d_%c", 0, FLDSEP); APPEND_REALLOC(buf, off, len, tmp);