fix #257, server latency is 0.1s+, the bottleneck is encoder. 2.0.71
正在显示
3 个修改的文件
包含
29 行增加
和
18 行删除
@@ -786,6 +786,10 @@ The latency between encoder and player with realtime config( | @@ -786,6 +786,10 @@ The latency between encoder and player with realtime config( | ||
786 | </tr> | 786 | </tr> |
787 | </table> | 787 | </table> |
788 | 788 | ||
789 | +We use FMLE as encoder to benchmark. The latency of server is 0.1s+, | ||
790 | +and the bottleneck is on the encoder. For more information, read | ||
791 | +[bug #257](https://github.com/winlinvip/simple-rtmp-server/issues/257#issuecomment-66864413). | ||
792 | + | ||
789 | ## Architecture | 793 | ## Architecture |
790 | 794 | ||
791 | SRS always use the most simple architecture to support complex transaction. | 795 | SRS always use the most simple architecture to support complex transaction. |
@@ -589,11 +589,12 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) | @@ -589,11 +589,12 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) | ||
589 | bool user_specified_duration_to_stop = (req->duration > 0); | 589 | bool user_specified_duration_to_stop = (req->duration > 0); |
590 | int64_t starttime = -1; | 590 | int64_t starttime = -1; |
591 | 591 | ||
592 | + // setup the realtime. | ||
593 | + realtime = _srs_config->get_realtime_enabled(req->vhost); | ||
592 | // setup the mw config. | 594 | // setup the mw config. |
593 | // when mw_sleep changed, resize the socket send buffer. | 595 | // when mw_sleep changed, resize the socket send buffer. |
594 | mw_enabled = true; | 596 | mw_enabled = true; |
595 | change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost)); | 597 | change_mw_sleep(_srs_config->get_mw_sleep_ms(req->vhost)); |
596 | - realtime = _srs_config->get_realtime_enabled(req->vhost); | ||
597 | 598 | ||
598 | while (true) { | 599 | while (true) { |
599 | // to use isolate thread to recv, can improve about 33% performance. | 600 | // to use isolate thread to recv, can improve about 33% performance. |
@@ -642,34 +643,40 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) | @@ -642,34 +643,40 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) | ||
642 | return ret; | 643 | return ret; |
643 | } | 644 | } |
644 | 645 | ||
645 | -#ifdef SRS_PERF_QUEUE_COND_WAIT | 646 | + // reportable |
647 | + if (pithy_print.can_print()) { | ||
648 | + kbps->sample(); | ||
649 | + srs_trace("-> "SRS_CONSTS_LOG_PLAY | ||
650 | + " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mw=%d", | ||
651 | + pithy_print.age(), count, | ||
652 | + kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | ||
653 | + kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), | ||
654 | + mw_sleep | ||
655 | + ); | ||
656 | + } | ||
657 | + | ||
646 | // we use wait timeout to get messages, | 658 | // we use wait timeout to get messages, |
647 | // for min latency event no message incoming, | 659 | // for min latency event no message incoming, |
648 | // so the count maybe zero. | 660 | // so the count maybe zero. |
649 | - srs_info("mw wait %dms and got %d msgs %d(%"PRId64"-%"PRId64")ms", | 661 | + if (count > 0) { |
662 | + srs_verbose("mw wait %dms and got %d msgs %d(%"PRId64"-%"PRId64")ms", | ||
650 | mw_sleep, count, | 663 | mw_sleep, count, |
651 | (count > 0? msgs.msgs[count - 1]->timestamp - msgs.msgs[0]->timestamp : 0), | 664 | (count > 0? msgs.msgs[count - 1]->timestamp - msgs.msgs[0]->timestamp : 0), |
652 | (count > 0? msgs.msgs[0]->timestamp : 0), | 665 | (count > 0? msgs.msgs[0]->timestamp : 0), |
653 | (count > 0? msgs.msgs[count - 1]->timestamp : 0)); | 666 | (count > 0? msgs.msgs[count - 1]->timestamp : 0)); |
654 | -#else | 667 | + } |
668 | + | ||
655 | if (count <= 0) { | 669 | if (count <= 0) { |
670 | +#ifndef SRS_PERF_QUEUE_COND_WAIT | ||
656 | srs_info("mw sleep %dms for no msg", mw_sleep); | 671 | srs_info("mw sleep %dms for no msg", mw_sleep); |
657 | st_usleep(mw_sleep * 1000); | 672 | st_usleep(mw_sleep * 1000); |
658 | - } | 673 | +#else |
674 | + srs_verbose("mw wait %dms and got nothing.", mw_sleep); | ||
659 | #endif | 675 | #endif |
660 | - srs_info("got %d msgs, min=%d, mw=%d", count, SRS_PERF_MW_MIN_MSGS, mw_sleep); | ||
661 | - | ||
662 | - // reportable | ||
663 | - if (pithy_print.can_print()) { | ||
664 | - kbps->sample(); | ||
665 | - srs_trace("-> "SRS_CONSTS_LOG_PLAY | ||
666 | - " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d, mw=%d", | ||
667 | - pithy_print.age(), count, | ||
668 | - kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | ||
669 | - kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m(), | ||
670 | - mw_sleep | ||
671 | - ); | 676 | + // ignore when nothing got. |
677 | + continue; | ||
672 | } | 678 | } |
679 | + srs_info("got %d msgs, min=%d, mw=%d", count, SRS_PERF_MW_MIN_MSGS, mw_sleep); | ||
673 | 680 | ||
674 | // only when user specifies the duration, | 681 | // only when user specifies the duration, |
675 | // we start to collect the durations for each message. | 682 | // we start to collect the durations for each message. |
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | // current release version | 31 | // current release version |
32 | #define VERSION_MAJOR 2 | 32 | #define VERSION_MAJOR 2 |
33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
34 | -#define VERSION_REVISION 70 | 34 | +#define VERSION_REVISION 71 |
35 | // server info. | 35 | // server info. |
36 | #define RTMP_SIG_SRS_KEY "SRS" | 36 | #define RTMP_SIG_SRS_KEY "SRS" |
37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" | 37 | #define RTMP_SIG_SRS_ROLE "origin/edge server" |
-
请 注册 或 登录 后发表评论