From c143c80fd644e3a78d4e7dc19532693b4b9adb1a Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 15 Apr 2020 07:10:41 +0800 Subject: [PATCH] Fix GSO stat bug --- trunk/scripts/perf_gso.py | 12 ++++++++---- trunk/src/app/srs_app_rtc_conn.cpp | 10 ++++++++-- trunk/src/app/srs_app_statistic.cpp | 6 ++++++ trunk/src/app/srs_app_statistic.hpp | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/trunk/scripts/perf_gso.py b/trunk/scripts/perf_gso.py index 560763e4c..707e6c6b5 100755 --- a/trunk/scripts/perf_gso.py +++ b/trunk/scripts/perf_gso.py @@ -46,41 +46,45 @@ keys = ['lt_2', 'lt_3', 'lt_5', 'lt_9', 'lt_16', 'lt_32', 'lt_64', 'lt_128', 'lt print "" print("AV---Frames"), +p = obj['data']['avframes'] for k in keys: k2 = '%s'%(k) - p = obj['data']['avframes'] if k2 in p: print(p[k2]), else: print(0), +print(p['nn']), print "" print("RTC--Frames"), +p = obj['data']['rtc'] for k in keys: k2 = '%s'%(k) - p = obj['data']['rtc'] if k2 in p: print(p[k2]), else: print(0), +print(p['nn']), print "" print("RTP-Packets"), +p = obj['data']['rtp'] for k in keys: k2 = '%s'%(k) - p = obj['data']['rtp'] if k2 in p: print(p[k2]), else: print(0), +print(p['nn']), print "" print("GSO-Packets"), +p = obj['data']['gso'] for k in keys: k2 = '%s'%(k) - p = obj['data']['gso'] if k2 in p: print(p[k2]), else: print(0), +print(p['nn']), diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index 6cb23f552..a01e6305c 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -652,11 +652,17 @@ srs_error_t SrsRtcSenderThread::cycle() // Stat the original RAW AV frame, maybe h264+aac. stat->perf_on_msgs(msg_count); // Stat the RTC packets, RAW AV frame, maybe h.264+opus. - stat->perf_on_rtc_packets(srs_max(pkts.nn_audios, pkts.nn_extras) + pkts.nn_videos); + int nn_rtc_packets = srs_max(pkts.nn_audios, pkts.nn_extras) + pkts.nn_videos; + stat->perf_on_rtc_packets(nn_rtc_packets); // Stat the RAW RTP packets, which maybe group by GSO. stat->perf_on_rtp_packets(pkts.packets.size()); // Stat the RTP packets going into kernel. stat->perf_on_gso_packets(pkts.nn_rtp_pkts); +#if defined(SRS_DEBUG) + srs_trace("RTC PLAY packets, msgs %d/%d, rtp %d, gso %d, %d audios, %d extras, %d videos, %d samples, %d bytes", + msg_count, nn_rtc_packets, pkts.packets.size(), pkts.nn_rtp_pkts, pkts.nn_audios, pkts.nn_extras, pkts.nn_videos, + pkts.nn_samples, pkts.nn_bytes); +#endif pprint->elapse(); if (pprint->can_print()) { @@ -1014,7 +1020,7 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsUdpMuxSocket* skt, SrsRtcPac } #if defined(SRS_DEBUG) - srs_trace("Summary packets, rtp %d/%d, videos %d/%d, audios %d/%d", packets.packets.size(), + srs_trace("RTC PLAY summary, rtp %d/%d, videos %d/%d, audios %d/%d", packets.packets.size(), packets.nn_rtp_pkts, packets.nn_videos, packets.nn_samples, packets.nn_audios, packets.nn_extras); #endif diff --git a/trunk/src/app/srs_app_statistic.cpp b/trunk/src/app/srs_app_statistic.cpp index ccbdabfe8..01abcd446 100644 --- a/trunk/src/app/srs_app_statistic.cpp +++ b/trunk/src/app/srs_app_statistic.cpp @@ -236,6 +236,8 @@ srs_error_t SrsStatisticClient::dumps(SrsJsonObject* obj) SrsStatisticCategory::SrsStatisticCategory() { + nn = 0; + a = 0; b = 0; c = 0; @@ -685,6 +687,8 @@ void SrsStatistic::perf_on_packets(SrsStatisticCategory* p, int nb_msgs) } else { p->j++; } + + p->nn += nb_msgs; } srs_error_t SrsStatistic::dumps_perf(SrsStatisticCategory* p, SrsJsonObject* obj) @@ -715,6 +719,8 @@ srs_error_t SrsStatistic::dumps_perf(SrsStatisticCategory* p, SrsJsonObject* obj if (p->i) obj->set("lt_256", SrsJsonAny::integer(p->i)); if (p->j) obj->set("gt_256", SrsJsonAny::integer(p->j)); + obj->set("nn", SrsJsonAny::integer(p->nn)); + return err; } diff --git a/trunk/src/app/srs_app_statistic.hpp b/trunk/src/app/srs_app_statistic.hpp index 0926fce0c..0d9905f75 100644 --- a/trunk/src/app/srs_app_statistic.hpp +++ b/trunk/src/app/srs_app_statistic.hpp @@ -124,6 +124,8 @@ public: class SrsStatisticCategory { +public: + uint64_t nn; public: uint64_t a; uint64_t b;