TSG-11147: 性能优化,使用sapp_get_platform_opt(SPO_CURTIME_TIMET_MS)代替clock_gettime()
This commit is contained in:
@@ -372,6 +372,15 @@ static int is_deny_application(Maat_rule_t *p_result)
|
||||
return ret;
|
||||
}
|
||||
|
||||
long long get_current_time_ms(void)
|
||||
{
|
||||
int size=sizeof(long long);
|
||||
long long current_time_ms=0;
|
||||
sapp_get_platform_opt(SPO_CURTIME_TIMET_MS, ¤t_time_ms, &size);
|
||||
|
||||
return current_time_ms;
|
||||
}
|
||||
|
||||
int set_struct_project(const struct streaminfo *a_stream, int project_id, void *data)
|
||||
{
|
||||
if(a_stream==NULL || project_id<0)
|
||||
@@ -1821,7 +1830,7 @@ static int app_identify_result_cb(const struct streaminfo *a_stream, int bridge_
|
||||
return 0;
|
||||
}
|
||||
|
||||
record_time_start(&(context->last_scan_time));
|
||||
context->last_scan_time=get_current_time_ms();
|
||||
hit_num=scan_application_id_and_properties((struct streaminfo *)a_stream, scan_result, MAX_RESULT_NUM, context, &(gather_result[identify_result->origin]), a_stream->threadnum);
|
||||
p_result=tsg_policy_decision_criteria(scan_result, hit_num);
|
||||
if(p_result==NULL || (p_result->action==TSG_ACTION_MONITOR && is_parent_ssl==1))
|
||||
@@ -1919,7 +1928,7 @@ static unsigned char tsg_master_data_entry(const struct streaminfo *a_stream, vo
|
||||
{
|
||||
*pme=(void *)context;
|
||||
}
|
||||
record_time_start(&context->last_scan_time);
|
||||
context->last_scan_time=get_current_time_ms();
|
||||
}
|
||||
|
||||
switch(a_stream->opstate)
|
||||
@@ -1955,7 +1964,7 @@ static unsigned char tsg_master_data_entry(const struct streaminfo *a_stream, vo
|
||||
break;
|
||||
}
|
||||
|
||||
if(record_time_elapse_us(&context->last_scan_time) < (g_tsg_para.scan_time_interval*1000000))
|
||||
if(get_current_time_ms()-context->last_scan_time < (g_tsg_para.scan_time_interval*1000))
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -1966,7 +1975,7 @@ static unsigned char tsg_master_data_entry(const struct streaminfo *a_stream, vo
|
||||
context->mid=NULL;
|
||||
}
|
||||
|
||||
record_time_start(&context->last_scan_time);
|
||||
context->last_scan_time=get_current_time_ms();
|
||||
ret=tsg_scan_nesting_addr(g_tsg_maat_feather, a_stream, context->proto, &context->mid, scan_result+hit_num, MAX_RESULT_NUM-hit_num);
|
||||
if(ret>0)
|
||||
{
|
||||
|
||||
@@ -240,7 +240,7 @@ struct master_context
|
||||
};
|
||||
scan_status_t mid;
|
||||
struct Maat_rule_t *result;
|
||||
struct hited_app_para hited_para;
|
||||
struct hited_app_para hited_para;
|
||||
long long last_scan_time;
|
||||
};
|
||||
|
||||
@@ -415,6 +415,7 @@ int tsg_gtp_signaling_hash_init(const char* conffile, void *logger);
|
||||
|
||||
int set_struct_project(const struct streaminfo *a_stream, int project_id, void *data);
|
||||
const void *get_struct_project(const struct streaminfo *a_stream, int project_id);
|
||||
|
||||
long long get_current_time_ms(void);
|
||||
|
||||
//parent_app_name.app_name
|
||||
|
||||
@@ -119,13 +119,13 @@ static int register_topic(struct tsg_log_instance_t *instance, struct topic_stat
|
||||
topic->topic_rkt=rd_kafka_topic_new(_instance->kafka_handle, topic->name, topic_conf);
|
||||
|
||||
int thread_num=get_thread_count();
|
||||
topic->drop_start=(struct timespec *)calloc(thread_num, sizeof(struct timespec));
|
||||
topic->drop_start=(long long *)calloc(thread_num, sizeof(long long));
|
||||
topic->send_log_percent=(int *)calloc(thread_num, sizeof(int));
|
||||
|
||||
for(int i=0; i<thread_num; i++)
|
||||
{
|
||||
topic->send_log_percent[i]=100;
|
||||
clock_gettime(CLOCK_REALTIME, &(topic->drop_start[i]));
|
||||
topic->drop_start[i]=get_current_time_ms();
|
||||
}
|
||||
|
||||
topic->fs2_line_id=FS_register(_instance->fs2_handle, FS_STYLE_LINE, FS_CALC_SPEED, topic->name);
|
||||
@@ -136,11 +136,9 @@ static int register_topic(struct tsg_log_instance_t *instance, struct topic_stat
|
||||
|
||||
static int update_percent(struct tsg_log_instance_t *_instance, int service_id, enum LOG_COLUMN_STATUS column, int thread_id)
|
||||
{
|
||||
struct timespec cur_time;
|
||||
long long current_time_ms=get_current_time_ms();
|
||||
struct topic_stat *topic=(struct topic_stat *)&(_instance->service2topic[service_id]);
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &cur_time);
|
||||
|
||||
switch(column)
|
||||
{
|
||||
case LOG_COLUMN_STATUS_SUCCESS:
|
||||
@@ -156,14 +154,14 @@ static int update_percent(struct tsg_log_instance_t *_instance, int service_id,
|
||||
|
||||
FS_operate(_instance->fs2_handle, _instance->sum_line_id, _instance->fs2_column_id[column], FS_OP_ADD, 1);
|
||||
FS_operate(_instance->fs2_handle, _instance->sum_line_id, _instance->fs2_column_id[column+1], FS_OP_ADD, 1);
|
||||
if(cur_time.tv_sec - topic->drop_start[thread_id].tv_sec>=1)
|
||||
if(current_time_ms - topic->drop_start[thread_id]>=1000)
|
||||
{
|
||||
topic->send_log_percent[thread_id]/=2;
|
||||
topic->drop_start[thread_id]=cur_time;
|
||||
topic->drop_start[thread_id]=current_time_ms;
|
||||
}
|
||||
break;
|
||||
case LOG_COLUMN_STATUS_DROP:
|
||||
if((cur_time.tv_nsec%100) > topic->send_log_percent[thread_id])
|
||||
if((current_time_ms%100) > topic->send_log_percent[thread_id])
|
||||
{
|
||||
FS_operate(_instance->fs2_handle, topic->fs2_line_id, _instance->fs2_column_id[column], FS_OP_ADD, 1);
|
||||
FS_operate(_instance->fs2_handle, topic->fs2_line_id, _instance->fs2_column_id[column+1], FS_OP_ADD, 1);
|
||||
@@ -179,10 +177,10 @@ static int update_percent(struct tsg_log_instance_t *_instance, int service_id,
|
||||
break;
|
||||
}
|
||||
|
||||
if((cur_time.tv_sec - topic->drop_start[thread_id].tv_sec) >= _instance->recovery_interval)
|
||||
if((current_time_ms - topic->drop_start[thread_id]) >= _instance->recovery_interval*1000)
|
||||
{
|
||||
topic->send_log_percent[thread_id]++;
|
||||
topic->drop_start[thread_id]=cur_time;
|
||||
topic->drop_start[thread_id]=current_time_ms;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -419,13 +417,11 @@ static int set_direction(struct tsg_log_instance_t *_instance, struct TLD_handle
|
||||
|
||||
static int set_address_list(struct tsg_log_instance_t *_instance, struct TLD_handle_t *_handle, struct streaminfo *a_stream)
|
||||
{
|
||||
int ret=0;
|
||||
unsigned short tunnel_type=0;
|
||||
char nest_addr_buf[1024];
|
||||
int tunnel_type_size=sizeof(tunnel_type);
|
||||
|
||||
ret=MESA_get_stream_opt(a_stream, MSO_STREAM_TUNNEL_TYPE, &tunnel_type, &tunnel_type_size);
|
||||
assert(ret==0);
|
||||
MESA_get_stream_opt(a_stream, MSO_STREAM_TUNNEL_TYPE, &tunnel_type, &tunnel_type_size);
|
||||
if(tunnel_type==STREAM_TUNNLE_NON)
|
||||
{
|
||||
layer_addr_ntop_r(a_stream,nest_addr_buf, sizeof(nest_addr_buf));
|
||||
|
||||
@@ -181,7 +181,7 @@ struct topic_stat
|
||||
int fs2_line_id;
|
||||
int *send_log_percent;
|
||||
char name[MAX_STRING_LEN];
|
||||
struct timespec *drop_start;
|
||||
long long *drop_start;
|
||||
rd_kafka_topic_t *topic_rkt;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user