diff options
| author | Amar Tumballi <amarts@redhat.com> | 2017-09-12 23:01:46 +0530 | 
|---|---|---|
| committer | Xavier Hernandez <jahernan@redhat.com> | 2017-11-08 08:33:22 +0000 | 
| commit | b79f29694165a65666d4177619d57b54641e4255 (patch) | |
| tree | 13022c58cf0e13f4e3823776634086b93994e839 | |
| parent | d109c7b79e15ab1940cd083636e867b1d4ed204e (diff) | |
xlator: add more metrics per fops
Make sure to handle these counters in STACK_WIND/UNWIND macro, and
keep the counters as part of xlator_t structure itself, to provide
infra to monitoring.
Updates #137
Change-Id: Ib54d45e2321c2b095dac5810c37e6cdffe1f71b7
Signed-off-by: Amar Tumballi <amarts@redhat.com>
| -rw-r--r-- | libglusterfs/src/stack.c | 1 | ||||
| -rw-r--r-- | libglusterfs/src/stack.h | 18 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.c | 12 | ||||
| -rw-r--r-- | libglusterfs/src/xlator.h | 16 | 
4 files changed, 47 insertions, 0 deletions
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c index 5527814a19d..bf905ca0b0e 100644 --- a/libglusterfs/src/stack.c +++ b/libglusterfs/src/stack.c @@ -55,6 +55,7 @@ create_frame (xlator_t *xl, call_pool_t *pool)                  pool->cnt++;          }          UNLOCK (&pool->lock); +        GF_ATOMIC_INC (pool->total_count);          LOCK_INIT (&stack->stack_lock); diff --git a/libglusterfs/src/stack.h b/libglusterfs/src/stack.h index 8a617377bc7..ac395fcc4b0 100644 --- a/libglusterfs/src/stack.h +++ b/libglusterfs/src/stack.h @@ -56,6 +56,7 @@ struct call_pool {                  } all_stacks;          };          int64_t                     cnt; +        gf_atomic_t                 total_count;          gf_lock_t                   lock;          struct mem_pool             *frame_mem_pool;          struct mem_pool             *stack_mem_pool; @@ -253,6 +254,14 @@ STACK_RESET (call_stack_t *stack)                                "winding from %s to %s",                  \                                frame->root, old_THIS->name,              \                                THIS->name);                              \ +                /* Need to capture counts at leaf node */               \ +                if (!next_xl->children) {                               \ +                        int op = get_fop_index_from_fn((next_xl), (fn)); \ +                        GF_ATOMIC_INC (next_xl->stats.total.metrics[op].fop); \ +                        GF_ATOMIC_INC (next_xl->stats.interval.metrics[op].fop); \ +                        GF_ATOMIC_INC (next_xl->stats.total.count);     \ +                        GF_ATOMIC_INC (next_xl->stats.interval.count);  \ +                }                                                       \                  next_xl_fn (frame, next_xl, params);                    \                  THIS = old_THIS;                                        \          } while (0) @@ -309,6 +318,10 @@ STACK_RESET (call_stack_t *stack)                  if (obj->ctx->measure_latency)                          \                          timespec_now (&_new->begin);                    \                  _new->op = get_fop_index_from_fn ((_new->this), (fn));  \ +                GF_ATOMIC_INC (obj->stats.total.metrics[_new->op].fop); \ +                GF_ATOMIC_INC (obj->stats.interval.metrics[_new->op].fop); \ +                GF_ATOMIC_INC (obj->stats.total.count);                 \ +                GF_ATOMIC_INC (obj->stats.interval.count);              \                  fn (_new, obj, params);                                 \                  THIS = old_THIS;                                        \          } while (0) @@ -367,6 +380,10 @@ STACK_RESET (call_stack_t *stack)                          if (_parent->ret == NULL)                       \                                  timespec_now (&_parent->end);           \                  }                                                       \ +                if (op_ret < 0) {                                       \ +                        GF_ATOMIC_INC (THIS->stats.total.metrics[frame->op].cbk); \ +                        GF_ATOMIC_INC (THIS->stats.interval.metrics[frame->op].cbk); \ +                }                                                       \                  fn (_parent, frame->cookie, _parent->this, op_ret,      \                      op_errno, params);                                  \                  THIS = old_THIS;                                        \ @@ -485,6 +502,7 @@ copy_frame (call_frame_t *frame)                  newstack->pool->cnt++;          }          UNLOCK (&oldstack->pool->lock); +        GF_ATOMIC_INC (newstack->pool->total_count);          return newframe;  } diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c index 4817da43da1..e371038f2c7 100644 --- a/libglusterfs/src/xlator.c +++ b/libglusterfs/src/xlator.c @@ -495,10 +495,22 @@ __xlator_init(xlator_t *xl)  {          xlator_t *old_THIS = NULL;          int       ret = 0; +        int       fop_idx = 0;          old_THIS = THIS;          THIS = xl; +        /* initialize the metrics related locks */ +        for (fop_idx = 0; fop_idx < GF_FOP_MAXVALUE; fop_idx++) { +                GF_ATOMIC_INIT (xl->stats.total.metrics[fop_idx].fop, 0); +                GF_ATOMIC_INIT (xl->stats.total.metrics[fop_idx].cbk, 0); + +                GF_ATOMIC_INIT (xl->stats.interval.metrics[fop_idx].fop, 0); +                GF_ATOMIC_INIT (xl->stats.interval.metrics[fop_idx].cbk, 0); +        } +        GF_ATOMIC_INIT (xl->stats.total.count, 0); +        GF_ATOMIC_INIT (xl->stats.interval.count, 0); +          xlator_init_lock ();          ret = xl->init (xl);          xlator_init_unlock (); diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h index 430dbadd517..d802bdc76c3 100644 --- a/libglusterfs/src/xlator.h +++ b/libglusterfs/src/xlator.h @@ -923,6 +923,11 @@ typedef struct xlator_list {          struct xlator_list *next;  } xlator_list_t; +typedef struct fop_metrics { +        gf_atomic_t fop; +        gf_atomic_t cbk; /* only updaed when there is failure */ +} fop_metrics_t; +  struct _xlator {          /* Built during parsing */          char          *name; @@ -953,7 +958,18 @@ struct _xlator {                  int64_t  client_latency; /* This is in 'milliseconds' units */                  struct {                          /* for latency measurement */ +                        fop_metrics_t metrics[GF_FOP_MAXVALUE]; + +                        gf_atomic_t count; +                } total; + +                struct { +                        /* for latency measurement */                          fop_latency_t latencies[GF_FOP_MAXVALUE]; +                        /* for latency measurement */ +                        fop_metrics_t metrics[GF_FOP_MAXVALUE]; + +                        gf_atomic_t count;                  } interval;          } stats;  | 
