summaryrefslogtreecommitdiff
path: root/service/src
diff options
context:
space:
mode:
authorsongyanchao <[email protected]>2024-04-17 06:41:27 +0000
committersongyanchao <[email protected]>2024-04-17 06:41:27 +0000
commitb9b1d3990b1fc4b89fb8b2bd061c3326986aad49 (patch)
tree86d38e86d21eff92233b36284007977e7703cc5e /service/src
parent637d1ee965e8cba77a16170cecedce8e307daf28 (diff)
🎈 perf: Refine counting structure in health check node.
Refine counting structure in health check node.
Diffstat (limited to 'service/src')
-rw-r--r--service/src/monit.c2
-rw-r--r--service/src/node_health_check.c127
2 files changed, 81 insertions, 48 deletions
diff --git a/service/src/monit.c b/service/src/monit.c
index 16bad63..d758c64 100644
--- a/service/src/monit.c
+++ b/service/src/monit.c
@@ -257,7 +257,7 @@ static cJSON * monit_root(struct sc_main * sc)
cJSON_AddItemToObject(j_root, "shmdev_rx", shmdev_rx_node_monit_loop(sc));
cJSON_AddItemToObject(j_root, "eth-egress", eth_egress_node_monit_loop(sc));
cJSON_AddItemToObject(j_root, "health-check-ask", health_check_ask_node_monit_loop(sc));
- cJSON_AddItemToObject(j_root, "health-check-dealanswer", health_check_deal_answer_node_monit_loop(sc));
+ cJSON_AddItemToObject(j_root, "health-check-deal-answer", health_check_deal_answer_node_monit_loop(sc));
cJSON_AddItemToObject(j_root, "health-session-state", health_check_session_monit_loop(sc));
cJSON_AddItemToObject(j_root, "forwarder-table", forwarder_table_monit_loop(sc));
cJSON_AddItemToObject(j_root, "ef-peer-table", ef_peer_monit_loop(sc));
diff --git a/service/src/node_health_check.c b/service/src/node_health_check.c
index 20fee8b..5ad2b34 100644
--- a/service/src/node_health_check.c
+++ b/service/src/node_health_check.c
@@ -1,4 +1,5 @@
#include "sc_trace.h"
+#include <bits/stdint-uintn.h>
#include <rte_graph.h>
#include <rte_graph_worker.h>
#include <rte_hash_crc.h>
@@ -45,12 +46,26 @@ struct health_check_ask_stats
volatile uint64_t buf_alloc_err;
} __rte_cache_aligned;
+/* Health check deal answer exception reason */
+enum health_chk_deal_ans_exc_reason
+{
+ HEALTH_CHK_DEAL_ANS_EXC_RSN_SESS_MISS = 0,
+ HEALTH_CHK_DEAL_ANS_EXC_RSN_TIMEOUT,
+ HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX
+};
+
+/* Health check deal answer exception reason string */
+static const char * health_chk_deal_ans_exc_reason_str[HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX] = {
+ "session lookup miss",
+ "timeout",
+};
+
/* Health check deal answer stats */
struct health_check_deal_answer_stats
{
- volatile uint64_t deal_pkts;
- volatile uint64_t session_lookup_miss;
- volatile uint64_t timeout;
+ volatile uint64_t total_pkts;
+ volatile uint64_t pkts_per_batch;
+ volatile uint64_t excpt_reason[HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX];
} __rte_cache_aligned;
/* Private health check hdr */
@@ -503,29 +518,50 @@ cJSON * health_check_ask_node_monit_loop(struct sc_main * sc)
/************************************ Health check deal answer statistics *************************************/
cJSON * health_check_deal_answer_node_monit_loop(struct sc_main * sc)
{
- unsigned int nr_graph_total = sc->nr_io_thread;
cJSON * json_root = cJSON_CreateObject();
+ unsigned int nr_graphs = sc->nr_io_thread;
- for (uint32_t graph_id = 0; graph_id < nr_graph_total; graph_id++)
+ uint64_t total_pkts[nr_graphs];
+ uint64_t pkts_per_batch[nr_graphs];
+ uint64_t excpt_reason[nr_graphs][HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX];
+
+ for (uint32_t graph_id = 0; graph_id < nr_graphs; graph_id++)
{
struct health_check_deal_answer_stats * stats = &deal_answer_stats[graph_id];
- if (stats->deal_pkts == 0)
+ if (stats->total_pkts == 0)
+ {
+ total_pkts[graph_id] = 0;
+ pkts_per_batch[graph_id] = 0;
+
+ memset(excpt_reason[graph_id], 0, sizeof(excpt_reason[graph_id]));
continue;
+ }
- /* Fill public stats */
- cJSON * graph_obj = cJSON_CreateObject();
- cJSON_AddNumberToObject(graph_obj, "deal_pkts", stats->deal_pkts);
- cJSON_AddNumberToObject(graph_obj, "session_lookup_miss", stats->session_lookup_miss);
- cJSON_AddNumberToObject(graph_obj, "timeout", stats->timeout);
+ total_pkts[graph_id] = stats->total_pkts;
+ pkts_per_batch[graph_id] = stats->pkts_per_batch;
- /* Fill graph id */
- char graph_index[MR_STRING_MAX] = {};
- snprintf(graph_index, sizeof(graph_index), "graph-%u", graph_id);
- cJSON_AddItemToObject(json_root, graph_index, graph_obj);
+ for (int i = 0; i < HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX; i++)
+ {
+ excpt_reason[graph_id][i] = stats->excpt_reason[i];
+ }
+ }
+
+ cJSON * json_total_pkts = cJSON_CreateIntArray((const int *)total_pkts, nr_graphs);
+ cJSON_AddItemToObject(json_root, "health_chk_deal_ans, total pkts", json_total_pkts);
+
+ cJSON * json_pkts_per_batch = cJSON_CreateIntArray((const int *)pkts_per_batch, nr_graphs);
+ cJSON_AddItemToObject(json_root, "health_chk_deal_ans, pkts per batch", json_pkts_per_batch);
+
+ for (int i = 0; i < HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX; i++)
+ {
+ char str_title[MR_STRING_MAX];
+ snprintf(str_title, sizeof(str_title), "health_chk_deal_ans, %s", health_chk_deal_ans_exc_reason_str[i]);
+
+ cJSON * json_excpt_reason = cJSON_CreateIntArray((const int *)excpt_reason[i], nr_graphs);
+ cJSON_AddItemToObject(json_root, str_title, json_excpt_reason);
}
- cJSON_AddNumberToObject(json_root, "total_graph_num", nr_graph_total);
return json_root;
}
@@ -714,43 +750,32 @@ RTE_NODE_REGISTER(health_check_ask_node_base);
/************************************* Health check deal answer node **************************************/
/* Generate and store the trace information */
-static __rte_always_inline void gen_store_trace_info_answer_node(
- struct rte_node * node, struct rte_mbuf * mbuf, uint16_t next_node_index,
- struct health_check_deal_answer_stats * stats, struct health_check_deal_answer_stats * stats_for_trace,
- struct health_check_session * session)
+static __rte_always_inline void gen_store_trace_info_answer_node(struct rte_node * node, struct rte_mbuf * mbuf,
+ uint16_t next_node_index,
+ struct health_check_deal_answer_stats * stats,
+ struct health_check_session * session,
+ enum health_chk_deal_ans_exc_reason excpt_reason)
{
- struct dp_trace_record_meta meta = {.appsym = MR_TRACE_APPSYM, .module = node->name};
-
/* Populate the next node infomation */
char str_record[MR_STRING_MAX];
int len = snprintf(str_record, sizeof(str_record), "next node:%s", node->nodes[next_node_index]->name);
- /* Populate the lookup result */
- if (stats_for_trace->session_lookup_miss != stats->session_lookup_miss)
+ if (excpt_reason != HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX)
{
- stats_for_trace->session_lookup_miss = stats->session_lookup_miss;
- len += snprintf(str_record + len, sizeof(str_record) - len, ", missed session lookup");
- }
-
- /* Populate the timeout information */
- if (stats_for_trace->timeout != stats->timeout)
- {
- stats_for_trace->timeout = stats->timeout;
- len += snprintf(str_record + len, sizeof(str_record) - len, ", timeout");
+ len += snprintf(str_record + len, sizeof(str_record) - len, ", %s",
+ health_chk_deal_ans_exc_reason_str[excpt_reason]);
}
/* Populate the health check session infomation */
if (likely(session != NULL))
{
- len += snprintf(str_record + len, sizeof(str_record) - len, ", session name:%s", session->name);
- len += snprintf(str_record + len, sizeof(str_record) - len, ", listening dev:%u,%s", session->port_id,
- session->device);
-
- len += snprintf(str_record + len, sizeof(str_record) - len, ", remote_state:%ld",
- rte_atomic64_read(&session->remote_state));
+ len += snprintf(str_record + len, sizeof(str_record) - len,
+ ", session name:%s, listening dev:%u,%s, remote_state:%ld", session->name, session->port_id,
+ session->device, rte_atomic64_read(&session->remote_state));
}
/* Emit the trace record */
+ struct dp_trace_record_meta meta = {.appsym = MR_TRACE_APPSYM, .module = node->name};
dp_trace_record_emit_str(sc_main_get()->trace, mbuf, rte_lcore_id(), &meta, str_record);
}
@@ -764,7 +789,7 @@ static __rte_always_inline uint16_t health_check_deal_answer_node_process(struct
struct rte_mbuf ** pkts = (struct rte_mbuf **)objs;
void ** batch_pkts = objs;
struct health_check_deal_answer_stats stats = {};
- struct health_check_deal_answer_stats stats_for_trace = {};
+ enum health_chk_deal_ans_exc_reason excpt_reason = HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX;
/* Single packet processing */
while (n_left_from > 0)
@@ -785,19 +810,23 @@ static __rte_always_inline uint16_t health_check_deal_answer_node_process(struct
/* Deal answer */
int ret = session->deal_answer_func(session, eth_hdr);
if (unlikely(ret != RT_SUCCESS))
- stats.timeout++;
+ {
+ excpt_reason = HEALTH_CHK_DEAL_ANS_EXC_RSN_TIMEOUT;
+ stats.excpt_reason[excpt_reason]++;
+ }
}
else
{
/* Update no match session pkts */
- stats.session_lookup_miss++;
+ excpt_reason = HEALTH_CHK_DEAL_ANS_EXC_RSN_SESS_MISS;
+ stats.excpt_reason[excpt_reason]++;
}
/* Check if tracing is enabled for the current Mbuf */
if (unlikely(dp_trace_record_can_emit(mbuf)))
{
- gen_store_trace_info_answer_node(node, mbuf, HEALTH_CHECK_DEAL_ANSWER_NEXT_PKT_DROP, &stats,
- &stats_for_trace, session);
+ gen_store_trace_info_answer_node(node, mbuf, HEALTH_CHECK_DEAL_ANSWER_NEXT_PKT_DROP, &stats, session,
+ excpt_reason);
}
}
@@ -806,9 +835,13 @@ static __rte_always_inline uint16_t health_check_deal_answer_node_process(struct
/* Update graph stats */
struct health_check_deal_answer_stats * graph_stats = &deal_answer_stats[graph->id];
- graph_stats->deal_pkts += cnt;
- graph_stats->session_lookup_miss += stats.session_lookup_miss;
- graph_stats->timeout += stats.timeout;
+ graph_stats->total_pkts += cnt;
+ graph_stats->pkts_per_batch = cnt;
+
+ for (int i = 0; i < HEALTH_CHK_DEAL_ANS_EXC_RSN_MAX; i++)
+ {
+ graph_stats->excpt_reason[i] += stats.excpt_reason[i];
+ }
return cnt;
}