Core: Refine ST stat for thread switch

pull/2199/head
winlin 4 years ago
parent e726aba8f9
commit 71cc8e35d9

@ -63,6 +63,9 @@ unsigned long long _st_stat_sched_160ms = 0;
unsigned long long _st_stat_sched_320ms = 0;
unsigned long long _st_stat_sched_1000ms = 0;
unsigned long long _st_stat_sched_s = 0;
unsigned long long _st_stat_thread_run = 0;
unsigned long long _st_stat_thread_idle = 0;
#endif
@ -131,10 +134,18 @@ void _st_vp_schedule(void)
_st_thread_t *thread;
if (_ST_RUNQ.next != &_ST_RUNQ) {
#ifdef DEBUG
++_st_stat_thread_run;
#endif
/* Pull thread off of the run queue */
thread = _ST_THREAD_PTR(_ST_RUNQ.next);
_ST_DEL_RUNQ(thread);
} else {
#ifdef DEBUG
++_st_stat_thread_idle;
#endif
/* If there are no threads to run, switch to the idle thread */
thread = _st_this_vp.idle_thread;
}

@ -112,6 +112,11 @@ SrsPps* _srs_pps_clock_80ms = new SrsPps(_srs_clock);
SrsPps* _srs_pps_clock_160ms = new SrsPps(_srs_clock);
SrsPps* _srs_pps_timer_s = new SrsPps(_srs_clock);
extern unsigned long long _st_stat_thread_run;
extern unsigned long long _st_stat_thread_idle;
SrsPps* _srs_pps_thread_run = new SrsPps(_srs_clock);
SrsPps* _srs_pps_thread_idle = new SrsPps(_srs_clock);
ISrsHybridServer::ISrsHybridServer()
{
}
@ -248,7 +253,7 @@ srs_error_t SrsHybridServer::run()
}
// Wait for all server to quit.
srs_thread_exit(NULL);
srs_usleep(SRS_UTIME_NO_TIMEOUT);
return err;
}
@ -417,11 +422,19 @@ srs_error_t SrsHybridServer::notify(int event, srs_utime_t interval, srs_utime_t
clock_desc = buf;
}
srs_trace("Hybrid cpu=%.2f%%,%dMB%s%s%s%s%s%s%s%s%s",
string thread_desc;
_srs_pps_thread_run->update(_st_stat_thread_run); _srs_pps_thread_idle->update(_st_stat_thread_idle);
if (_srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s()) {
snprintf(buf, sizeof(buf), ", co=%d,%d", _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s());
thread_desc = buf;
}
srs_trace("Hybrid cpu=%.2f%%,%dMB%s%s%s%s%s%s%s%s%s%s",
u->percent * 100, memory,
cid_desc.c_str(), timer_desc.c_str(),
recvfrom_desc.c_str(), io_desc.c_str(), msg_desc.c_str(),
epoll_desc.c_str(), sched_desc.c_str(), clock_desc.c_str(),
thread_desc.c_str(),
free_desc.c_str()
);

Loading…
Cancel
Save