diff options
author | Amar Tumballi <amarts@redhat.com> | 2017-05-30 14:27:16 +0530 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-06-05 12:44:28 +0000 |
commit | d7105ba1652e548d9ba893e05f3d1fa29e8ee3b1 (patch) | |
tree | 0858e051d220ad8bddf80aee029be1fa3b09583e /libglusterfs/src/dict.c | |
parent | a9d3d0438ef93beb6ec3f895923db4418c0ab3df (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/dict.c')
-rw-r--r-- | libglusterfs/src/dict.c | 25 |
1 files changed, 25 insertions, 0 deletions
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); |