From 03a03e41748d7495d01ca1286626ab7b97b5856c Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 14 Apr 2020 13:47:23 +0800 Subject: [PATCH] Refine stat for GSO --- trunk/src/app/srs_app_http_api.cpp | 6 +-- trunk/src/app/srs_app_rtc_conn.cpp | 4 ++ trunk/src/app/srs_app_statistic.cpp | 73 +++++++++------------------ trunk/src/app/srs_app_statistic.hpp | 4 -- trunk/src/protocol/srs_rtmp_stack.cpp | 5 -- trunk/src/protocol/srs_rtmp_stack.hpp | 3 -- 6 files changed, 31 insertions(+), 64 deletions(-) diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 6d7df56fa..fd4e9b2bb 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1622,7 +1622,7 @@ srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* data->set("query", p); p->set("target", SrsJsonAny::str(target.c_str())); - p->set("help", SrsJsonAny::str("?target=writev|sendmmsg|gso|udp")); + p->set("help", SrsJsonAny::str("?target=writev|sendmmsg|gso")); } if (target.empty() || target == "writev") { @@ -1634,7 +1634,7 @@ srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* } } - if (target.empty() || target == "sendmmsg" || target == "udp") { + if (target.empty() || target == "sendmmsg") { SrsJsonObject* p = SrsJsonAny::object(); data->set("sendmmsg", p); if ((err = stat->dumps_perf_sendmmsg(p)) != srs_success) { @@ -1643,7 +1643,7 @@ srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* } } - if (target.empty() || target == "gso" || target == "udp") { + if (target.empty() || target == "gso") { SrsJsonObject* p = SrsJsonAny::object(); data->set("gso", p); if ((err = stat->dumps_perf_gso(p)) != srs_success) { diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 863bdb95d..f70cf279d 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -609,6 +609,8 @@ srs_error_t SrsRtcSenderThread::cycle() SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_play(); SrsAutoFree(SrsPithyPrint, pprint); + SrsStatistic* stat = SrsStatistic::instance(); + while (true) { if ((err = trd->pull()) != srs_success) { return srs_error_wrap(err, "rtc sender thread"); @@ -647,6 +649,8 @@ srs_error_t SrsRtcSenderThread::cycle() srs_freep(msg); } + stat->perf_mw_on_msgs(msg_count, pkts.nn_bytes, pkts.nn_rtp_pkts); + pprint->elapse(); if (pprint->can_print()) { // TODO: FIXME: Print stat like frame/s, packet/s, loss_packets. diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index 2e33b7cb6..228fa8344 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -265,7 +265,6 @@ SrsStatistic::SrsStatistic() perf_iovs = new SrsStatisticCategory(); perf_msgs = new SrsStatisticCategory(); - perf_sys = new SrsStatisticCategory(); perf_sendmmsg = new SrsStatisticCategory(); perf_gso = new SrsStatisticCategory(); } @@ -304,7 +303,6 @@ SrsStatistic::~SrsStatistic() srs_freep(perf_iovs); srs_freep(perf_msgs); - srs_freep(perf_sys); srs_freep(perf_sendmmsg); srs_freep(perf_gso); } @@ -591,28 +589,28 @@ void SrsStatistic::perf_mw_on_msgs(int nb_msgs, int bytes_msgs, int nb_iovs) { // For perf msgs, the nb_msgs stat. // a: =1 - // b: <10 - // c: <100 - // d: <200 - // e: <300 - // f: <400 - // g: <500 + // b: <3 + // c: <6 + // d: <12 + // e: <128 + // f: <256 + // g: <512 // h: <600 // i: <1000 // j: >=1000 if (nb_msgs == 1) { perf_msgs->a++; - } else if (nb_msgs < 10) { + } else if (nb_msgs < 3) { perf_msgs->b++; - } else if (nb_msgs < 100) { + } else if (nb_msgs < 6) { perf_msgs->c++; - } else if (nb_msgs < 200) { + } else if (nb_msgs < 12) { perf_msgs->d++; - } else if (nb_msgs < 300) { + } else if (nb_msgs < 128) { perf_msgs->e++; - } else if (nb_msgs < 400) { + } else if (nb_msgs < 256) { perf_msgs->f++; - } else if (nb_msgs < 500) { + } else if (nb_msgs < 512) { perf_msgs->g++; } else if (nb_msgs < 600) { perf_msgs->h++; @@ -654,18 +652,6 @@ void SrsStatistic::perf_mw_on_msgs(int nb_msgs, int bytes_msgs, int nb_iovs) } else { perf_iovs->j++; } - - // Stat the syscalls. - // a: number of syscalls of msgs. - perf_sys->a++; -} - -void SrsStatistic::perf_mw_on_packets(int nb_pkts, int bytes_pkts, int nb_iovs) -{ - // Stat the syscalls. - // a: number of syscalls of msgs. - // b: number of syscalls of pkts. - perf_sys->b++; } srs_error_t SrsStatistic::dumps_perf_writev(SrsJsonObject* obj) @@ -678,22 +664,22 @@ srs_error_t SrsStatistic::dumps_perf_writev(SrsJsonObject* obj) // For perf msgs, the nb_msgs stat. // a: =1 - // b: <10 - // c: <100 - // d: <200 - // e: <300 - // f: <400 - // g: <500 + // b: <3 + // c: <6 + // d: <12 + // e: <128 + // f: <256 + // g: <512 // h: <600 // i: <1000 // j: >=1000 p->set("lt_2", SrsJsonAny::integer(perf_msgs->a)); - p->set("lt_10", SrsJsonAny::integer(perf_msgs->b)); - p->set("lt_100", SrsJsonAny::integer(perf_msgs->c)); - p->set("lt_200", SrsJsonAny::integer(perf_msgs->d)); - p->set("lt_300", SrsJsonAny::integer(perf_msgs->e)); - p->set("lt_400", SrsJsonAny::integer(perf_msgs->f)); - p->set("lt_500", SrsJsonAny::integer(perf_msgs->g)); + p->set("lt_3", SrsJsonAny::integer(perf_msgs->b)); + p->set("lt_6", SrsJsonAny::integer(perf_msgs->c)); + p->set("lt_12", SrsJsonAny::integer(perf_msgs->d)); + p->set("lt_128", SrsJsonAny::integer(perf_msgs->e)); + p->set("lt_256", SrsJsonAny::integer(perf_msgs->f)); + p->set("lt_512", SrsJsonAny::integer(perf_msgs->g)); p->set("lt_600", SrsJsonAny::integer(perf_msgs->h)); p->set("lt_1000", SrsJsonAny::integer(perf_msgs->i)); p->set("gt_1000", SrsJsonAny::integer(perf_msgs->j)); @@ -726,17 +712,6 @@ srs_error_t SrsStatistic::dumps_perf_writev(SrsJsonObject* obj) p->set("gt_1024", SrsJsonAny::integer(perf_iovs->j)); } - if (true) { - SrsJsonObject* p = SrsJsonAny::object(); - obj->set("sys", p); - - // Stat the syscalls. - // a: number of syscalls of msgs. - // b: number of syscalls of pkts. - p->set("msgs", SrsJsonAny::integer(perf_sys->a)); - p->set("pkts", SrsJsonAny::integer(perf_sys->b)); - } - return err; } diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 553bc9650..ae73f49de 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -168,7 +168,6 @@ private: // The perf stat for mw(merged write). SrsStatisticCategory* perf_iovs; SrsStatisticCategory* perf_msgs; - SrsStatisticCategory* perf_sys; SrsStatisticCategory* perf_sendmmsg; SrsStatisticCategory* perf_gso; private: @@ -232,9 +231,6 @@ public: // Stat for packets merged written, nb_msgs is the number of RTMP messages, // bytes_msgs is the total bytes of RTMP messages, nb_iovs is the total number of iovec. virtual void perf_mw_on_msgs(int nb_msgs, int bytes_msgs, int nb_iovs); - // Stat for packets merged written, nb_pkts is the number of or chunk packets, - // bytes_pkts is the total bytes of or chunk packets, nb_iovs is the total number of iovec. - virtual void perf_mw_on_packets(int nb_pkts, int bytes_pkts, int nb_iovs); // Dumps the perf statistic data for TCP writev, for performance analysis. virtual srs_error_t dumps_perf_writev(SrsJsonObject* obj); public: diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index 6c0889d3f..835746805 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -627,11 +627,6 @@ srs_error_t SrsProtocol::do_send_messages(SrsSharedPtrMessage** msgs, int nb_msg if ((er = skt->writev(iovs, 2, NULL)) != srs_success) { return srs_error_wrap(err, "writev"); } - - // Notify about perf stat. - if (perf) { - perf->perf_mw_on_packets(1, payload_size, 2); - } } } diff --git a/trunk/src/protocol/srs_rtmp_stack.hpp b/trunk/src/protocol/srs_rtmp_stack.hpp index 470347cac..eea0c5a50 100644 --- a/trunk/src/protocol/srs_rtmp_stack.hpp +++ b/trunk/src/protocol/srs_rtmp_stack.hpp @@ -157,9 +157,6 @@ public: // Stat for packets merged written, nb_msgs is the number of RTMP messages, // bytes_msgs is the total bytes of RTMP messages, nb_iovs is the total number of iovec. virtual void perf_mw_on_msgs(int nb_msgs, int bytes_msgs, int nb_iovs) = 0; - // Stat for packets merged written, nb_pkts is the number of or chunk packets, - // bytes_pkts is the total bytes of or chunk packets, nb_iovs is the total number of iovec. - virtual void perf_mw_on_packets(int nb_pkts, int bytes_pkts, int nb_iovs) = 0; }; // The protocol provides the rtmp-message-protocol services,