perf: 优化metrics的性能

* 使用自定义的HASH_KEYCMP代替memcmp, 优先比较sf_profile_id
    * 减少sf_metrics_inc函数入参的个数
This commit is contained in:
luwenpeng
2023-11-22 14:49:25 +08:00
parent c3bd2fb939
commit 8b714a5924
4 changed files with 88 additions and 51 deletions

View File

@@ -7,13 +7,20 @@ extern "C"
#endif
#include <stdint.h>
#include "uthash.h"
struct sf_metrics_key
{
uint64_t rule_id;
uint32_t sf_profile_id;
uint32_t sff_profile_id;
uint32_t vsys_id;
};
struct sf_metrics *sf_metrics_create(const char *profile);
void sf_metrics_destory(struct sf_metrics *handle);
void sf_metrics_reset(struct sf_metrics *handle);
void sf_metrics_inc(struct sf_metrics *handle, int vsys_id, uint64_t rule_id, int sff_profile_id, int sf_profile_id, uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes);
void sf_metrics_inc(struct sf_metrics *handle, struct sf_metrics_key *key, uint64_t rx_pkts, uint64_t rx_bytes, uint64_t tx_pkts, uint64_t tx_bytes);
void sf_metrics_send(struct sf_metrics *handle);
int sf_metrics_get_interval(struct sf_metrics *handle);