when worker thread exit, print per thread stat to log file
This commit is contained in:
@@ -177,6 +177,18 @@ static inline void merge_thread_stat(struct stellar_thread *thread)
|
||||
stellar_stat_merge(runtime->stat, &thr_stat, thread->idx);
|
||||
}
|
||||
|
||||
static inline void print_thread_stat(struct stellar_thread *thread)
|
||||
{
|
||||
struct stellar *st = thread->st;
|
||||
struct stellar_runtime *runtime = &st->runtime;
|
||||
struct thread_stat thr_stat = {
|
||||
.packet_io = packet_io_stat(runtime->packet_io, thread->idx),
|
||||
.ip_reassembly = ip_reassembly_stat(thread->ip_mgr),
|
||||
.session_mgr = session_manager_stat(thread->sess_mgr),
|
||||
};
|
||||
stellar_stat_print(runtime->stat, &thr_stat, thread->idx);
|
||||
}
|
||||
|
||||
static void *work_thread(void *arg)
|
||||
{
|
||||
int nr_recv;
|
||||
@@ -333,21 +345,21 @@ static void *work_thread(void *arg)
|
||||
plugin_manager_on_polling(plug_mgr);
|
||||
|
||||
// per free_expired_session_interval MAX free_expired_session_batch sessions are released
|
||||
if (now_ms - sched_data->last_free_expired_session_timestamp > sched_data->free_expired_session_interval)
|
||||
if (now_ms - sched_data->last_free_expired_session_timestamp >= sched_data->free_expired_session_interval)
|
||||
{
|
||||
free_expired_sessions(sess_mgr, sched_data->free_expired_session_batch, now_ms);
|
||||
sched_data->last_free_expired_session_timestamp = now_ms;
|
||||
}
|
||||
|
||||
// per merge_stat_interval merge thread stat
|
||||
if (now_ms - sched_data->last_merge_thread_stat_timestamp > sched_data->merge_stat_interval)
|
||||
if (now_ms - sched_data->last_merge_thread_stat_timestamp >= sched_data->merge_stat_interval)
|
||||
{
|
||||
merge_thread_stat(thread);
|
||||
sched_data->last_merge_thread_stat_timestamp = now_ms;
|
||||
}
|
||||
|
||||
// per free_expired_ip_frag_interval MAX free_expired_ip_frag_batch ip fragments are released
|
||||
if (now_ms - sched_data->last_free_expired_ip_frag_timestamp > sched_data->free_expired_ip_frag_interval)
|
||||
if (now_ms - sched_data->last_free_expired_ip_frag_timestamp >= sched_data->free_expired_ip_frag_interval)
|
||||
{
|
||||
ip_reassembly_expire(ip_reass, sched_data->free_expired_ip_frag_batch, now_ms);
|
||||
sched_data->last_free_expired_ip_frag_timestamp = now_ms;
|
||||
@@ -359,6 +371,9 @@ static void *work_thread(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
merge_thread_stat(thread);
|
||||
print_thread_stat(thread);
|
||||
|
||||
ATOMIC_SET(&thread->is_runing, 0);
|
||||
CORE_LOG_FATAL("worker thread %d exit", thr_idx);
|
||||
|
||||
@@ -601,7 +616,7 @@ void stellar_run(struct stellar *st)
|
||||
runtime->stat_last_output_ts = clock_get_real_time_ms();
|
||||
while (!ATOMIC_READ(&runtime->need_exit))
|
||||
{
|
||||
if (clock_get_real_time_ms() - runtime->stat_last_output_ts > config->sched_opts.output_stat_interval)
|
||||
if (clock_get_real_time_ms() - runtime->stat_last_output_ts >= config->sched_opts.output_stat_interval)
|
||||
{
|
||||
runtime->stat_last_output_ts = clock_get_real_time_ms();
|
||||
stellar_stat_output(runtime->stat);
|
||||
@@ -616,6 +631,9 @@ void stellar_run(struct stellar *st)
|
||||
ATOMIC_SET(&runtime->need_exit, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// berfore exit, output last stat
|
||||
stellar_stat_output(runtime->stat);
|
||||
}
|
||||
|
||||
void stellar_free(struct stellar *st)
|
||||
|
||||
Reference in New Issue
Block a user