Skip to content

Commit

Permalink
Threads-Hybrid: Change pps stat to thread-local.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Apr 26, 2021
1 parent 9eb9b19 commit 963a0fa
Show file tree
Hide file tree
Showing 15 changed files with 390 additions and 200 deletions.
8 changes: 4 additions & 4 deletions trunk/src/app/srs_app_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ using namespace std;

#include <srs_protocol_kbps.hpp>

SrsPps* _srs_pps_ids = new SrsPps();
SrsPps* _srs_pps_fids = new SrsPps();
SrsPps* _srs_pps_fids_level0 = new SrsPps();
SrsPps* _srs_pps_dispose = new SrsPps();
__thread SrsPps* _srs_pps_ids = NULL;
__thread SrsPps* _srs_pps_fids = NULL;
__thread SrsPps* _srs_pps_fids_level0 = NULL;
__thread SrsPps* _srs_pps_dispose = NULL;

ISrsDisposingHandler::ISrsDisposingHandler()
{
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/app/srs_app_hourglass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ using namespace std;

#include <srs_protocol_kbps.hpp>

SrsPps* _srs_pps_timer = new SrsPps();
__thread SrsPps* _srs_pps_timer = NULL;

extern SrsPps* _srs_pps_clock_15ms;
extern SrsPps* _srs_pps_clock_20ms;
Expand Down
176 changes: 88 additions & 88 deletions trunk/src/app/srs_app_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,103 +33,103 @@

using namespace std;

extern SrsPps* _srs_pps_cids_get;
extern SrsPps* _srs_pps_cids_set;
extern __thread SrsPps* _srs_pps_cids_get;
extern __thread SrsPps* _srs_pps_cids_set;

extern SrsPps* _srs_pps_timer;
extern SrsPps* _srs_pps_pub;
extern SrsPps* _srs_pps_conn;
extern SrsPps* _srs_pps_dispose;
extern __thread SrsPps* _srs_pps_timer;
extern __thread SrsPps* _srs_pps_pub;
extern __thread SrsPps* _srs_pps_conn;
extern __thread SrsPps* _srs_pps_dispose;

#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
extern unsigned long long _st_stat_recvfrom;
extern unsigned long long _st_stat_recvfrom_eagain;
extern unsigned long long _st_stat_sendto;
extern unsigned long long _st_stat_sendto_eagain;
SrsPps* _srs_pps_recvfrom = new SrsPps();
SrsPps* _srs_pps_recvfrom_eagain = new SrsPps();
SrsPps* _srs_pps_sendto = new SrsPps();
SrsPps* _srs_pps_sendto_eagain = new SrsPps();

extern unsigned long long _st_stat_read;
extern unsigned long long _st_stat_read_eagain;
extern unsigned long long _st_stat_readv;
extern unsigned long long _st_stat_readv_eagain;
extern unsigned long long _st_stat_writev;
extern unsigned long long _st_stat_writev_eagain;
SrsPps* _srs_pps_read = new SrsPps();
SrsPps* _srs_pps_read_eagain = new SrsPps();
SrsPps* _srs_pps_readv = new SrsPps();
SrsPps* _srs_pps_readv_eagain = new SrsPps();
SrsPps* _srs_pps_writev = new SrsPps();
SrsPps* _srs_pps_writev_eagain = new SrsPps();

extern unsigned long long _st_stat_recvmsg;
extern unsigned long long _st_stat_recvmsg_eagain;
extern unsigned long long _st_stat_sendmsg;
extern unsigned long long _st_stat_sendmsg_eagain;
SrsPps* _srs_pps_recvmsg = new SrsPps();
SrsPps* _srs_pps_recvmsg_eagain = new SrsPps();
SrsPps* _srs_pps_sendmsg = new SrsPps();
SrsPps* _srs_pps_sendmsg_eagain = new SrsPps();

extern unsigned long long _st_stat_epoll;
extern unsigned long long _st_stat_epoll_zero;
extern unsigned long long _st_stat_epoll_shake;
extern unsigned long long _st_stat_epoll_spin;
SrsPps* _srs_pps_epoll = new SrsPps();
SrsPps* _srs_pps_epoll_zero = new SrsPps();
SrsPps* _srs_pps_epoll_shake = new SrsPps();
SrsPps* _srs_pps_epoll_spin = new SrsPps();

extern unsigned long long _st_stat_sched_15ms;
extern unsigned long long _st_stat_sched_20ms;
extern unsigned long long _st_stat_sched_25ms;
extern unsigned long long _st_stat_sched_30ms;
extern unsigned long long _st_stat_sched_35ms;
extern unsigned long long _st_stat_sched_40ms;
extern unsigned long long _st_stat_sched_80ms;
extern unsigned long long _st_stat_sched_160ms;
extern unsigned long long _st_stat_sched_s;
SrsPps* _srs_pps_sched_15ms = new SrsPps();
SrsPps* _srs_pps_sched_20ms = new SrsPps();
SrsPps* _srs_pps_sched_25ms = new SrsPps();
SrsPps* _srs_pps_sched_30ms = new SrsPps();
SrsPps* _srs_pps_sched_35ms = new SrsPps();
SrsPps* _srs_pps_sched_40ms = new SrsPps();
SrsPps* _srs_pps_sched_80ms = new SrsPps();
SrsPps* _srs_pps_sched_160ms = new SrsPps();
SrsPps* _srs_pps_sched_s = new SrsPps();
extern __thread unsigned long long _st_stat_recvfrom;
extern __thread unsigned long long _st_stat_recvfrom_eagain;
extern __thread unsigned long long _st_stat_sendto;
extern __thread unsigned long long _st_stat_sendto_eagain;
__thread SrsPps* _srs_pps_recvfrom = NULL;
__thread SrsPps* _srs_pps_recvfrom_eagain = NULL;
__thread SrsPps* _srs_pps_sendto = NULL;
__thread SrsPps* _srs_pps_sendto_eagain = NULL;

extern __thread unsigned long long _st_stat_read;
extern __thread unsigned long long _st_stat_read_eagain;
extern __thread unsigned long long _st_stat_readv;
extern __thread unsigned long long _st_stat_readv_eagain;
extern __thread unsigned long long _st_stat_writev;
extern __thread unsigned long long _st_stat_writev_eagain;
__thread SrsPps* _srs_pps_read = NULL;
__thread SrsPps* _srs_pps_read_eagain = NULL;
__thread SrsPps* _srs_pps_readv = NULL;
__thread SrsPps* _srs_pps_readv_eagain = NULL;
__thread SrsPps* _srs_pps_writev = NULL;
__thread SrsPps* _srs_pps_writev_eagain = NULL;

extern __thread unsigned long long _st_stat_recvmsg;
extern __thread unsigned long long _st_stat_recvmsg_eagain;
extern __thread unsigned long long _st_stat_sendmsg;
extern __thread unsigned long long _st_stat_sendmsg_eagain;
__thread SrsPps* _srs_pps_recvmsg = NULL;
__thread SrsPps* _srs_pps_recvmsg_eagain = NULL;
__thread SrsPps* _srs_pps_sendmsg = NULL;
__thread SrsPps* _srs_pps_sendmsg_eagain = NULL;

extern __thread unsigned long long _st_stat_epoll;
extern __thread unsigned long long _st_stat_epoll_zero;
extern __thread unsigned long long _st_stat_epoll_shake;
extern __thread unsigned long long _st_stat_epoll_spin;
__thread SrsPps* _srs_pps_epoll = NULL;
__thread SrsPps* _srs_pps_epoll_zero = NULL;
__thread SrsPps* _srs_pps_epoll_shake = NULL;
__thread SrsPps* _srs_pps_epoll_spin = NULL;

extern __thread unsigned long long _st_stat_sched_15ms;
extern __thread unsigned long long _st_stat_sched_20ms;
extern __thread unsigned long long _st_stat_sched_25ms;
extern __thread unsigned long long _st_stat_sched_30ms;
extern __thread unsigned long long _st_stat_sched_35ms;
extern __thread unsigned long long _st_stat_sched_40ms;
extern __thread unsigned long long _st_stat_sched_80ms;
extern __thread unsigned long long _st_stat_sched_160ms;
extern __thread unsigned long long _st_stat_sched_s;
__thread SrsPps* _srs_pps_sched_15ms = NULL;
__thread SrsPps* _srs_pps_sched_20ms = NULL;
__thread SrsPps* _srs_pps_sched_25ms = NULL;
__thread SrsPps* _srs_pps_sched_30ms = NULL;
__thread SrsPps* _srs_pps_sched_35ms = NULL;
__thread SrsPps* _srs_pps_sched_40ms = NULL;
__thread SrsPps* _srs_pps_sched_80ms = NULL;
__thread SrsPps* _srs_pps_sched_160ms = NULL;
__thread SrsPps* _srs_pps_sched_s = NULL;
#endif

SrsPps* _srs_pps_clock_15ms = new SrsPps();
SrsPps* _srs_pps_clock_20ms = new SrsPps();
SrsPps* _srs_pps_clock_25ms = new SrsPps();
SrsPps* _srs_pps_clock_30ms = new SrsPps();
SrsPps* _srs_pps_clock_35ms = new SrsPps();
SrsPps* _srs_pps_clock_40ms = new SrsPps();
SrsPps* _srs_pps_clock_80ms = new SrsPps();
SrsPps* _srs_pps_clock_160ms = new SrsPps();
SrsPps* _srs_pps_timer_s = new SrsPps();
__thread SrsPps* _srs_pps_clock_15ms = NULL;
__thread SrsPps* _srs_pps_clock_20ms = NULL;
__thread SrsPps* _srs_pps_clock_25ms = NULL;
__thread SrsPps* _srs_pps_clock_30ms = NULL;
__thread SrsPps* _srs_pps_clock_35ms = NULL;
__thread SrsPps* _srs_pps_clock_40ms = NULL;
__thread SrsPps* _srs_pps_clock_80ms = NULL;
__thread SrsPps* _srs_pps_clock_160ms = NULL;
__thread SrsPps* _srs_pps_timer_s = NULL;

#if defined(SRS_DEBUG) && defined(SRS_DEBUG_STATS)
extern int _st_active_count;
extern unsigned long long _st_stat_thread_run;
extern unsigned long long _st_stat_thread_idle;
extern unsigned long long _st_stat_thread_yield;
extern unsigned long long _st_stat_thread_yield2;
SrsPps* _srs_pps_thread_run = new SrsPps();
SrsPps* _srs_pps_thread_idle = new SrsPps();
SrsPps* _srs_pps_thread_yield = new SrsPps();
SrsPps* _srs_pps_thread_yield2 = new SrsPps();
extern __thread int _st_active_count;
extern __thread unsigned long long _st_stat_thread_run;
extern __thread unsigned long long _st_stat_thread_idle;
extern __thread unsigned long long _st_stat_thread_yield;
extern __thread unsigned long long _st_stat_thread_yield2;
__thread SrsPps* _srs_pps_thread_run = NULL;
__thread SrsPps* _srs_pps_thread_idle = NULL;
__thread SrsPps* _srs_pps_thread_yield = NULL;
__thread SrsPps* _srs_pps_thread_yield2 = NULL;
#endif

extern SrsPps* _srs_pps_objs_rtps;
extern SrsPps* _srs_pps_objs_rraw;
extern SrsPps* _srs_pps_objs_rfua;
extern SrsPps* _srs_pps_objs_rbuf;
extern SrsPps* _srs_pps_objs_msgs;
extern SrsPps* _srs_pps_objs_rothers;
extern __thread SrsPps* _srs_pps_objs_rtps;
extern __thread SrsPps* _srs_pps_objs_rraw;
extern __thread SrsPps* _srs_pps_objs_rfua;
extern __thread SrsPps* _srs_pps_objs_rbuf;
extern __thread SrsPps* _srs_pps_objs_msgs;
extern __thread SrsPps* _srs_pps_objs_rothers;

ISrsHybridServer::ISrsHybridServer()
{
Expand Down
8 changes: 4 additions & 4 deletions trunk/src/app/srs_app_listener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ using namespace std;

#include <srs_protocol_kbps.hpp>

SrsPps* _srs_pps_rpkts = new SrsPps();
SrsPps* _srs_pps_addrs = new SrsPps();
SrsPps* _srs_pps_fast_addrs = new SrsPps();
__thread SrsPps* _srs_pps_rpkts = NULL;
__thread SrsPps* _srs_pps_addrs = NULL;
__thread SrsPps* _srs_pps_fast_addrs = NULL;

SrsPps* _srs_pps_spkts = new SrsPps();
__thread SrsPps* _srs_pps_spkts = NULL;

// set the max packet size.
const int SRS_UDP_MAX_PACKET_SIZE = 1500;
Expand Down
32 changes: 16 additions & 16 deletions trunk/src/app/srs_app_rtc_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ using namespace std;

#include <srs_protocol_kbps.hpp>

SrsPps* _srs_pps_sstuns = new SrsPps();
SrsPps* _srs_pps_srtcps = new SrsPps();
SrsPps* _srs_pps_srtps = new SrsPps();

SrsPps* _srs_pps_pli = new SrsPps();
SrsPps* _srs_pps_twcc = new SrsPps();
SrsPps* _srs_pps_rr = new SrsPps();
SrsPps* _srs_pps_pub = new SrsPps();
SrsPps* _srs_pps_conn = new SrsPps();

extern SrsPps* _srs_pps_snack;
extern SrsPps* _srs_pps_snack2;

extern SrsPps* _srs_pps_rnack;
extern SrsPps* _srs_pps_rnack2;
extern SrsPps* _srs_pps_snack4;
__thread SrsPps* _srs_pps_sstuns = NULL;
__thread SrsPps* _srs_pps_srtcps = NULL;
__thread SrsPps* _srs_pps_srtps = NULL;

__thread SrsPps* _srs_pps_pli = NULL;
__thread SrsPps* _srs_pps_twcc = NULL;
__thread SrsPps* _srs_pps_rr = NULL;
__thread SrsPps* _srs_pps_pub = NULL;
__thread SrsPps* _srs_pps_conn = NULL;

extern __thread SrsPps* _srs_pps_snack;
extern __thread SrsPps* _srs_pps_snack2;

extern __thread SrsPps* _srs_pps_rnack;
extern __thread SrsPps* _srs_pps_rnack2;
extern __thread SrsPps* _srs_pps_snack4;

#define SRS_TICKID_RTCP 0
#define SRS_TICKID_TWCC 1
Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_rtc_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ using namespace std;

#include <srs_protocol_kbps.hpp>

extern SrsPps* _srs_pps_snack3;
extern SrsPps* _srs_pps_snack4;
extern __thread SrsPps* _srs_pps_snack3;
extern __thread SrsPps* _srs_pps_snack4;

SrsRtpRingBuffer::SrsRtpRingBuffer(int capacity)
{
Expand Down
72 changes: 36 additions & 36 deletions trunk/src/app/srs_app_rtc_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,42 @@ using namespace std;
#include <srs_app_rtc_api.hpp>
#include <srs_protocol_utility.hpp>

extern SrsPps* _srs_pps_rpkts;
SrsPps* _srs_pps_rstuns = new SrsPps();
SrsPps* _srs_pps_rrtps = new SrsPps();
SrsPps* _srs_pps_rrtcps = new SrsPps();
extern SrsPps* _srs_pps_addrs;
extern SrsPps* _srs_pps_fast_addrs;

extern SrsPps* _srs_pps_spkts;
extern SrsPps* _srs_pps_sstuns;
extern SrsPps* _srs_pps_srtcps;
extern SrsPps* _srs_pps_srtps;

extern SrsPps* _srs_pps_ids;
extern SrsPps* _srs_pps_fids;
extern SrsPps* _srs_pps_fids_level0;

extern SrsPps* _srs_pps_pli;
extern SrsPps* _srs_pps_twcc;
extern SrsPps* _srs_pps_rr;

extern SrsPps* _srs_pps_snack;
extern SrsPps* _srs_pps_snack2;
extern SrsPps* _srs_pps_snack3;
extern SrsPps* _srs_pps_snack4;
extern SrsPps* _srs_pps_sanack;
extern SrsPps* _srs_pps_svnack;

extern SrsPps* _srs_pps_rnack;
extern SrsPps* _srs_pps_rnack2;
extern SrsPps* _srs_pps_rhnack;
extern SrsPps* _srs_pps_rmnack;

extern SrsPps* _srs_pps_rloss;
extern SrsPps* _srs_pps_sloss;
extern SrsPps* _srs_pps_aloss;
extern SrsPps* _srs_pps_aloss2;
extern __thread SrsPps* _srs_pps_rpkts;
__thread SrsPps* _srs_pps_rstuns = NULL;
__thread SrsPps* _srs_pps_rrtps = NULL;
__thread SrsPps* _srs_pps_rrtcps = NULL;
extern __thread SrsPps* _srs_pps_addrs;
extern __thread SrsPps* _srs_pps_fast_addrs;

extern __thread SrsPps* _srs_pps_spkts;
extern __thread SrsPps* _srs_pps_sstuns;
extern __thread SrsPps* _srs_pps_srtcps;
extern __thread SrsPps* _srs_pps_srtps;

extern __thread SrsPps* _srs_pps_ids;
extern __thread SrsPps* _srs_pps_fids;
extern __thread SrsPps* _srs_pps_fids_level0;

extern __thread SrsPps* _srs_pps_pli;
extern __thread SrsPps* _srs_pps_twcc;
extern __thread SrsPps* _srs_pps_rr;

extern __thread SrsPps* _srs_pps_snack;
extern __thread SrsPps* _srs_pps_snack2;
extern __thread SrsPps* _srs_pps_snack3;
extern __thread SrsPps* _srs_pps_snack4;
extern __thread SrsPps* _srs_pps_sanack;
extern __thread SrsPps* _srs_pps_svnack;

extern __thread SrsPps* _srs_pps_rnack;
extern __thread SrsPps* _srs_pps_rnack2;
extern __thread SrsPps* _srs_pps_rhnack;
extern __thread SrsPps* _srs_pps_rmnack;

extern __thread SrsPps* _srs_pps_rloss;
extern __thread SrsPps* _srs_pps_sloss;
extern __thread SrsPps* _srs_pps_aloss;
extern __thread SrsPps* _srs_pps_aloss2;

SrsRtcBlackhole::SrsRtcBlackhole()
{
Expand Down
26 changes: 13 additions & 13 deletions trunk/src/app/srs_app_rtc_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@
#include <srs_protocol_kbps.hpp>

// The NACK sent by us(SFU).
SrsPps* _srs_pps_snack = new SrsPps();
SrsPps* _srs_pps_snack2 = new SrsPps();
SrsPps* _srs_pps_snack3 = new SrsPps();
SrsPps* _srs_pps_snack4 = new SrsPps();
SrsPps* _srs_pps_sanack = new SrsPps();
SrsPps* _srs_pps_svnack = new SrsPps();

SrsPps* _srs_pps_rnack = new SrsPps();
SrsPps* _srs_pps_rnack2 = new SrsPps();
SrsPps* _srs_pps_rhnack = new SrsPps();
SrsPps* _srs_pps_rmnack = new SrsPps();

extern SrsPps* _srs_pps_aloss2;
__thread SrsPps* _srs_pps_snack = NULL;
__thread SrsPps* _srs_pps_snack2 = NULL;
__thread SrsPps* _srs_pps_snack3 = NULL;
__thread SrsPps* _srs_pps_snack4 = NULL;
__thread SrsPps* _srs_pps_sanack = NULL;
__thread SrsPps* _srs_pps_svnack = NULL;

__thread SrsPps* _srs_pps_rnack = NULL;
__thread SrsPps* _srs_pps_rnack2 = NULL;
__thread SrsPps* _srs_pps_rhnack = NULL;
__thread SrsPps* _srs_pps_rmnack = NULL;

extern __thread SrsPps* _srs_pps_aloss2;

// Firefox defaults as 109, Chrome is 111.
const int kAudioPayloadType = 111;
Expand Down
Loading

0 comments on commit 963a0fa

Please sign in to comment.