From dbab97f3dafd6cec311d16072fe9d100b961511b Mon Sep 17 00:00:00 2001 From: kanoi Date: Mon, 22 Aug 2016 17:35:37 +1000 Subject: [PATCH] ckdb - key update: discard sharesummaries since they are not used --- src/ckdb.h | 2 +- src/ckdb_dbio.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/ckdb.h b/src/ckdb.h index 557903ad..57768337 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -58,7 +58,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.7" -#define CKDB_VERSION DB_VERSION"-2.416" +#define CKDB_VERSION DB_VERSION"-2.417" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_dbio.c b/src/ckdb_dbio.c index 00eca084..a9580be1 100644 --- a/src/ckdb_dbio.c +++ b/src/ckdb_dbio.c @@ -4787,6 +4787,39 @@ bool sharesummaries_to_markersummaries(PGconn *conn, WORKMARKERS *workmarkers, dokey: + if (key_update) { + setnow(&add_stt); + + // Discard the sharesummaries + looksharesummary.workinfoid = workmarkers->workinfoidend; + looksharesummary.userid = MAXID; + looksharesummary.workername = EMPTY; + + INIT_SHARESUMMARY(&ss_look); + ss_look.data = (void *)(&looksharesummary); + /* Since shares come in from ckpool at a high rate, + * we don't want to lock sharesummary for long + * Those incoming shares will not be touching the sharesummaries + * we are processing here */ + K_RLOCK(sharesummary_free); + ss_item = find_before_in_ktree(sharesummary_workinfoid_root, + &ss_look, ss_ctx); + K_RUNLOCK(sharesummary_free); + while (ss_item) { + DATA_SHARESUMMARY(sharesummary, ss_item); + if (sharesummary->workinfoid < workmarkers->workinfoidstart) + break; + K_WLOCK(sharesummary_free); + ss_prev = prev_in_ktree(ss_ctx); + k_unlink_item(sharesummary_store, ss_item); + K_WUNLOCK(sharesummary_free); + k_add_head_nolock(old_sharesummary_store, ss_item); + + ss_item = ss_prev; + } + setnow(&add_fin); + } + setnow(&kadd_stt); INIT_KEYSUMMARY(&ks_look);