mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
For #2194, Core: Refine yield for high performance timer.
This commit is contained in:
parent
4fc1a19415
commit
a04dd7ed30
3 changed files with 16 additions and 8 deletions
1
trunk/3rdparty/st-srs/README.md
vendored
1
trunk/3rdparty/st-srs/README.md
vendored
|
@ -68,6 +68,7 @@ The branch [srs](https://github.com/ossrs/state-threads/tree/srs) will be patche
|
||||||
- [x] Support OSX for Apple Darwin, macOS, [#11](https://github.com/ossrs/state-threads/issues/11).
|
- [x] Support OSX for Apple Darwin, macOS, [#11](https://github.com/ossrs/state-threads/issues/11).
|
||||||
- [x] Support sendmmsg for UDP, [#12](https://github.com/ossrs/state-threads/issues/12).
|
- [x] Support sendmmsg for UDP, [#12](https://github.com/ossrs/state-threads/issues/12).
|
||||||
- [x] Refine performance for sleep or epoll_wait(0), [#17](https://github.com/ossrs/state-threads/issues/17).
|
- [x] Refine performance for sleep or epoll_wait(0), [#17](https://github.com/ossrs/state-threads/issues/17).
|
||||||
|
- [ ] Improve the performance of timer. [9fe8cfe5b](https://github.com/ossrs/state-threads/commit/9fe8cfe5b1c9741a2e671a46215184f267fba400), [7879c2b](https://github.com/ossrs/state-threads/commit/7879c2b), [387cddb](https://github.com/ossrs/state-threads/commit/387cddb)
|
||||||
|
|
||||||
## GDB Tools
|
## GDB Tools
|
||||||
|
|
||||||
|
|
15
trunk/3rdparty/st-srs/sched.c
vendored
15
trunk/3rdparty/st-srs/sched.c
vendored
|
@ -67,6 +67,7 @@ unsigned long long _st_stat_sched_s = 0;
|
||||||
unsigned long long _st_stat_thread_run = 0;
|
unsigned long long _st_stat_thread_run = 0;
|
||||||
unsigned long long _st_stat_thread_idle = 0;
|
unsigned long long _st_stat_thread_idle = 0;
|
||||||
unsigned long long _st_stat_thread_yield = 0;
|
unsigned long long _st_stat_thread_yield = 0;
|
||||||
|
unsigned long long _st_stat_thread_yield2 = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -559,11 +560,6 @@ void st_thread_yield()
|
||||||
{
|
{
|
||||||
_st_thread_t *me = _ST_CURRENT_THREAD();
|
_st_thread_t *me = _ST_CURRENT_THREAD();
|
||||||
|
|
||||||
// If not thread in RunQ to yield to, ignore and continue to run.
|
|
||||||
if (_ST_RUNQ.next == &_ST_RUNQ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
++_st_stat_thread_yield;
|
++_st_stat_thread_yield;
|
||||||
#endif
|
#endif
|
||||||
|
@ -571,6 +567,15 @@ void st_thread_yield()
|
||||||
/* Check sleep queue for expired threads */
|
/* Check sleep queue for expired threads */
|
||||||
_st_vp_check_clock();
|
_st_vp_check_clock();
|
||||||
|
|
||||||
|
// If not thread in RunQ to yield to, ignore and continue to run.
|
||||||
|
if (_ST_RUNQ.next == &_ST_RUNQ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
++_st_stat_thread_yield2;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Append thread to the tail of RunQ, we will back after all threads executed.
|
// Append thread to the tail of RunQ, we will back after all threads executed.
|
||||||
me->state = _ST_ST_RUNNABLE;
|
me->state = _ST_ST_RUNNABLE;
|
||||||
_ST_ADD_RUNQ(me);
|
_ST_ADD_RUNQ(me);
|
||||||
|
|
|
@ -116,9 +116,11 @@ extern int _st_active_count;
|
||||||
extern unsigned long long _st_stat_thread_run;
|
extern unsigned long long _st_stat_thread_run;
|
||||||
extern unsigned long long _st_stat_thread_idle;
|
extern unsigned long long _st_stat_thread_idle;
|
||||||
extern unsigned long long _st_stat_thread_yield;
|
extern unsigned long long _st_stat_thread_yield;
|
||||||
|
extern unsigned long long _st_stat_thread_yield2;
|
||||||
SrsPps* _srs_pps_thread_run = new SrsPps(_srs_clock);
|
SrsPps* _srs_pps_thread_run = new SrsPps(_srs_clock);
|
||||||
SrsPps* _srs_pps_thread_idle = new SrsPps(_srs_clock);
|
SrsPps* _srs_pps_thread_idle = new SrsPps(_srs_clock);
|
||||||
SrsPps* _srs_pps_thread_yield = new SrsPps(_srs_clock);
|
SrsPps* _srs_pps_thread_yield = new SrsPps(_srs_clock);
|
||||||
|
SrsPps* _srs_pps_thread_yield2 = new SrsPps(_srs_clock);
|
||||||
|
|
||||||
ISrsHybridServer::ISrsHybridServer()
|
ISrsHybridServer::ISrsHybridServer()
|
||||||
{
|
{
|
||||||
|
@ -430,9 +432,9 @@ srs_error_t SrsHybridServer::notify(int event, srs_utime_t interval, srs_utime_t
|
||||||
|
|
||||||
string thread_desc;
|
string thread_desc;
|
||||||
_srs_pps_thread_run->update(_st_stat_thread_run); _srs_pps_thread_idle->update(_st_stat_thread_idle);
|
_srs_pps_thread_run->update(_st_stat_thread_run); _srs_pps_thread_idle->update(_st_stat_thread_idle);
|
||||||
_srs_pps_thread_yield->update(_st_stat_thread_yield);
|
_srs_pps_thread_yield->update(_st_stat_thread_yield); _srs_pps_thread_yield2->update(_st_stat_thread_yield2);
|
||||||
if (_st_active_count > 0 || _srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s() || _srs_pps_thread_yield->r10s()) {
|
if (_st_active_count > 0 || _srs_pps_thread_run->r10s() || _srs_pps_thread_idle->r10s() || _srs_pps_thread_yield->r10s() || _srs_pps_thread_yield2->r10s()) {
|
||||||
snprintf(buf, sizeof(buf), ", co=%d,%d,%d,%d", _st_active_count, _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s(), _srs_pps_thread_yield->r10s());
|
snprintf(buf, sizeof(buf), ", co=%d,%d,%d, yield=%d,%d", _st_active_count, _srs_pps_thread_run->r10s(), _srs_pps_thread_idle->r10s(), _srs_pps_thread_yield->r10s(), _srs_pps_thread_yield2->r10s());
|
||||||
thread_desc = buf;
|
thread_desc = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue