perf: Optimize the output of global metrics to reduce atomic operations
This commit is contained in:
@@ -82,6 +82,17 @@ struct sf_session_metrics
|
||||
uint64_t log; // 累计值
|
||||
};
|
||||
|
||||
struct thread_metrics
|
||||
{
|
||||
struct device_metrics device;
|
||||
struct raw_pkt_metrics raw_pkt;
|
||||
struct ctrl_pkt_metrics ctrl_pkt;
|
||||
struct keepalived_pkt_metrics kee_pkt;
|
||||
|
||||
struct sf_status_metrics sf_status;
|
||||
struct sf_session_metrics sf_session;
|
||||
};
|
||||
|
||||
struct global_metrics
|
||||
{
|
||||
struct device_metrics device;
|
||||
@@ -95,11 +106,16 @@ struct global_metrics
|
||||
struct metrics_config config;
|
||||
screen_stat_handle_t fs_handle;
|
||||
int fs_id[128];
|
||||
|
||||
int thread_num;
|
||||
int *thread_metrics_flag;
|
||||
struct thread_metrics *thread_metrics_cache;
|
||||
};
|
||||
|
||||
struct global_metrics *global_metrics_create(const char *profile);
|
||||
void global_metrics_destory(struct global_metrics *metrics);
|
||||
void global_metrics_dump(struct global_metrics *metrics);
|
||||
struct global_metrics *global_metrics_create(const char *profile, int thread_num);
|
||||
void global_metrics_destory(struct global_metrics *global_metrics);
|
||||
void global_metrics_update(struct global_metrics *global_metrics, struct thread_metrics *thread_metrics, int thread_id);
|
||||
void global_metrics_dump(struct global_metrics *global_metrics);
|
||||
|
||||
#ifdef __cpluscplus
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ extern "C"
|
||||
#include "timestamp.h"
|
||||
#include "packet_io.h"
|
||||
#include "session_table.h"
|
||||
#include "global_metrics.h"
|
||||
|
||||
#define MAX_THREAD_NUM 128
|
||||
|
||||
@@ -29,7 +30,8 @@ struct thread_ctx
|
||||
|
||||
struct packet_io *ref_io;
|
||||
struct sce_ctx *ref_sce_ctx;
|
||||
struct global_metrics *ref_metrics;
|
||||
struct thread_metrics thread_metrics;
|
||||
struct global_metrics *ref_global_metrics;
|
||||
struct policy_enforcer *ref_enforcer;
|
||||
|
||||
int session_table_need_reset;
|
||||
|
||||
Reference in New Issue
Block a user