From c060ccdeab783b56c783eb34c8d5467c10395783 Mon Sep 17 00:00:00 2001 From: Mikhail Brinskii Date: Fri, 3 Apr 2020 12:45:38 +0300 Subject: [PATCH] UCP/DT: Add stats for struct dt --- src/ucp/core/ucp_request.c | 2 ++ src/ucp/dt/dt_struct.c | 24 ++++++++++++++++++++++++ src/ucp/dt/dt_struct.h | 8 ++++++++ 3 files changed, 34 insertions(+) diff --git a/src/ucp/core/ucp_request.c b/src/ucp/core/ucp_request.c index a83a24e5691..a428ed69ddc 100644 --- a/src/ucp/core/ucp_request.c +++ b/src/ucp/core/ucp_request.c @@ -268,6 +268,7 @@ UCS_PROFILE_FUNC(ucs_status_t, ucp_request_memory_reg, s, buffer, nc_memh); /* SET memh properly */ state->dt.struct_dt.non_contig.memh[0] = nc_memh; + UCS_STATS_UPDATE_COUNTER(s->stats, UCP_DT_STRUCT_STAT_IN_CACHE, 1); return UCS_OK; } @@ -304,6 +305,7 @@ UCS_PROFILE_FUNC(ucs_status_t, ucp_request_memory_reg, if (status != UCS_OK) { goto err; } + UCS_STATS_UPDATE_COUNTER(s->stats, UCP_DT_STRUCT_STAT_CREATE, 1); break; default: diff --git a/src/ucp/dt/dt_struct.c b/src/ucp/dt/dt_struct.c index bd55794c4ad..26113b4c2c5 100644 --- a/src/ucp/dt/dt_struct.c +++ b/src/ucp/dt/dt_struct.c @@ -22,6 +22,17 @@ #include #include +#if ENABLE_STATS +static ucs_stats_class_t ucp_dt_struct_stats_class = { + .name = "dt_struct", + .num_counters = UCP_DT_STRUCT_STAT_LAST, + .counter_names = { + [UCP_DT_STRUCT_STAT_CREATE] = "create", + [UCP_DT_STRUCT_STAT_IN_CACHE] = "reuse" + } +}; +#endif + ucs_status_t _struct_register_ep_rec(uct_ep_h ep, void *buf, ucp_dt_struct_t *s, uct_mem_h contig_memh, uct_mem_h* memh); @@ -222,6 +233,7 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr, size_t desc_count, size_t rep_count, ucp_datatype_t *datatype_p) { + ucs_status_t status; ucp_dt_struct_t *dt; size_t i; @@ -269,6 +281,17 @@ ucs_status_t ucp_dt_create_struct(ucp_struct_dt_desc_t *desc_ptr, _set_struct_attributes(dt); *datatype_p = ((uintptr_t)dt) | UCP_DATATYPE_STRUCT; + + + status = UCS_STATS_NODE_ALLOC(&dt->stats, + &ucp_dt_struct_stats_class, + ucs_stats_get_root(), "%p-%d-%d", + dt, desc_count, rep_count); + if (status != UCS_OK) { + ucs_error("Can't allocate stats: %s", ucs_status_string(status)); + return status; + } + ucs_info("Created struct dt %p, len %ld (step %ld), depth %ld, uct_iovs %ld, rep count %ld", dt, dt->len, dt->step_len, dt->depth, dt->uct_iov_count, dt->rep_count); @@ -290,6 +313,7 @@ void ucp_dt_destroy_struct(ucp_datatype_t datatype_p) }) kh_destroy_inplace(dt_struct, &dt->hash); ucs_free(dt->desc); + UCS_STATS_NODE_FREE(dt->stats); ucs_free(dt); } diff --git a/src/ucp/dt/dt_struct.h b/src/ucp/dt/dt_struct.h index ee925b7c6f5..cc9ed593502 100644 --- a/src/ucp/dt/dt_struct.h +++ b/src/ucp/dt/dt_struct.h @@ -11,6 +11,7 @@ #include #include #include +#include typedef struct ucp_dt_struct_hash_value { uct_md_h md; @@ -36,6 +37,12 @@ int main() { } */ +enum { + UCP_DT_STRUCT_STAT_CREATE, + UCP_DT_STRUCT_STAT_IN_CACHE, + UCP_DT_STRUCT_STAT_LAST +}; + /** * Structured datatype structure. */ @@ -48,6 +55,7 @@ typedef struct ucp_dt_struct { size_t extent; /* total contig space covering the whole type */ ptrdiff_t lb_displ; /* the lowest displacement from which extent is effective */ khash_t(dt_struct) hash; + UCS_STATS_NODE_DECLARE(stats); } ucp_dt_struct_t; static inline ucp_dt_struct_t* ucp_dt_struct(ucp_datatype_t datatype)