[master] c6c4915a2 wrk: Track pool statistics separately
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon Jul 3 14:04:06 UTC 2023
commit c6c4915a2fbf36afcdc8f745be53315f0d3e791c
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Wed Jun 28 11:07:09 2023 +0200
wrk: Track pool statistics separately
This makes obvious what is used for statistics purposes and what is used
to maintain the pool queue. In particular, the pool::nqueued field has
nothing to do with pool::ndequeued.
diff --git a/bin/varnishd/cache/cache_pool.h b/bin/varnishd/cache/cache_pool.h
index 207e275b1..11bcfbd11 100644
--- a/bin/varnishd/cache/cache_pool.h
+++ b/bin/varnishd/cache/cache_pool.h
@@ -51,10 +51,8 @@ struct pool {
struct taskhead queues[TASK_QUEUE_RESERVE];
unsigned nthr;
unsigned lqueue;
- uintmax_t sdropped;
- uintmax_t rdropped;
- uintmax_t nqueued;
uintmax_t ndequeued;
+ struct VSC_main_pool stats[1];
struct VSC_main_wrk *a_stat;
struct VSC_main_wrk *b_stat;
diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c
index cc306a1e8..fe4c650b5 100644
--- a/bin/varnishd/cache/cache_wrk.c
+++ b/bin/varnishd/cache/cache_wrk.c
@@ -343,15 +343,20 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio)
} else if (!TASK_QUEUE_LIMITED(prio) ||
pp->lqueue + pp->nthr < cache_param->wthread_max +
cache_param->wthread_queue_limit) {
- pp->nqueued++;
+ pp->stats->sess_queued++;
pp->lqueue++;
VTAILQ_INSERT_TAIL(&pp->queues[prio], task, list);
PTOK(pthread_cond_signal(&pp->herder_cond));
} else {
+ /* NB: This is counter-intuitive but when we drop a REQ
+ * task, it is an HTTP/1 request and we effectively drop
+ * the whole session. It is otherwise an h2 stream with
+ * STR priority in which case we are dropping a request.
+ */
if (prio == TASK_QUEUE_REQ)
- pp->sdropped++;
+ pp->stats->sess_dropped++;
else
- pp->rdropped++;
+ pp->stats->req_dropped++;
retval = -1;
}
Lck_Unlock(&pp->mtx);
@@ -651,10 +656,8 @@ pool_herder(void *priv)
Lck_Lock(&pp->mtx);
/* XXX: unsafe counters */
- VSC_C_main->sess_queued += pp->nqueued;
- VSC_C_main->sess_dropped += pp->sdropped;
- VSC_C_main->req_dropped += pp->rdropped;
- pp->nqueued = pp->sdropped = pp->rdropped = 0;
+ VSC_main_Summ_pool(VSC_C_main, pp->stats);
+ memset(pp->stats, 0, sizeof pp->stats);
wrk = NULL;
pt = VTAILQ_LAST(&pp->idle_queue, taskhead);
More information about the varnish-commit
mailing list