diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-06-19 16:22:26 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-07-02 01:18:35 +0200 |
commit | 6f6f00107e72cc9c01a6604ff514a5b25d52106d (patch) | |
tree | 65f2663d0c7808a8d1921df8be185d6ba6627fa5 /vtysh | |
parent | lib: add statistics for hash tables (diff) | |
download | frr-6f6f00107e72cc9c01a6604ff514a5b25d52106d.tar.xz frr-6f6f00107e72cc9c01a6604ff514a5b25d52106d.zip |
lib, vtysh: hashtable statistics
Adds the ability to name hash tables, and a new cli command that will
show various summary statistics for named hash tables.
Statistics computed are
- load factor
- full load factor (see comments)
- stddev of full load factor
Standard deviation is computed by storing the sum of squares of bucket
lengths. This is somewhat susceptible to overflow. On platforms where a
double is 32 bits, placing 65535 or more elements into a hash table
opens up the potential for overflow, depending on how they are arranged
in buckets (which depends on the hash function). For example, placing
65535 elements into one hash bucket would cause ssq overflow, but
distributing 40000000 elements evenly among 400000 buckets (100 elements
per bucket) would not.
These cases are extremely degenerate, so the vague possibility of
overflow in an informational command is deemed an acceptable tradeoff
for constant time calculation of variance without locks or compromising
efficiency of actual table operations.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'vtysh')
-rw-r--r-- | vtysh/vtysh.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index d10861a66..d95a2d286 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2103,6 +2103,35 @@ DEFUN (vtysh_show_work_queues_daemon, return ret; } +DEFUN (vtysh_show_hashtable, + vtysh_show_hashtable_cmd, + "show hashtable [statistics]", + SHOW_STR + "Statistics about hash tables\n" + "Statistics about hash tables\n") +{ + char cmd[] = "do show hashtable statistics"; + unsigned long i; + int ret = CMD_SUCCESS; + + vty_out (vty, "%sLoad factor (LF) - average number of elements across all " + "buckets%s", VTY_NEWLINE, VTY_NEWLINE); + vty_out (vty, "Full load factor (FLF) - average number of elements " + "across full buckets%s%s", VTY_NEWLINE, VTY_NEWLINE); + + vty_out (vty, "Standard deviation (SD) is calculated for both the LF and FLF%s", VTY_NEWLINE); + vty_out (vty, "and indicates the typical deviation of bucket chain length%s", VTY_NEWLINE); + vty_out (vty, "from the value in the corresponding load factor.%s%s", + VTY_NEWLINE, VTY_NEWLINE); + + for (i = 0; i < array_size(vtysh_client); i++) + if ( vtysh_client[i].fd >= 0 ) { + ret = vtysh_client_execute (&vtysh_client[i], cmd, stdout); + fprintf (stdout, "\n"); + } + return ret; +} + DEFUNSH (VTYSH_ZEBRA, vtysh_link_params, vtysh_link_params_cmd, @@ -3575,6 +3604,8 @@ vtysh_init_vty (void) install_element (VIEW_NODE, &vtysh_show_work_queues_cmd); install_element (VIEW_NODE, &vtysh_show_work_queues_daemon_cmd); + install_element (VIEW_NODE, &vtysh_show_hashtable_cmd); + install_element (VIEW_NODE, &vtysh_show_thread_cmd); /* Logging */ |