Commit 529d30f3 authored by Geoff Simmons's avatar Geoff Simmons

Revert "make the occupancy stats private to MON_, tighten the lock, and"

This reverts commit c4cbd278.
parent c4cbd278
......@@ -192,6 +192,7 @@ DATA_Init(void)
VSTAILQ_INSERT_TAIL(&freetxhead, &txn[i], freelist);
}
tx_occ = rec_occ = chunk_occ = tx_occ_hi = rec_occ_hi = chunk_occ_hi = 0;
global_nfree_tx = config.max_data;
global_nfree_rec = nrecords;
global_nfree_chunk = nchunks;
......
......@@ -43,9 +43,6 @@ static int run = 0;
static pthread_t monitor;
static pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER;
static unsigned tx_occ = 0, rec_occ = 0, chunk_occ = 0, tx_occ_hi = 0,
rec_occ_hi = 0, chunk_occ_hi = 0;
static void
log_output(void)
{
......@@ -118,35 +115,24 @@ MON_Start(void)
void
MON_StatsUpdate(stats_update_t update, unsigned nrec, unsigned nchunk)
{
AZ(pthread_mutex_lock(&stats_lock));
switch(update) {
case STATS_WRITTEN:
AZ(pthread_mutex_lock(&stats_lock));
AN(tx_occ);
assert(rec_occ >= nrec);
assert(chunk_occ >= nchunk);
tx_occ--;
rec_occ -= nrec;
chunk_occ -= nchunk;
AZ(pthread_mutex_unlock(&stats_lock));
break;
case STATS_DONE:
AZ(pthread_mutex_lock(&stats_lock));
tx_occ++;
rec_occ += nrec;
chunk_occ += nchunk;
AZ(pthread_mutex_unlock(&stats_lock));
if (tx_occ > tx_occ_hi)
tx_occ_hi = tx_occ;
if (rec_occ > rec_occ_hi)
rec_occ_hi = rec_occ;
if (chunk_occ > chunk_occ_hi)
chunk_occ_hi = chunk_occ;
break;
default:
/* Unreachable */
AN(NULL);
}
AZ(pthread_mutex_unlock(&stats_lock));
}
......@@ -85,7 +85,6 @@ static char
for (int i = 0; i < THRESHOLD; i++) {
tx.occupied = 1;
tx.type = VSL_t_req;
MON_StatsUpdate(STATS_DONE, 1, 1);
wrt_write(&tx);
MAZ(to.tv_sec);
......
......@@ -355,6 +355,12 @@ event(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
tx->occupied = 1;
seen++;
MON_StatsUpdate(STATS_DONE, nrec, total_chunks);
if (tx_occ > tx_occ_hi)
tx_occ_hi = tx_occ;
if (rec_occ > rec_occ_hi)
rec_occ_hi = rec_occ;
if (chunk_occ > chunk_occ_hi)
chunk_occ_hi = chunk_occ;
submit(tx);
}
......
......@@ -119,7 +119,8 @@ typedef VSTAILQ_HEAD(txhead_s, tx_t) txhead_t;
#define OCCUPIED(p) ((p)->occupied == 1)
unsigned global_nfree_tx, global_nfree_rec, global_nfree_chunk;
unsigned tx_occ, rec_occ, chunk_occ, tx_occ_hi, rec_occ_hi, chunk_occ_hi,
global_nfree_tx, global_nfree_rec, global_nfree_chunk;
/* Writer (consumer) waits for this condition when the SPSC queue is empty.
Reader (producer) signals the condition after enqueue. */
......
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