[patch]add maat_compile_state statistics
This commit is contained in:
@@ -155,6 +155,7 @@ struct maat_stat {
|
|||||||
long long *hit_cnt;
|
long long *hit_cnt;
|
||||||
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 scan_err_cnt;
|
long long scan_err_cnt;
|
||||||
long long zombie_rs_stream;
|
long long zombie_rs_stream;
|
||||||
|
|||||||
@@ -1729,6 +1729,8 @@ void maat_state_free(struct maat_state *state)
|
|||||||
if (state->compile_state != NULL) {
|
if (state->compile_state != NULL) {
|
||||||
maat_compile_state_free(state->compile_state);
|
maat_compile_state_free(state->compile_state);
|
||||||
state->compile_state = NULL;
|
state->compile_state = NULL;
|
||||||
|
alignment_int64_array_add(maat_instance->stat->maat_compile_state_cnt,
|
||||||
|
state->thread_id, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
state->maat_instance = NULL;
|
state->maat_instance = NULL;
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "maat_group.h"
|
#include "maat_group.h"
|
||||||
#include "maat_ex_data.h"
|
#include "maat_ex_data.h"
|
||||||
#include "maat_table.h"
|
#include "maat_table.h"
|
||||||
|
#include "alignment.h"
|
||||||
|
|
||||||
#define MODULE_COMPILE module_name_str("maat.compile")
|
#define MODULE_COMPILE module_name_str("maat.compile")
|
||||||
#define MAX_TABLE_LINE_SIZE (1024 * 16)
|
#define MAX_TABLE_LINE_SIZE (1024 * 16)
|
||||||
@@ -2185,8 +2186,11 @@ void maat_compile_state_update(int vtable_id, struct maat_item *hit_items,
|
|||||||
hit_cnt = MAX_SCANNER_HIT_GROUP_NUM;
|
hit_cnt = MAX_SCANNER_HIT_GROUP_NUM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct maat *maat_instance = state->maat_instance;
|
||||||
if (NULL == state->compile_state) {
|
if (NULL == state->compile_state) {
|
||||||
state->compile_state = maat_compile_state_new(state->thread_id);
|
state->compile_state = maat_compile_state_new(state->thread_id);
|
||||||
|
alignment_int64_array_add(maat_instance->stat->maat_compile_state_cnt,
|
||||||
|
state->thread_id, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < hit_cnt; i++) {
|
for (i = 0; i < hit_cnt; i++) {
|
||||||
@@ -2200,17 +2204,17 @@ void maat_compile_state_update(int vtable_id, struct maat_item *hit_items,
|
|||||||
if (state->compile_table_id > 0) {
|
if (state->compile_table_id > 0) {
|
||||||
compile_table_id = state->compile_table_id;
|
compile_table_id = state->compile_table_id;
|
||||||
} else {
|
} else {
|
||||||
compile_table_id = state->maat_instance->default_compile_table_id;
|
compile_table_id = maat_instance->default_compile_table_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *compile_rt = table_manager_get_runtime(state->maat_instance->tbl_mgr,
|
void *compile_rt = table_manager_get_runtime(maat_instance->tbl_mgr,
|
||||||
compile_table_id);
|
compile_table_id);
|
||||||
if (NULL == compile_rt) {
|
if (NULL == compile_rt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *g2g_rt = table_manager_get_runtime(state->maat_instance->tbl_mgr,
|
void *g2g_rt = table_manager_get_runtime(maat_instance->tbl_mgr,
|
||||||
state->maat_instance->g2g_table_id);
|
maat_instance->g2g_table_id);
|
||||||
if (NULL == g2g_rt) {
|
if (NULL == g2g_rt) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ 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_COMPILE_STATE_NUM,
|
||||||
STATUS_GARBAGE_QSIZE,
|
STATUS_GARBAGE_QSIZE,
|
||||||
STATUS_TOTAL_SCAN_BYTES,
|
STATUS_TOTAL_SCAN_BYTES,
|
||||||
STATUS_TOTAL_SCAN_CNT,
|
STATUS_TOTAL_SCAN_CNT,
|
||||||
@@ -98,6 +99,8 @@ 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_COMPILE_STATE_NUM] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
|
"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,
|
||||||
"z_stream", NULL, 0);
|
"z_stream", NULL, 0);
|
||||||
stat->fs_status_id[STATUS_NOT_GROUP_HIT] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
stat->fs_status_id[STATUS_NOT_GROUP_HIT] = fieldstat_register(stat->fs_handle, FIELD_TYPE_GAUGE,
|
||||||
@@ -143,7 +146,7 @@ int maat_fieldstat_table_row_register(struct maat_stat *stat, struct table_manag
|
|||||||
|
|
||||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->total_stat_id[COLUMN_HIT_RATE],
|
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->total_stat_id[COLUMN_HIT_RATE],
|
||||||
stat->total_stat_id[COLUMN_HIT_CNT],
|
stat->total_stat_id[COLUMN_HIT_CNT],
|
||||||
stat->total_stat_id[COLUMN_SCAN_CNT], 1000000000);
|
stat->total_stat_id[COLUMN_SCAN_CNT], 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed.");
|
log_error(stat->logger, MODULE_MAAT_STAT, "fieldstat set hit_rate for Sum failed.");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -186,7 +189,7 @@ int maat_fieldstat_table_row_register(struct maat_stat *stat, struct table_manag
|
|||||||
|
|
||||||
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->fs_column_id[i][COLUMN_HIT_RATE],
|
ret = fieldstat_set_metric_ratio_para(stat->fs_handle, stat->fs_column_id[i][COLUMN_HIT_RATE],
|
||||||
stat->fs_column_id[i][COLUMN_HIT_CNT],
|
stat->fs_column_id[i][COLUMN_HIT_CNT],
|
||||||
stat->fs_column_id[i][COLUMN_SCAN_CNT], 1000000000);
|
stat->fs_column_id[i][COLUMN_SCAN_CNT], 1);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
log_error(stat->logger, MODULE_MAAT_STAT,
|
log_error(stat->logger, MODULE_MAAT_STAT,
|
||||||
"fieldstat set hit_rate for %s failed.", table_name);
|
"fieldstat set hit_rate for %s failed.", table_name);
|
||||||
@@ -211,6 +214,7 @@ struct maat_stat *maat_stat_new(const char *stat_file, size_t max_thread_num,
|
|||||||
stat->hit_cnt = alignment_int64_array_alloc(max_thread_num);
|
stat->hit_cnt = alignment_int64_array_alloc(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);
|
||||||
|
|
||||||
return stat;
|
return stat;
|
||||||
}
|
}
|
||||||
@@ -241,6 +245,11 @@ void maat_stat_free(struct maat_stat *stat)
|
|||||||
stat->maat_state_cnt = NULL;
|
stat->maat_state_cnt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stat->maat_compile_state_cnt != NULL) {
|
||||||
|
alignment_int64_array_free(stat->maat_compile_state_cnt);
|
||||||
|
stat->maat_compile_state_cnt = 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;
|
||||||
@@ -442,6 +451,8 @@ 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_compile_state_cnt = alignment_int64_array_sum(stat->maat_compile_state_cnt,
|
||||||
|
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,
|
||||||
stat->nr_worker_thread);
|
stat->nr_worker_thread);
|
||||||
size_t table_cnt = table_manager_table_count(stat->ref_tbl_mgr);
|
size_t table_cnt = table_manager_table_count(stat->ref_tbl_mgr);
|
||||||
@@ -455,6 +466,8 @@ 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_COMPILE_STATE_NUM],
|
||||||
|
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],
|
||||||
not_grp_hit_cnt);
|
not_grp_hit_cnt);
|
||||||
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_CMD_LINE_NUM],
|
fieldstat_value_set(stat->fs_handle, stat->fs_status_id[STATUS_CMD_LINE_NUM],
|
||||||
|
|||||||
Reference in New Issue
Block a user