Commit 4f610d3a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

I've spent some time trying to think more clearly about stats counters

and it's all a mess.

Try to get it right, and document in the head-comment what I mean with
"right".

Goal:  Cleaned up for 3.1
parent eafb66a2
...@@ -110,7 +110,7 @@ ses_sm_alloc(void) ...@@ -110,7 +110,7 @@ ses_sm_alloc(void)
hl = HTTP_estimate(nhttp); hl = HTTP_estimate(nhttp);
l = sizeof *sm + nws + 2 * hl; l = sizeof *sm + nws + 2 * hl;
VSC_C_main->g_sessmem_size = l; VSC_C_main->sessmem_size = l;
p = malloc(l); p = malloc(l);
if (p == NULL) if (p == NULL)
return (NULL); return (NULL);
...@@ -190,20 +190,20 @@ SES_New(struct worker *wrk, struct sesspool *pp) ...@@ -190,20 +190,20 @@ SES_New(struct worker *wrk, struct sesspool *pp)
pp->nsess++; pp->nsess++;
do_alloc = 1; do_alloc = 1;
} }
wrk->stats.c_sessmem_free += pp->dly_free_cnt; wrk->stats.sessmem_free += pp->dly_free_cnt;
pp->dly_free_cnt = 0; pp->dly_free_cnt = 0;
Lck_Unlock(&pp->mtx); Lck_Unlock(&pp->mtx);
if (do_alloc) { if (do_alloc) {
sm = ses_sm_alloc(); sm = ses_sm_alloc();
if (sm != NULL) { if (sm != NULL) {
wrk->stats.c_sessmem_alloc++; wrk->stats.sessmem_alloc++;
sm->pool = pp; sm->pool = pp;
ses_setup(sm); ses_setup(sm);
} else { } else {
wrk->stats.c_sessmem_fail++; wrk->stats.sessmem_fail++;
} }
} else if (sm == NULL) { } else if (sm == NULL) {
wrk->stats.c_sessmem_limit++; wrk->stats.sessmem_limit++;
} }
if (sm == NULL) if (sm == NULL)
return (NULL); return (NULL);
...@@ -325,7 +325,7 @@ SES_Delete(struct sess *sp, const char *reason) ...@@ -325,7 +325,7 @@ SES_Delete(struct sess *sp, const char *reason)
free(sm); free(sm);
Lck_Lock(&pp->mtx); Lck_Lock(&pp->mtx);
if (wrk != NULL) if (wrk != NULL)
wrk->stats.c_sessmem_free++; wrk->stats.sessmem_free++;
else else
pp->dly_free_cnt++; pp->dly_free_cnt++;
pp->nsess--; pp->nsess--;
...@@ -335,7 +335,7 @@ SES_Delete(struct sess *sp, const char *reason) ...@@ -335,7 +335,7 @@ SES_Delete(struct sess *sp, const char *reason)
ses_setup(sm); ses_setup(sm);
Lck_Lock(&pp->mtx); Lck_Lock(&pp->mtx);
if (wrk != NULL) { if (wrk != NULL) {
wrk->stats.c_sessmem_free += pp->dly_free_cnt; wrk->stats.sessmem_free += pp->dly_free_cnt;
pp->dly_free_cnt = 0; pp->dly_free_cnt = 0;
} }
VTAILQ_INSERT_HEAD(&pp->freelist, sm, list); VTAILQ_INSERT_HEAD(&pp->freelist, sm, list);
......
...@@ -110,7 +110,7 @@ do_once_cb(void *priv, const struct VSC_point * const pt) ...@@ -110,7 +110,7 @@ do_once_cb(void *priv, const struct VSC_point * const pt)
if (i > op->pad) if (i > op->pad)
op->pad = i + 1; op->pad = i + 1;
printf("%*.*s", op->pad - i, op->pad - i, ""); printf("%*.*s", op->pad - i, op->pad - i, "");
if (pt->flag == 'a') if (pt->flag == 'a' || pt->flag == 'c')
printf("%12ju %12.2f %s\n", val, val / op->up, pt->desc); printf("%12ju %12.2f %s\n", val, val / op->up, pt->desc);
else else
printf("%12ju %12s %s\n", val, ". ", pt->desc); printf("%12ju %12s %s\n", val, ". ", pt->desc);
......
...@@ -59,7 +59,7 @@ struct pt { ...@@ -59,7 +59,7 @@ struct pt {
VTAILQ_ENTRY(pt) next; VTAILQ_ENTRY(pt) next;
const volatile uint64_t *ptr; const volatile uint64_t *ptr;
uint64_t ref; uint64_t ref;
int type; int flag;
char seen; char seen;
char *name; char *name;
}; };
...@@ -81,7 +81,7 @@ do_curses_cb(void *priv, const struct VSC_point * const sp) ...@@ -81,7 +81,7 @@ do_curses_cb(void *priv, const struct VSC_point * const sp)
pt->ptr = sp->ptr; pt->ptr = sp->ptr;
pt->ref = *pt->ptr; pt->ref = *pt->ptr;
pt->type = sp->flag; pt->flag = sp->flag;
*buf = '\0'; *buf = '\0';
if (strcmp(sp->class, "")) { if (strcmp(sp->class, "")) {
...@@ -210,13 +210,13 @@ do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main, ...@@ -210,13 +210,13 @@ do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main,
line++; line++;
if (line >= LINES) if (line >= LINES)
break; break;
if (pt->type == 'a') { if (pt->flag == 'a' || pt->flag == 'c') {
AC(mvprintw(line, 0, AC(mvprintw(line, 0,
"%12ju %12.2f %12.2f %s\n", "%12ju %12.2f %12.2f %s\n",
ju, (ju - (intmax_t)pt->ref)/lt, ju, (ju - (intmax_t)pt->ref)/lt,
ju / up, pt->name)); ju / up, pt->name));
pt->ref = ju; pt->ref = ju;
} else if (pt->type == 'b') { } else if (pt->flag == 'b') {
AC(mvprintw(line, 0, " %010.10jx <", AC(mvprintw(line, 0, " %010.10jx <",
(ju >> 24) & 0xffffffffffLL)); (ju >> 24) & 0xffffffffffLL));
for (ch = 0x800000; ch; ch >>= 1) for (ch = 0x800000; ch; ch >>= 1)
......
...@@ -26,15 +26,31 @@ ...@@ -26,15 +26,31 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* 3rd argument marks fields for inclusion in the per worker-thread * Definition of all shared memory statistics below.
* stats structure. *
* Fields (n, t, l, f, e, d):
* n - Name: Field name, in C-source and stats programs
* t - Type: C-type, uint64_t, unless marked in 'f'
* l - Local: Local counter in worker thread.
* f - Format: Semantics of the value in this field
* 'a' - Accumulator (deprecated, use 'c')
* 'b' - Bitmap
* 'c' - Counter, never decreases.
* 'g' - Gauge, goes up and down
* 'i' - Integer (deprecated, use 'g')
* e - Explantion: Short explanation of field (for screen use)
* d - Description: Long explanation of field (for doc use)
*
* -----------------------
* NB: Cleanup in progress
* -----------------------
*
* Insufficient attention has caused this to become a swamp of conflicting
* conventions, shorthands and general mumbo-jumbo. I'm trying to clean
* it up as I go over the code in other business.
*
* Please see the sessmem section for how it should look.
* *
* XXX: We need a much more consistent naming of these fields, this has
* XXX: turned into a major mess, causing trouble already for backends.
* XXX:
* XXX: Please converge on:
* XXX: c_* counter (total bytes ever allocated from sma, "")
* XXX: g_* gauge (presently allocated bytes from sma, "")
*/ */
/**********************************************************************/ /**********************************************************************/
...@@ -77,27 +93,27 @@ VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)", "") ...@@ -77,27 +93,27 @@ VSC_F(fetch_304, uint64_t, 1, 'a', "Fetch no body (304)", "")
* see: cache_session.c * see: cache_session.c
*/ */
VSC_F(g_sessmem_size, uint64_t, 1, 'i', VSC_F(sessmem_size, uint64_t, 1, 'g',
"Session mem size", "Session mem size",
"Bytes of memory allocated for last allocated session." "Bytes of memory allocated for last allocated session."
) )
VSC_F(c_sessmem_alloc, uint64_t, 1, 'a', VSC_F(sessmem_alloc, uint64_t, 1, 'c',
"Session mem allocated", "Session mem allocated",
"Count of all allocations of session memory." "Count of all allocations of session memory."
) )
VSC_F(c_sessmem_free, uint64_t, 1, 'a', VSC_F(sessmem_free, uint64_t, 1, 'c',
"Session mem freed", "Session mem freed",
"Count of all frees of session memory." "Count of all frees of session memory."
) )
VSC_F(c_sessmem_fail, uint64_t, 1, 'a', VSC_F(sessmem_fail, uint64_t, 1, 'c',
"Session mem alloc failed", "Session mem alloc failed",
"Count of session memory allocation failures." "Count of session memory allocation failures."
) )
VSC_F(c_sessmem_limit, uint64_t, 1, 'a', VSC_F(sessmem_limit, uint64_t, 1, 'c',
"Session mem alloc limited", "Session mem alloc limited",
"Count of session memory allocations blocked by limit (max_sess)." "Count of session memory allocations blocked by limit (max_sess)."
) )
......
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