[PATCH]add maat_state_free count&bytes statistics
This commit is contained in:
@@ -98,7 +98,8 @@ long long group2compile_runtime_update_err_count(void *g2c_runtime);
|
|||||||
struct maat_compile_state;
|
struct maat_compile_state;
|
||||||
struct maat_compile_state *maat_compile_state_new(void);
|
struct maat_compile_state *maat_compile_state_new(void);
|
||||||
void maat_compile_state_reset(struct maat_compile_state *compile_state);
|
void maat_compile_state_reset(struct maat_compile_state *compile_state);
|
||||||
void maat_compile_state_free(struct maat_compile_state *compile_state);
|
void maat_compile_state_free(struct maat_compile_state *compile_state,
|
||||||
|
struct maat *maat_instance, int thread_id);
|
||||||
|
|
||||||
void maat_compile_state_update(int vtable_id, struct maat_item *hit_items,
|
void maat_compile_state_update(int vtable_id, struct maat_item *hit_items,
|
||||||
size_t n_hit_item, struct maat_state *state);
|
size_t n_hit_item, struct maat_state *state);
|
||||||
|
|||||||
@@ -156,6 +156,8 @@ struct maat_stat {
|
|||||||
long long *not_grp_hit_cnt;
|
long long *not_grp_hit_cnt;
|
||||||
long long *maat_state_cnt;
|
long long *maat_state_cnt;
|
||||||
long long *maat_compile_state_cnt;
|
long long *maat_compile_state_cnt;
|
||||||
|
long long *maat_state_free_cnt;
|
||||||
|
long long *maat_state_free_bytes;
|
||||||
|
|
||||||
long long scan_err_cnt;
|
long long scan_err_cnt;
|
||||||
long long zombie_rs_stream;
|
long long zombie_rs_stream;
|
||||||
|
|||||||
@@ -1727,10 +1727,10 @@ void maat_state_free(struct maat_state *state)
|
|||||||
long long thread_id = state->thread_id;
|
long long thread_id = state->thread_id;
|
||||||
|
|
||||||
if (state->compile_state != NULL) {
|
if (state->compile_state != NULL) {
|
||||||
maat_compile_state_free(state->compile_state);
|
maat_compile_state_free(state->compile_state, maat_instance, thread_id);
|
||||||
state->compile_state = NULL;
|
state->compile_state = NULL;
|
||||||
alignment_int64_array_add(maat_instance->stat->maat_compile_state_cnt,
|
alignment_int64_array_add(maat_instance->stat->maat_compile_state_cnt,
|
||||||
state->thread_id, -1);
|
thread_id, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->maat_instance = NULL;
|
state->maat_instance = NULL;
|
||||||
@@ -1738,6 +1738,10 @@ void maat_state_free(struct maat_state *state)
|
|||||||
|
|
||||||
alignment_int64_array_add(maat_instance->stat->maat_state_cnt,
|
alignment_int64_array_add(maat_instance->stat->maat_state_cnt,
|
||||||
thread_id, -1);
|
thread_id, -1);
|
||||||
|
alignment_int64_array_add(maat_instance->stat->maat_state_free_cnt,
|
||||||
|
thread_id, 1);
|
||||||
|
alignment_int64_array_add(maat_instance->stat->maat_state_free_bytes,
|
||||||
|
thread_id, sizeof(struct maat_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
int maat_state_set_scan_district(struct maat_state *state, int vtable_id,
|
int maat_state_set_scan_district(struct maat_state *state, int vtable_id,
|
||||||
|
|||||||
@@ -167,7 +167,6 @@ struct maat_compile_state {
|
|||||||
UT_array *internal_hit_paths;
|
UT_array *internal_hit_paths;
|
||||||
UT_array *all_hit_clauses;
|
UT_array *all_hit_clauses;
|
||||||
UT_array *this_scan_hit_clauses;
|
UT_array *this_scan_hit_clauses;
|
||||||
// UT_array *all_hit_groups;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
UT_icd ut_literal_id_icd = {sizeof(struct maat_literal_id), NULL, NULL, NULL};
|
UT_icd ut_literal_id_icd = {sizeof(struct maat_literal_id), NULL, NULL, NULL};
|
||||||
@@ -1478,28 +1477,36 @@ void maat_compile_state_reset(struct maat_compile_state *compile_state)
|
|||||||
utarray_clear(compile_state->this_scan_hit_clauses);
|
utarray_clear(compile_state->this_scan_hit_clauses);
|
||||||
}
|
}
|
||||||
|
|
||||||
void maat_compile_state_free(struct maat_compile_state *compile_state)
|
void maat_compile_state_free(struct maat_compile_state *compile_state,
|
||||||
|
struct maat *maat_instance, int thread_id)
|
||||||
{
|
{
|
||||||
if (NULL == compile_state) {
|
if (NULL == compile_state) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long long free_bytes = 0;
|
||||||
if (compile_state->internal_hit_paths != NULL) {
|
if (compile_state->internal_hit_paths != NULL) {
|
||||||
|
free_bytes += utarray_len(compile_state->internal_hit_paths) * sizeof(struct maat_internal_hit_path);
|
||||||
utarray_free(compile_state->internal_hit_paths);
|
utarray_free(compile_state->internal_hit_paths);
|
||||||
compile_state->internal_hit_paths = NULL;
|
compile_state->internal_hit_paths = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compile_state->all_hit_clauses != NULL) {
|
if (compile_state->all_hit_clauses != NULL) {
|
||||||
|
free_bytes += utarray_len(compile_state->all_hit_clauses) * sizeof(long long);
|
||||||
utarray_free(compile_state->all_hit_clauses);
|
utarray_free(compile_state->all_hit_clauses);
|
||||||
compile_state->all_hit_clauses = NULL;
|
compile_state->all_hit_clauses = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compile_state->this_scan_hit_clauses != NULL) {
|
if (compile_state->this_scan_hit_clauses != NULL) {
|
||||||
|
free_bytes += utarray_len(compile_state->this_scan_hit_clauses) * sizeof(long long);
|
||||||
utarray_free(compile_state->this_scan_hit_clauses);
|
utarray_free(compile_state->this_scan_hit_clauses);
|
||||||
compile_state->this_scan_hit_clauses = NULL;
|
compile_state->this_scan_hit_clauses = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE(compile_state);
|
FREE(compile_state);
|
||||||
|
|
||||||
|
free_bytes += sizeof(struct maat_compile_state);
|
||||||
|
alignment_int64_array_add(maat_instance->stat->maat_state_free_bytes, thread_id, free_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int maat_compile_hit_path_add(UT_array *hit_paths, long long item_id,
|
static int maat_compile_hit_path_add(UT_array *hit_paths, long long item_id,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
struct cm_table_info_t
|
struct cm_table_info_t
|
||||||
{
|
{
|
||||||
char table_name[NAME_MAX];
|
char table_name[MAX_NAME_STR_LEN];
|
||||||
char cfg_path[NAME_MAX];
|
char cfg_path[NAME_MAX];
|
||||||
int cfg_num;
|
int cfg_num;
|
||||||
char encrypt_algo[NAME_MAX];
|
char encrypt_algo[NAME_MAX];
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ enum MAAT_FS_STATUS {
|
|||||||
STATUS_GROUP_REF_EXCL_NUM, //group reference exclude group num
|
STATUS_GROUP_REF_EXCL_NUM, //group reference exclude group num
|
||||||
STATUS_COMPILE_RULE_NUM,
|
STATUS_COMPILE_RULE_NUM,
|
||||||
STATUS_MAAT_STATE_NUM,
|
STATUS_MAAT_STATE_NUM,
|
||||||
|
STATUS_MAAT_STATE_FREE_NUM,
|
||||||
|
STATUS_MAAT_STATE_FREE_BYTES,
|
||||||
STATUS_COMPILE_STATE_NUM,
|
STATUS_COMPILE_STATE_NUM,
|
||||||
STATUS_GARBAGE_QSIZE,
|
STATUS_GARBAGE_QSIZE,
|
||||||
STATUS_TOTAL_SCAN_BYTES,
|
STATUS_TOTAL_SCAN_BYTES,
|
||||||
@@ -99,6 +101,10 @@ void maat_fieldstat_register(struct maat_stat *stat)
|
|||||||
"garbage_num", NULL, 0);
|
"garbage_num", NULL, 0);
|
||||||
stat->fs_status_id[STATUS_MAAT_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
stat->fs_status_id[STATUS_MAAT_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
"maat_state", NULL, 0);
|
"maat_state", NULL, 0);
|
||||||
|
stat->fs_status_id[STATUS_MAAT_STATE_FREE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
|
"maat_state_free_cnt", NULL, 0);
|
||||||
|
stat->fs_status_id[STATUS_MAAT_STATE_FREE_BYTES] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
|
"maat_state_free_bytes", NULL, 0);
|
||||||
stat->fs_status_id[STATUS_COMPILE_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
stat->fs_status_id[STATUS_COMPILE_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
"maat_compile_state", NULL, 0);
|
"maat_compile_state", NULL, 0);
|
||||||
stat->fs_status_id[STATUS_ZOMBIE_RS_STREAM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
stat->fs_status_id[STATUS_ZOMBIE_RS_STREAM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
@@ -215,6 +221,8 @@ struct maat_stat *maat_stat_new(const char *stat_file, size_t max_thread_num,
|
|||||||
stat->not_grp_hit_cnt = alignment_int64_array_alloc(max_thread_num);
|
stat->not_grp_hit_cnt = alignment_int64_array_alloc(max_thread_num);
|
||||||
stat->maat_state_cnt = alignment_int64_array_alloc(max_thread_num);
|
stat->maat_state_cnt = alignment_int64_array_alloc(max_thread_num);
|
||||||
stat->maat_compile_state_cnt = alignment_int64_array_alloc(max_thread_num);
|
stat->maat_compile_state_cnt = alignment_int64_array_alloc(max_thread_num);
|
||||||
|
stat->maat_state_free_cnt = alignment_int64_array_alloc(max_thread_num);
|
||||||
|
stat->maat_state_free_bytes = alignment_int64_array_alloc(max_thread_num);
|
||||||
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
@@ -250,6 +258,16 @@ void maat_stat_free(struct maat_stat *stat)
|
|||||||
stat->maat_compile_state_cnt = NULL;
|
stat->maat_compile_state_cnt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stat->maat_state_free_cnt != NULL) {
|
||||||
|
alignment_int64_array_free(stat->maat_state_free_cnt);
|
||||||
|
stat->maat_state_free_cnt = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stat->maat_state_free_bytes != NULL) {
|
||||||
|
alignment_int64_array_free(stat->maat_state_free_bytes);
|
||||||
|
stat->maat_state_free_bytes = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (stat->fs_handle != NULL) {
|
if (stat->fs_handle != NULL) {
|
||||||
fieldstat_instance_free(stat->fs_handle);
|
fieldstat_instance_free(stat->fs_handle);
|
||||||
stat->fs_handle = NULL;
|
stat->fs_handle = NULL;
|
||||||
@@ -451,6 +469,10 @@ void maat_stat_output(struct maat_stat *stat, long long maat_version, int perf_o
|
|||||||
stat->nr_worker_thread);
|
stat->nr_worker_thread);
|
||||||
long long maat_state_cnt = alignment_int64_array_sum(stat->maat_state_cnt,
|
long long maat_state_cnt = alignment_int64_array_sum(stat->maat_state_cnt,
|
||||||
stat->nr_worker_thread);
|
stat->nr_worker_thread);
|
||||||
|
long long maat_state_free_cnt = alignment_int64_array_sum(stat->maat_state_free_cnt,
|
||||||
|
stat->nr_worker_thread);
|
||||||
|
long long maat_state_free_bytes = alignment_int64_array_sum(stat->maat_state_free_bytes,
|
||||||
|
stat->nr_worker_thread);
|
||||||
long long maat_compile_state_cnt = alignment_int64_array_sum(stat->maat_compile_state_cnt,
|
long long maat_compile_state_cnt = alignment_int64_array_sum(stat->maat_compile_state_cnt,
|
||||||
stat->nr_worker_thread);
|
stat->nr_worker_thread);
|
||||||
long long not_grp_hit_cnt = alignment_int64_array_sum(stat->not_grp_hit_cnt,
|
long long not_grp_hit_cnt = alignment_int64_array_sum(stat->not_grp_hit_cnt,
|
||||||
@@ -466,6 +488,10 @@ void maat_stat_output(struct maat_stat *stat, long long maat_version, int perf_o
|
|||||||
table_cnt);
|
table_cnt);
|
||||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_MAAT_STATE_NUM],
|
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_MAAT_STATE_NUM],
|
||||||
maat_state_cnt);
|
maat_state_cnt);
|
||||||
|
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_MAAT_STATE_FREE_NUM],
|
||||||
|
maat_state_free_cnt);
|
||||||
|
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_MAAT_STATE_FREE_BYTES],
|
||||||
|
maat_state_free_bytes);
|
||||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_COMPILE_STATE_NUM],
|
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_COMPILE_STATE_NUM],
|
||||||
maat_compile_state_cnt);
|
maat_compile_state_cnt);
|
||||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_NOT_GROUP_HIT],
|
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_NOT_GROUP_HIT],
|
||||||
|
|||||||
Reference in New Issue
Block a user