Commit 82017620 authored by Geoff Simmons's avatar Geoff Simmons

Extend and refactor VMOD stats.

- Add PH stats
- Stats are visible in varnishstat curses mode at verbosity level
  debug.
- Rename stats for better readability.
- Stats specific to PH and QP have names with prefixed hash_ and
  trie_, respectively.
parent 355a3aa4
......@@ -4,59 +4,174 @@
.. varnish_vsc_begin:: selector
:oneliner: VMOD selector set object stats
:order: 90
:order: 100
.. varnish_vsc:: elements
:type: gauge
:level: debug
:oneliner: Elements
Number of elements (strings) in the set.
.. varnish_vsc:: setsz
:type: gauge
:level: debug
:format: bytes
:oneliner: Set size
Total size of the strings in the set -- the sum of the lengths
of all of the strings, including their terminating null bytes.
Total size of the strings in the set in bytes -- the sum of
the lengths of all elements, including terminating null bytes.
.. varnish_vsc:: nodes
.. varnish_vsc:: minlen
:type: gauge
:oneliner: Nodes
:level: debug
:format: bytes
:oneliner: Minimum string length
Total number of nodes in the internal data structure.
Minimum length of a string in the set in bytes, excluding the
terminating null byte
.. varnish_vsc:: nodesz
.. varnish_vsc:: maxlen
:type: gauge
:oneliner: Node size
:level: debug
:format: bytes
:oneliner: Maximum string length
Size of a node in bytes. Total size of the internal data
structure is nodes * nodesz.
Maximum length of a string in the set in bytes, excluding the
terminating null byte
.. varnish_vsc:: leaves
.. varnish_vsc:: hash_buckets
:type: gauge
:oneliner: Leaf nodes
:level: debug
:oneliner: Hash table buckets
Number of leaf nodes in the internal data structure.
Number of buckets in the primary hash table
.. varnish_vsc:: dmin
.. varnish_vsc:: hash_collisions
:type: gauge
:oneliner: Minimum terminating node depth
:level: debug
:oneliner: Hash value collisions
Minimum depth of a node in the internal data structure at
which an element of the set may be found.
Number of values in the primary hash to which more than one
string in the set is hashed.
.. varnish_vsc:: dmax
.. varnish_vsc:: hash_keylen
:type: gauge
:oneliner: Maximum terminating node depth
:level: debug
:oneliner: Hash key vector length
Maximum depth of a node in the internal data structure at
which an element of the set may be found.
Length of the hash key vectors, in blocks of 8 bytes
.. varnish_vsc:: davg
.. varnish_vsc:: hash_h2_buckets_min
:type: gauge
:oneliner: Average terminating node depth
:level: debug
:oneliner: Minimum secondary hash buckets
Average depth of nodes in the internal data structure at which
an element of the set may be found, rounded to the nearest integer.
Minimum number of buckets in a secondary hash table
.. varnish_vsc:: hash_h2_buckets_max
:type: gauge
:level: debug
:oneliner: Maximum secondary hash buckets
Maximum number of buckets in a secondary hash table
.. varnish_vsc:: hash_h2_buckets_avg
:type: gauge
:level: debug
:oneliner: Average secondary hash buckets
Average number of buckets in a secondary hash table, rounded
to the nearest integer
.. varnish_vsc:: hash_h2_strings_min
:type: gauge
:level: debug
:oneliner: Minimum secondary hash strings
Minimum number of buckets in a secondary hash table
.. varnish_vsc:: hash_h2_strings_max
:type: gauge
:level: debug
:oneliner: Maximum secondary hash strings
Maximum number of strings in a secondary hash table
.. varnish_vsc:: hash_h2_strings_avg
:type: gauge
:level: debug
:oneliner: Average secondary hash strings
Average number of strings in a secondary hash table, rounded
to the nearest integer
.. varnish_vsc:: trie_nodes
:type: gauge
:level: debug
:oneliner: Trie nodes
Total number of nodes in the trie.
.. varnish_vsc:: trie_nodesz
:type: gauge
:level: debug
:format: bytes
:oneliner: Trie node size
Size of a trie node in bytes.
.. varnish_vsc:: trie_leaves
:type: gauge
:level: debug
:oneliner: Trie leaf nodes
Number of leaf nodes in the trie.
.. varnish_vsc:: trie_depth_min
:type: gauge
:level: debug
:oneliner: Minimum terminating trie node depth
Minimum depth of a node in the trie at which an element of the
set may be found.
.. varnish_vsc:: trie_depth_max
:type: gauge
:level: debug
:oneliner: Maximum terminating trie node depth
Maximum depth of a node in the trie at which an element of the
set may be found.
.. varnish_vsc:: trie_depth_avg
:type: gauge
:level: debug
:oneliner: Average terminating trie node depth
Average depth of nodes in the trie at which an element of the
set may be found, rounded to the nearest integer.
.. varnish_vsc:: trie_fanout_min
:type: gauge
:level: debug
:oneliner: Minimum trie node fanout
Minimum number of branches at a non-leaf trie node
.. varnish_vsc:: trie_fanout_max
:type: gauge
:level: debug
:oneliner: Maximum trie node fanout
Maximum number of branches at a non-leaf trie node
.. varnish_vsc:: trie_fanout_avg
:type: gauge
:level: debug
:oneliner: Average trie node fanout
Average number of branches at a non-leaf trie node, rounded to
the nearest integer
.. varnish_vsc_end:: selector
......@@ -21,12 +21,26 @@ varnish v1 -vsc SELECTOR.*
varnish v1 -expect SELECTOR.vcl1.s.elements == 4
varnish v1 -expect SELECTOR.vcl1.s.setsz == 17
varnish v1 -expect SELECTOR.vcl1.s.nodes > 0
varnish v1 -expect SELECTOR.vcl1.s.nodesz > 0
varnish v1 -expect SELECTOR.vcl1.s.leaves <= 4
varnish v1 -expect SELECTOR.vcl1.s.dmin > 0
varnish v1 -expect SELECTOR.vcl1.s.dmax > 0
varnish v1 -expect SELECTOR.vcl1.s.davg > 0
varnish v1 -expect SELECTOR.vcl1.s.minlen == 3
varnish v1 -expect SELECTOR.vcl1.s.maxlen == 4
varnish v1 -expect SELECTOR.vcl1.s.trie_nodes > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_nodesz > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_leaves <= 4
varnish v1 -expect SELECTOR.vcl1.s.trie_depth_min > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_depth_max > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_depth_avg > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_fanout_min >= 1
varnish v1 -expect SELECTOR.vcl1.s.trie_fanout_max >= 1
varnish v1 -expect SELECTOR.vcl1.s.trie_fanout_avg >= 1
varnish v1 -expect SELECTOR.vcl1.s.hash_buckets >= 4
varnish v1 -expect SELECTOR.vcl1.s.hash_collisions >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_keylen == 2
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_buckets_min >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_buckets_max >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_buckets_avg >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_strings_avg >= 0
varnish v1 -vcl {
import ${vmod_selector};
......@@ -61,21 +75,49 @@ varnish v1 -vsc SELECTOR.*
varnish v1 -expect SELECTOR.vcl2.p.elements == 4
varnish v1 -expect SELECTOR.vcl2.p.setsz == 35
varnish v1 -expect SELECTOR.vcl2.p.nodes > 0
varnish v1 -expect SELECTOR.vcl2.p.nodesz > 0
varnish v1 -expect SELECTOR.vcl2.p.leaves <= 4
varnish v1 -expect SELECTOR.vcl2.p.dmin > 0
varnish v1 -expect SELECTOR.vcl2.p.dmax > 0
varnish v1 -expect SELECTOR.vcl2.p.davg > 0
varnish v1 -expect SELECTOR.vcl2.p.minlen == 3
varnish v1 -expect SELECTOR.vcl2.p.maxlen == 13
varnish v1 -expect SELECTOR.vcl2.p.trie_nodes > 0
varnish v1 -expect SELECTOR.vcl2.p.trie_nodesz > 0
varnish v1 -expect SELECTOR.vcl2.p.trie_leaves <= 4
varnish v1 -expect SELECTOR.vcl2.p.trie_depth_min > 0
varnish v1 -expect SELECTOR.vcl2.p.trie_depth_max > 0
varnish v1 -expect SELECTOR.vcl2.p.trie_depth_avg > 0
varnish v1 -expect SELECTOR.vcl2.p.trie_fanout_min >= 1
varnish v1 -expect SELECTOR.vcl2.p.trie_fanout_max >= 1
varnish v1 -expect SELECTOR.vcl2.p.trie_fanout_avg >= 1
varnish v1 -expect SELECTOR.vcl2.p.hash_buckets >= 4
varnish v1 -expect SELECTOR.vcl2.p.hash_collisions >= 0
varnish v1 -expect SELECTOR.vcl2.p.hash_keylen == 4
varnish v1 -expect SELECTOR.vcl2.p.hash_h2_buckets_min >= 0
varnish v1 -expect SELECTOR.vcl2.p.hash_h2_buckets_max >= 0
varnish v1 -expect SELECTOR.vcl2.p.hash_h2_buckets_avg >= 0
varnish v1 -expect SELECTOR.vcl2.p.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl2.p.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl2.p.hash_h2_strings_avg >= 0
varnish v1 -expect SELECTOR.vcl2.e.elements == 0
varnish v1 -expect SELECTOR.vcl2.e.setsz == 0
varnish v1 -expect SELECTOR.vcl2.e.nodes == 0
varnish v1 -expect SELECTOR.vcl2.e.nodesz == 0
varnish v1 -expect SELECTOR.vcl2.e.leaves == 0
varnish v1 -expect SELECTOR.vcl2.e.dmin == 0
varnish v1 -expect SELECTOR.vcl2.e.dmax == 0
varnish v1 -expect SELECTOR.vcl2.e.davg == 0
varnish v1 -expect SELECTOR.vcl2.e.minlen == 0
varnish v1 -expect SELECTOR.vcl2.e.maxlen == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_nodes == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_nodesz == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_leaves == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_depth_min == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_depth_max == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_depth_avg == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_fanout_min == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_fanout_max == 0
varnish v1 -expect SELECTOR.vcl2.e.trie_fanout_avg == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_buckets == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_collisions == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_keylen == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_h2_buckets_min == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_h2_buckets_max == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_h2_buckets_avg == 0
varnish v1 -expect SELECTOR.vcl2.e.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl2.e.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl2.e.hash_h2_strings_avg >= 0
# When vcl1 is set to cold, stats for vcl2.p but not vcl1.s appear.
varnish v1 -cliok "vcl.state vcl1 cold"
......@@ -86,12 +128,26 @@ varnish v1 -cliok "vcl.state vcl1 warm"
varnish v1 -vsc SELECTOR.*
varnish v1 -expect SELECTOR.vcl1.s.elements == 4
varnish v1 -expect SELECTOR.vcl1.s.setsz == 17
varnish v1 -expect SELECTOR.vcl1.s.nodes > 0
varnish v1 -expect SELECTOR.vcl1.s.nodesz > 0
varnish v1 -expect SELECTOR.vcl1.s.leaves <= 4
varnish v1 -expect SELECTOR.vcl1.s.dmin > 0
varnish v1 -expect SELECTOR.vcl1.s.dmax > 0
varnish v1 -expect SELECTOR.vcl1.s.davg > 0
varnish v1 -expect SELECTOR.vcl1.s.minlen == 3
varnish v1 -expect SELECTOR.vcl1.s.maxlen == 4
varnish v1 -expect SELECTOR.vcl1.s.trie_nodes > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_nodesz > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_leaves <= 4
varnish v1 -expect SELECTOR.vcl1.s.trie_depth_min > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_depth_max > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_depth_avg > 0
varnish v1 -expect SELECTOR.vcl1.s.trie_fanout_min >= 1
varnish v1 -expect SELECTOR.vcl1.s.trie_fanout_max >= 1
varnish v1 -expect SELECTOR.vcl1.s.trie_fanout_avg >= 1
varnish v1 -expect SELECTOR.vcl1.s.hash_buckets >= 4
varnish v1 -expect SELECTOR.vcl1.s.hash_collisions >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_keylen == 2
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_buckets_min >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_buckets_max >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_buckets_avg >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl1.s.hash_h2_strings_avg >= 0
# The same 100 words from /usr/share/dict/words as in match.vtc
varnish v1 -vcl {
......@@ -207,12 +263,26 @@ varnish v1 -vcl {
varnish v1 -expect SELECTOR.vcl3.words.elements == 100
varnish v1 -expect SELECTOR.vcl3.words.setsz == 927
varnish v1 -expect SELECTOR.vcl3.words.nodes > 0
varnish v1 -expect SELECTOR.vcl3.words.nodesz > 0
varnish v1 -expect SELECTOR.vcl3.words.leaves <= 100
varnish v1 -expect SELECTOR.vcl3.words.dmin > 0
varnish v1 -expect SELECTOR.vcl3.words.dmax > 0
varnish v1 -expect SELECTOR.vcl3.words.davg > 0
varnish v1 -expect SELECTOR.vcl3.words.minlen == 3
varnish v1 -expect SELECTOR.vcl3.words.maxlen == 14
varnish v1 -expect SELECTOR.vcl3.words.trie_nodes > 0
varnish v1 -expect SELECTOR.vcl3.words.trie_nodesz > 0
varnish v1 -expect SELECTOR.vcl3.words.trie_leaves <= 100
varnish v1 -expect SELECTOR.vcl3.words.trie_depth_min > 0
varnish v1 -expect SELECTOR.vcl3.words.trie_depth_max > 0
varnish v1 -expect SELECTOR.vcl3.words.trie_depth_avg > 0
varnish v1 -expect SELECTOR.vcl3.words.trie_fanout_min >= 1
varnish v1 -expect SELECTOR.vcl3.words.trie_fanout_max >= 1
varnish v1 -expect SELECTOR.vcl3.words.trie_fanout_avg >= 1
varnish v1 -expect SELECTOR.vcl3.words.hash_buckets >= 100
varnish v1 -expect SELECTOR.vcl3.words.hash_collisions >= 0
varnish v1 -expect SELECTOR.vcl3.words.hash_keylen == 4
varnish v1 -expect SELECTOR.vcl3.words.hash_h2_buckets_min >= 0
varnish v1 -expect SELECTOR.vcl3.words.hash_h2_buckets_max >= 0
varnish v1 -expect SELECTOR.vcl3.words.hash_h2_buckets_avg >= 0
varnish v1 -expect SELECTOR.vcl3.words.hash_h2_strings_min >= 0
varnish v1 -expect SELECTOR.vcl3.words.hash_h2_strings_max >= 0
varnish v1 -expect SELECTOR.vcl3.words.hash_h2_strings_avg >= 0
varnish v1 -cliok "vcl.state vcl1 cold"
varnish v1 -cli "vcl.discard vcl1"
......
......@@ -859,7 +859,8 @@ VCL_VOID
vmod_set_create_stats(VRT_CTX, struct vmod_selector_set *set,
struct vmod_priv *priv)
{
struct qp_stats stats = { .magic = QP_STATS_MAGIC };
struct qp_stats qp_stats = { .magic = QP_STATS_MAGIC };
struct ph_stats ph_stats = { .magic = PH_STATS_MAGIC };
struct VSC_selector *vsc;
struct vsc_seg *vsc_seg;
struct vsc_head *vsc_head;
......@@ -877,8 +878,10 @@ vmod_set_create_stats(VRT_CTX, struct vmod_selector_set *set,
AN(priv->priv);
vsc_head = priv->priv;
if (set->nmembers == 0)
memset(&stats, 0, sizeof(stats));
if (set->nmembers == 0) {
memset(&qp_stats, 0, sizeof(qp_stats));
memset(&ph_stats, 0, sizeof(ph_stats));
}
else if (set->origo == NULL) {
VFAIL(ctx, "%s.create_stats(): set was not compiled",
set->vcl_name);
......@@ -889,27 +892,58 @@ vmod_set_create_stats(VRT_CTX, struct vmod_selector_set *set,
if (!set->case_sensitive)
members = set->lomembers;
AN(members);
QP_Stats(set->origo, members, &stats);
assert(stats.terms == set->nmembers);
assert(stats.leaves <= stats.terms);
assert(stats.terms <= stats.nodes);
assert(stats.dmin <= stats.dmax);
assert(stats.dmin <= stats.davg);
assert(stats.davg <= stats.dmax);
assert(stats.nodesz > 0);
QP_Stats(set->origo, members, &qp_stats);
assert(qp_stats.terms == set->nmembers);
assert(qp_stats.leaves <= qp_stats.terms);
assert(qp_stats.terms <= qp_stats.nodes);
assert(qp_stats.dmin <= qp_stats.dmax);
assert(qp_stats.dmin <= qp_stats.davg);
assert(qp_stats.davg <= qp_stats.dmax);
assert(qp_stats.fmin <= qp_stats.fmax);
assert(qp_stats.fmin <= qp_stats.favg);
assert(qp_stats.favg <= qp_stats.fmax);
assert(qp_stats.nodesz > 0);
PH_Stats(set->hash, members, &ph_stats);
assert(ph_stats.buckets >= set->nmembers);
assert(ph_stats.collisions <= ph_stats.buckets);
assert(ph_stats.minlen <= ph_stats.maxlen);
assert(ph_stats.klen == ((ph_stats.maxlen + 7) / 8) * 2);
assert(ph_stats.h2buckets_min <= ph_stats.h2buckets_max);
assert(ph_stats.h2buckets_min <= ph_stats.h2buckets_avg);
assert(ph_stats.h2buckets_avg <= ph_stats.h2buckets_max);
assert(ph_stats.h2strings_min <= ph_stats.h2strings_max);
assert(ph_stats.h2strings_min <= ph_stats.h2strings_avg);
assert(ph_stats.h2strings_avg <= ph_stats.h2strings_max);
}
vsc = VSC_selector_New(NULL, &vsc_seg, "%s.%s", VCL_Name(ctx->vcl),
set->vcl_name);
vsc->elements = set->nmembers;
vsc->nodes = stats.nodes;
vsc->nodesz = stats.nodesz;
vsc->leaves = stats.leaves;
vsc->dmin = stats.dmin;
vsc->dmax = stats.dmax;
vsc->davg = (uint64_t)(stats.davg + 0.5);
for (unsigned i = 0; i < set->nmembers; i++)
vsc->setsz += strlen(set->members[i]) + 1;
vsc->minlen = ph_stats.minlen;
vsc->maxlen = ph_stats.maxlen;
vsc->trie_nodes = qp_stats.nodes;
vsc->trie_nodesz = qp_stats.nodesz;
vsc->trie_leaves = qp_stats.leaves;
vsc->trie_depth_min = qp_stats.dmin;
vsc->trie_depth_max = qp_stats.dmax;
vsc->trie_depth_avg = (uint64_t)(qp_stats.davg + 0.5);
vsc->trie_fanout_min = qp_stats.fmin;
vsc->trie_fanout_max = qp_stats.fmax;
vsc->trie_fanout_avg = (uint64_t)(qp_stats.favg + 0.5);
vsc->hash_buckets = ph_stats.buckets;
vsc->hash_collisions = ph_stats.collisions;
vsc->hash_keylen = ph_stats.klen;
vsc->hash_h2_buckets_min = ph_stats.h2buckets_min;
vsc->hash_h2_buckets_max = ph_stats.h2buckets_max;
vsc->hash_h2_buckets_avg = ph_stats.h2buckets_avg;
vsc->hash_h2_strings_min = ph_stats.h2strings_min;
vsc->hash_h2_strings_max = ph_stats.h2strings_max;
vsc->hash_h2_strings_avg = ph_stats.h2strings_avg;
ALLOC_OBJ(vsc_entry, VMOD_SELECTOR_VSC_MAGIC);
AN(vsc_entry);
......
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