perf: 优化session_ctx减少内存占用; 优化global metrics的结构

This commit is contained in:
luwenpeng
2023-11-24 15:17:18 +08:00
parent bda50d79af
commit eedd18183e
12 changed files with 331 additions and 439 deletions

View File

@@ -39,31 +39,6 @@ struct thread_ctx
uint64_t tx_packets_ipid;
};
/******************************************************************************
* Struct Metadata
******************************************************************************/
struct metadata
{
int write_ref;
uint64_t session_id;
uint32_t rehash_index;
char *raw_data; // refer to current packet data
int raw_len;
uint16_t l7offset;
int direction; // 1: E2I; 0: I2E
int is_ctrl_pkt;
int is_decrypted;
struct sids sids;
struct route_ctx route_ctx;
};
int metadata_isempty(struct metadata *meta);
void metadata_copy(struct metadata *dst, struct metadata *src);
char *memdup(const char *src, int len);
/******************************************************************************
@@ -74,22 +49,32 @@ struct session_ctx
{
uint64_t session_id;
char *session_addr;
uint32_t rehash_index;
// dup from received control packet, for sending control packet
char *ctrl_packet_header_data;
uint16_t ctrl_packet_header_len;
char *ctrl_pkt_hdr_ptr;
uint16_t ctrl_pkt_hdr_len;
uint16_t vxlan_src_port;
struct four_tuple inner_tuple4;
struct mutable_array rule_ids;
struct metadata decrypted_meta_i2e;
struct metadata decrypted_meta_e2i;
struct metadata raw_meta_i2e;
struct metadata raw_meta_e2i;
struct metadata ctrl_meta;
// route ctx
struct route_ctx decrypted_e2i_route_ctx;
struct route_ctx decrypted_i2e_route_ctx;
struct route_ctx raw_e2i_route_ctx;
struct route_ctx raw_i2e_route_ctx;
struct route_ctx ctrl_route_ctx;
// sids
struct sids decrypted_e2i_sids;
struct sids decrypted_i2e_sids;
struct sids raw_e2i_sids;
struct sids raw_i2e_sids;
struct sids ctrl_sids;
// chaining
struct selected_chaining *chaining_raw;
struct selected_chaining *chaining_decrypted;