mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Support to disable stats by default
This commit is contained in:
parent
7d75f0af0f
commit
0fe031a156
8 changed files with 65 additions and 32 deletions
3
trunk/3rdparty/st-srs/Makefile
vendored
3
trunk/3rdparty/st-srs/Makefile
vendored
|
@ -286,6 +286,9 @@ endif
|
|||
#
|
||||
# make EXTRA_CFLAGS="-DMD_HAVE_SENDMMSG -D_GNU_SOURCE"
|
||||
#
|
||||
# or to enable stats for ST:
|
||||
#
|
||||
# make EXTRA_CFLAGS=-DDEBUG_STATS
|
||||
##########################
|
||||
|
||||
CFLAGS += $(DEFINES) $(OTHER_FLAGS) $(EXTRA_CFLAGS)
|
||||
|
|
10
trunk/3rdparty/st-srs/event.c
vendored
10
trunk/3rdparty/st-srs/event.c
vendored
|
@ -48,7 +48,7 @@
|
|||
#endif
|
||||
|
||||
// Global stat.
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
unsigned long long _st_stat_epoll = 0;
|
||||
unsigned long long _st_stat_epoll_zero = 0;
|
||||
unsigned long long _st_stat_epoll_shake = 0;
|
||||
|
@ -1213,7 +1213,7 @@ ST_HIDDEN void _st_epoll_dispatch(void)
|
|||
int events, op;
|
||||
short revents;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_epoll;
|
||||
#endif
|
||||
|
||||
|
@ -1225,12 +1225,12 @@ ST_HIDDEN void _st_epoll_dispatch(void)
|
|||
|
||||
// At least wait 1ms when <1ms, to avoid epoll_wait spin loop.
|
||||
if (timeout == 0) {
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_epoll_zero;
|
||||
#endif
|
||||
|
||||
if (min_timeout > 0) {
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_epoll_shake;
|
||||
#endif
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ ST_HIDDEN void _st_epoll_dispatch(void)
|
|||
/* Check for I/O operations */
|
||||
nfd = epoll_wait(_st_epoll_data->epfd, _st_epoll_data->evtlist, _st_epoll_data->evtlist_size, timeout);
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
if (nfd <= 0) {
|
||||
++_st_stat_epoll_spin;
|
||||
}
|
||||
|
|
38
trunk/3rdparty/st-srs/io.c
vendored
38
trunk/3rdparty/st-srs/io.c
vendored
|
@ -53,7 +53,7 @@
|
|||
#include "common.h"
|
||||
|
||||
// Global stat.
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
unsigned long long _st_stat_recvfrom = 0;
|
||||
unsigned long long _st_stat_recvfrom_eagain = 0;
|
||||
unsigned long long _st_stat_sendto = 0;
|
||||
|
@ -457,7 +457,7 @@ ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout)
|
|||
{
|
||||
ssize_t n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_read;
|
||||
#endif
|
||||
|
||||
|
@ -467,7 +467,7 @@ ssize_t st_read(_st_netfd_t *fd, void *buf, size_t nbyte, st_utime_t timeout)
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_read_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -499,7 +499,7 @@ ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, st_utim
|
|||
{
|
||||
ssize_t n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_readv;
|
||||
#endif
|
||||
|
||||
|
@ -509,7 +509,7 @@ ssize_t st_readv(_st_netfd_t *fd, const struct iovec *iov, int iov_size, st_utim
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_readv_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -610,7 +610,7 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, st_uti
|
|||
tmp_iov = (struct iovec *) iov; /* we promise not to modify iov */
|
||||
iov_cnt = iov_size;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_writev;
|
||||
#endif
|
||||
|
||||
|
@ -658,7 +658,7 @@ ssize_t st_writev(_st_netfd_t *fd, const struct iovec *iov, int iov_size, st_uti
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_writev_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -680,7 +680,7 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, st_utime
|
|||
{
|
||||
ssize_t n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_writev;
|
||||
#endif
|
||||
|
||||
|
@ -710,7 +710,7 @@ int st_writev_resid(_st_netfd_t *fd, struct iovec **iov, int *iov_size, st_utime
|
|||
(*iov)->iov_len -= n;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_writev_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -730,7 +730,7 @@ int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, int
|
|||
{
|
||||
int n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_recvfrom;
|
||||
#endif
|
||||
|
||||
|
@ -740,7 +740,7 @@ int st_recvfrom(_st_netfd_t *fd, void *buf, int len, struct sockaddr *from, int
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_recvfrom_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -757,7 +757,7 @@ int st_sendto(_st_netfd_t *fd, const void *msg, int len, const struct sockaddr *
|
|||
{
|
||||
int n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendto;
|
||||
#endif
|
||||
|
||||
|
@ -767,7 +767,7 @@ int st_sendto(_st_netfd_t *fd, const void *msg, int len, const struct sockaddr *
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendto_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -784,7 +784,7 @@ int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, st_utime_t timeou
|
|||
{
|
||||
int n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_recvmsg;
|
||||
#endif
|
||||
|
||||
|
@ -794,7 +794,7 @@ int st_recvmsg(_st_netfd_t *fd, struct msghdr *msg, int flags, st_utime_t timeou
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_recvmsg_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -811,7 +811,7 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
|
|||
{
|
||||
int n;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendmsg;
|
||||
#endif
|
||||
|
||||
|
@ -821,7 +821,7 @@ int st_sendmsg(_st_netfd_t *fd, const struct msghdr *msg, int flags, st_utime_t
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendmsg_eagain;
|
||||
#endif
|
||||
|
||||
|
@ -840,7 +840,7 @@ int st_sendmmsg(st_netfd_t fd, struct st_mmsghdr *msgvec, unsigned int vlen, int
|
|||
int left;
|
||||
struct mmsghdr *p;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendmmsg;
|
||||
#endif
|
||||
|
||||
|
@ -854,7 +854,7 @@ int st_sendmmsg(st_netfd_t fd, struct st_mmsghdr *msgvec, unsigned int vlen, int
|
|||
if (!_IO_NOT_READY_ERROR)
|
||||
break;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_sendmmsg_eagain;
|
||||
#endif
|
||||
|
||||
|
|
12
trunk/3rdparty/st-srs/sched.c
vendored
12
trunk/3rdparty/st-srs/sched.c
vendored
|
@ -53,7 +53,7 @@
|
|||
#endif
|
||||
|
||||
// Global stat.
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
unsigned long long _st_stat_sched_15ms = 0;
|
||||
unsigned long long _st_stat_sched_20ms = 0;
|
||||
unsigned long long _st_stat_sched_25ms = 0;
|
||||
|
@ -136,7 +136,7 @@ void _st_vp_schedule(void)
|
|||
_st_thread_t *thread;
|
||||
|
||||
if (_ST_RUNQ.next != &_ST_RUNQ) {
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_thread_run;
|
||||
#endif
|
||||
|
||||
|
@ -144,7 +144,7 @@ void _st_vp_schedule(void)
|
|||
thread = _ST_THREAD_PTR(_ST_RUNQ.next);
|
||||
_ST_DEL_RUNQ(thread);
|
||||
} else {
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_thread_idle;
|
||||
#endif
|
||||
|
||||
|
@ -509,7 +509,7 @@ void _st_vp_check_clock(void)
|
|||
elapsed = now < _ST_LAST_CLOCK? 0 : now - _ST_LAST_CLOCK; // Might step back.
|
||||
_ST_LAST_CLOCK = now;
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
if (elapsed <= 10000) {
|
||||
++_st_stat_sched_15ms;
|
||||
} else if (elapsed <= 21000) {
|
||||
|
@ -560,7 +560,7 @@ void st_thread_yield()
|
|||
{
|
||||
_st_thread_t *me = _ST_CURRENT_THREAD();
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_thread_yield;
|
||||
#endif
|
||||
|
||||
|
@ -572,7 +572,7 @@ void st_thread_yield()
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
#if defined(DEBUG) && defined(DEBUG_STATS)
|
||||
++_st_stat_thread_yield2;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue