summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2017-05-30 14:27:16 +0530
committerJeff Darcy <jeff@pl.atyp.us>2017-06-05 12:44:28 +0000
commitd7105ba1652e548d9ba893e05f3d1fa29e8ee3b1 (patch)
tree0858e051d220ad8bddf80aee029be1fa3b09583e /libglusterfs/src
parenta9d3d0438ef93beb6ec3f895923db4418c0ab3df (diff)
core: add more information on dictionary usage
when you take the 'statedump', it shows the output like below ----- [dict] max-number-of-dict-pairs=13 total-pairs-used=41613 total-dict-used=12629 average-pairs-per-dict=3 ------ Updates #220 Change-Id: I71a7eda3a3cd23edf4483234f22f983923bbb081 Signed-off-by: Amar Tumballi <amarts@redhat.com> Reviewed-on: https://review.gluster.org/4035 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jeff@pl.atyp.us>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/ctx.c3
-rw-r--r--libglusterfs/src/dict.c25
-rw-r--r--libglusterfs/src/dict.h1
-rw-r--r--libglusterfs/src/glusterfs.h8
-rw-r--r--libglusterfs/src/statedump.c21
5 files changed, 58 insertions, 0 deletions
diff --git a/libglusterfs/src/ctx.c b/libglusterfs/src/ctx.c
index 1c707eb5dfd..1cf1b988590 100644
--- a/libglusterfs/src/ctx.c
+++ b/libglusterfs/src/ctx.c
@@ -49,6 +49,9 @@ glusterfs_ctx_new ()
ctx = NULL;
}
+ GF_ATOMIC_INIT (ctx->stats.max_dict_pairs, 0);
+ GF_ATOMIC_INIT (ctx->stats.total_pairs_used, 0);
+ GF_ATOMIC_INIT (ctx->stats.total_dicts_used, 0);
out:
return ctx;
}
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index a92d03a5434..04d627dde39 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -407,6 +407,9 @@ dict_set_lk (dict_t *this, char *key, data_t *value, gf_boolean_t replace)
if (key_free)
GF_FREE (key);
+
+ if (this->max_count < this->count)
+ this->max_count = this->count;
return 0;
}
@@ -575,6 +578,9 @@ dict_destroy (dict_t *this)
data_pair_t *pair = this->members_list;
data_pair_t *prev = this->members_list;
+ glusterfs_ctx_t *ctx = NULL;
+ uint32_t total_pairs = 0;
+ uint64_t current_max = 0;
LOCK_DESTROY (&this->lock);
@@ -585,6 +591,7 @@ dict_destroy (dict_t *this)
if (prev != &this->free_pair) {
mem_put (prev);
}
+ total_pairs++;
prev = pair;
}
@@ -595,6 +602,24 @@ dict_destroy (dict_t *this)
GF_FREE (this->extra_free);
free (this->extra_stdfree);
+ /* update 'ctx->stats.dict.details' using max_count */
+ ctx = THIS->ctx;
+
+ /* NOTE: below logic is not totaly race proof */
+ /* thread0 and thread1 gets current_max as 10 */
+ /* thread0 has 'this->max_count as 11 */
+ /* thread1 has 'this->max_count as 20 */
+ /* thread1 goes ahead and sets the max_dict_pairs to 20 */
+ /* thread0 then goes and sets it to 11 */
+ /* As it is for information purpose only, no functionality will be
+ broken by this, but a point to consider about ATOMIC macros. */
+ current_max = GF_ATOMIC_GET (ctx->stats.max_dict_pairs);
+ if (current_max < this->max_count)
+ GF_ATOMIC_INIT (ctx->stats.max_dict_pairs, this->max_count);
+
+ GF_ATOMIC_ADD (ctx->stats.total_pairs_used, total_pairs);
+ GF_ATOMIC_INC (ctx->stats.total_dicts_used);
+
if (!this->is_static)
mem_put (this);
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index 0ce6ab8e2e3..bdc003ea373 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -91,6 +91,7 @@ struct _dict {
data_pair_t *members_internal;
data_pair_t free_pair;
gf_boolean_t free_pair_in_use;
+ uint32_t max_count;
};
typedef gf_boolean_t (*dict_match_t) (dict_t *d, char *k, data_t *v,
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 7eaeb0c7dbd..6feefb85e97 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -37,6 +37,7 @@
#include "lkowner.h"
#include "compat-uuid.h"
#include "refcount.h"
+#include "atomic.h"
#define GF_YES 1
#define GF_NO 0
@@ -522,6 +523,13 @@ struct _glusterfs_ctx {
struct gf_ctx_tw *tw; /* refcounted timer_wheel */
gf_lock_t volfile_lock;
+
+
+ struct {
+ gf_atomic_t max_dict_pairs;
+ gf_atomic_t total_pairs_used;
+ gf_atomic_t total_dicts_used;
+ } stats;
};
typedef struct _glusterfs_ctx glusterfs_ctx_t;
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index bb8043a869f..697ddc3b7ba 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -467,6 +467,23 @@ gf_proc_dump_mempool_info_to_dict (glusterfs_ctx_t *ctx, dict_t *dict)
void gf_proc_dump_latency_info (xlator_t *xl);
void
+gf_proc_dump_dict_info (glusterfs_ctx_t *ctx)
+{
+ uint64_t total_dicts = 0;
+ uint64_t total_pairs = 0;
+
+ total_dicts = GF_ATOMIC_GET (ctx->stats.total_dicts_used);
+ total_pairs = GF_ATOMIC_GET (ctx->stats.total_pairs_used);
+
+ gf_proc_dump_write ("max-pairs-per-dict", "%u",
+ GF_ATOMIC_GET (ctx->stats.max_dict_pairs));
+ gf_proc_dump_write ("total-pairs-used", "%lu", total_pairs);
+ gf_proc_dump_write ("total-dicts-used", "%lu", total_dicts);
+ gf_proc_dump_write ("average-pairs-per-dict", "%lu",
+ (total_pairs / total_dicts));
+}
+
+void
gf_proc_dump_xlator_info (xlator_t *top)
{
xlator_t *trav = NULL;
@@ -827,6 +844,10 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
if (GF_PROC_DUMP_IS_OPTION_ENABLED (callpool))
gf_proc_dump_pending_frames (ctx->pool);
+ /* dictionary stats */
+ gf_proc_dump_add_section ("dict");
+ gf_proc_dump_dict_info (ctx);
+
if (ctx->master) {
gf_proc_dump_add_section ("fuse");
gf_proc_dump_xlator_info (ctx->master);