mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Stat bytes
This commit is contained in:
parent
b7dab00f36
commit
5ad99b119d
5 changed files with 58 additions and 15 deletions
|
@ -1624,7 +1624,7 @@ srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage*
|
||||||
|
|
||||||
p->set("target", SrsJsonAny::str(target.c_str()));
|
p->set("target", SrsJsonAny::str(target.c_str()));
|
||||||
p->set("reset", SrsJsonAny::str(reset.c_str()));
|
p->set("reset", SrsJsonAny::str(reset.c_str()));
|
||||||
p->set("help", SrsJsonAny::str("?target=avframes|rtc|rtp|gso|writev_iovs|sendmmsg"));
|
p->set("help", SrsJsonAny::str("?target=avframes|rtc|rtp|gso|writev_iovs|sendmmsg|bytes"));
|
||||||
p->set("help2", SrsJsonAny::str("?reset=all"));
|
p->set("help2", SrsJsonAny::str("?reset=all"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1687,6 +1687,15 @@ srs_error_t SrsGoApiPerf::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (target.empty() || target == "bytes") {
|
||||||
|
SrsJsonObject* p = SrsJsonAny::object();
|
||||||
|
data->set("bytes", p);
|
||||||
|
if ((err = stat->dumps_perf_bytes(p)) != srs_success) {
|
||||||
|
int code = srs_error_code(err); srs_error_reset(err);
|
||||||
|
return srs_api_response_code(w, r, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return srs_api_response(w, r, obj->dumps());
|
return srs_api_response(w, r, obj->dumps());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -472,7 +472,7 @@ SrsRtcPackets::SrsRtcPackets()
|
||||||
nn_rtp_pkts = 0;
|
nn_rtp_pkts = 0;
|
||||||
nn_audios = nn_extras = 0;
|
nn_audios = nn_extras = 0;
|
||||||
nn_videos = nn_samples = 0;
|
nn_videos = nn_samples = 0;
|
||||||
nn_paddings = 0;
|
nn_padding_bytes = nn_paddings = 0;
|
||||||
|
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
}
|
}
|
||||||
|
@ -504,7 +504,7 @@ void SrsRtcPackets::reset(bool gso, bool merge_nalus)
|
||||||
nn_rtp_pkts = 0;
|
nn_rtp_pkts = 0;
|
||||||
nn_audios = nn_extras = 0;
|
nn_audios = nn_extras = 0;
|
||||||
nn_videos = nn_samples = 0;
|
nn_videos = nn_samples = 0;
|
||||||
nn_paddings = 0;
|
nn_padding_bytes = nn_paddings = 0;
|
||||||
|
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
}
|
}
|
||||||
|
@ -733,18 +733,20 @@ srs_error_t SrsRtcSenderThread::cycle()
|
||||||
stat->perf_on_rtp_packets(pkts.size());
|
stat->perf_on_rtp_packets(pkts.size());
|
||||||
// Stat the RTP packets going into kernel.
|
// Stat the RTP packets going into kernel.
|
||||||
stat->perf_on_gso_packets(pkts.nn_rtp_pkts);
|
stat->perf_on_gso_packets(pkts.nn_rtp_pkts);
|
||||||
|
// Stat the bytes and paddings.
|
||||||
|
stat->perf_on_rtc_bytes(pkts.nn_bytes, pkts.nn_padding_bytes);
|
||||||
#if defined(SRS_DEBUG)
|
#if defined(SRS_DEBUG)
|
||||||
srs_trace("RTC PLAY done, msgs %d/%d, rtp %d, gso %d, %d audios, %d extras, %d videos, %d samples, %d bytes",
|
srs_trace("RTC PLAY done, msgs %d/%d, rtp %d, gso %d, %d audios, %d extras, %d videos, %d samples, %d/%d bytes",
|
||||||
msg_count, nn_rtc_packets, pkts.size(), pkts.nn_rtp_pkts, pkts.nn_audios, pkts.nn_extras, pkts.nn_videos,
|
msg_count, nn_rtc_packets, pkts.size(), pkts.nn_rtp_pkts, pkts.nn_audios, pkts.nn_extras, pkts.nn_videos,
|
||||||
pkts.nn_samples, pkts.nn_bytes);
|
pkts.nn_samples, pkts.nn_bytes, pkts.nn_padding_bytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pprint->elapse();
|
pprint->elapse();
|
||||||
if (pprint->can_print()) {
|
if (pprint->can_print()) {
|
||||||
// TODO: FIXME: Print stat like frame/s, packet/s, loss_packets.
|
// TODO: FIXME: Print stat like frame/s, packet/s, loss_packets.
|
||||||
srs_trace("-> RTC PLAY %d msgs, %d/%d packets, %d audios, %d extras, %d videos, %d samples, %d bytes, %d pad",
|
srs_trace("-> RTC PLAY %d msgs, %d/%d packets, %d audios, %d extras, %d videos, %d samples, %d/%d bytes, %d pad",
|
||||||
msg_count, pkts.size(), pkts.nn_rtp_pkts, pkts.nn_audios, pkts.nn_extras, pkts.nn_videos,
|
msg_count, pkts.size(), pkts.nn_rtp_pkts, pkts.nn_audios, pkts.nn_extras, pkts.nn_videos,
|
||||||
pkts.nn_samples, pkts.nn_bytes, pkts.nn_paddings);
|
pkts.nn_samples, pkts.nn_bytes, pkts.nn_padding_bytes, pkts.nn_paddings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -965,6 +967,7 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsUdpMuxSocket* skt, SrsRtcPac
|
||||||
packet->set_padding(padding);
|
packet->set_padding(padding);
|
||||||
nn_packet += padding;
|
nn_packet += padding;
|
||||||
packets.nn_paddings++;
|
packets.nn_paddings++;
|
||||||
|
packets.nn_padding_bytes += padding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1128,8 +1131,9 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsUdpMuxSocket* skt, SrsRtcPac
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(SRS_DEBUG)
|
#if defined(SRS_DEBUG)
|
||||||
srs_trace("#%d, RTC PLAY summary, rtp %d/%d, videos %d/%d, audios %d/%d, pad %d", packets.debug_id, packets.size(),
|
srs_trace("#%d, RTC PLAY summary, rtp %d/%d, videos %d/%d, audios %d/%d, pad %d/%d", packets.debug_id, packets.size(),
|
||||||
packets.nn_rtp_pkts, packets.nn_videos, packets.nn_samples, packets.nn_audios, packets.nn_extras, packets.nn_paddings);
|
packets.nn_rtp_pkts, packets.nn_videos, packets.nn_samples, packets.nn_audios, packets.nn_extras, packets.nn_paddings,
|
||||||
|
packets.nn_padding_bytes);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
|
@ -1971,7 +1975,7 @@ srs_error_t SrsUdpMuxSender::cycle()
|
||||||
srs_warn("sendmmsg %d msgs, %d done", vlen, r0);
|
srs_warn("sendmmsg %d msgs, %d done", vlen, r0);
|
||||||
}
|
}
|
||||||
|
|
||||||
stat->perf_sendmmsg_on_packets(vlen);
|
stat->perf_on_sendmmsg_packets(vlen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,12 @@ public:
|
||||||
// Debug id.
|
// Debug id.
|
||||||
uint32_t debug_id;
|
uint32_t debug_id;
|
||||||
#endif
|
#endif
|
||||||
|
public:
|
||||||
// The total bytes of RTP packets.
|
// The total bytes of RTP packets.
|
||||||
int nn_bytes;
|
int nn_bytes;
|
||||||
|
// The total padded bytes.
|
||||||
|
int nn_padding_bytes;
|
||||||
|
public:
|
||||||
// The RTP packets send out by sendmmsg or sendmsg. Note that if many packets group to
|
// The RTP packets send out by sendmmsg or sendmsg. Note that if many packets group to
|
||||||
// one msghdr by GSO, it's only one RTP packet, because we only send once.
|
// one msghdr by GSO, it's only one RTP packet, because we only send once.
|
||||||
int nn_rtp_pkts;
|
int nn_rtp_pkts;
|
||||||
|
|
|
@ -271,6 +271,7 @@ SrsStatistic::SrsStatistic()
|
||||||
perf_gso = new SrsStatisticCategory();
|
perf_gso = new SrsStatisticCategory();
|
||||||
perf_rtp = new SrsStatisticCategory();
|
perf_rtp = new SrsStatisticCategory();
|
||||||
perf_rtc = new SrsStatisticCategory();
|
perf_rtc = new SrsStatisticCategory();
|
||||||
|
perf_bytes = new SrsStatisticCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic::~SrsStatistic()
|
SrsStatistic::~SrsStatistic()
|
||||||
|
@ -311,6 +312,7 @@ SrsStatistic::~SrsStatistic()
|
||||||
srs_freep(perf_gso);
|
srs_freep(perf_gso);
|
||||||
srs_freep(perf_rtp);
|
srs_freep(perf_rtp);
|
||||||
srs_freep(perf_rtc);
|
srs_freep(perf_rtc);
|
||||||
|
srs_freep(perf_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsStatistic* SrsStatistic::instance()
|
SrsStatistic* SrsStatistic::instance()
|
||||||
|
@ -641,7 +643,7 @@ srs_error_t SrsStatistic::dumps_perf_writev_iovs(SrsJsonObject* obj)
|
||||||
return dumps_perf(perf_iovs, obj);
|
return dumps_perf(perf_iovs, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsStatistic::perf_sendmmsg_on_packets(int nb_packets)
|
void SrsStatistic::perf_on_sendmmsg_packets(int nb_packets)
|
||||||
{
|
{
|
||||||
perf_on_packets(perf_sendmmsg, nb_packets);
|
perf_on_packets(perf_sendmmsg, nb_packets);
|
||||||
}
|
}
|
||||||
|
@ -651,6 +653,26 @@ srs_error_t SrsStatistic::dumps_perf_sendmmsg(SrsJsonObject* obj)
|
||||||
return dumps_perf(perf_sendmmsg, obj);
|
return dumps_perf(perf_sendmmsg, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsStatistic::perf_on_rtc_bytes(int nn_bytes, int nn_padding)
|
||||||
|
{
|
||||||
|
// a: RTC bytes.
|
||||||
|
// b: RTC paddings.
|
||||||
|
perf_bytes->a += nn_bytes;
|
||||||
|
perf_bytes->b += nn_padding;
|
||||||
|
|
||||||
|
perf_bytes->nn += nn_bytes + nn_padding;
|
||||||
|
}
|
||||||
|
|
||||||
|
srs_error_t SrsStatistic::dumps_perf_bytes(SrsJsonObject* obj)
|
||||||
|
{
|
||||||
|
obj->set("rtc_bytes", SrsJsonAny::integer(perf_bytes->a));
|
||||||
|
obj->set("rtc_padding", SrsJsonAny::integer(perf_bytes->b));
|
||||||
|
|
||||||
|
obj->set("nn", SrsJsonAny::integer(perf_bytes->nn));
|
||||||
|
|
||||||
|
return srs_success;
|
||||||
|
}
|
||||||
|
|
||||||
void SrsStatistic::reset_perf()
|
void SrsStatistic::reset_perf()
|
||||||
{
|
{
|
||||||
srs_freep(perf_iovs);
|
srs_freep(perf_iovs);
|
||||||
|
@ -659,6 +681,7 @@ void SrsStatistic::reset_perf()
|
||||||
srs_freep(perf_gso);
|
srs_freep(perf_gso);
|
||||||
srs_freep(perf_rtp);
|
srs_freep(perf_rtp);
|
||||||
srs_freep(perf_rtc);
|
srs_freep(perf_rtc);
|
||||||
|
srs_freep(perf_bytes);
|
||||||
|
|
||||||
perf_iovs = new SrsStatisticCategory();
|
perf_iovs = new SrsStatisticCategory();
|
||||||
perf_msgs = new SrsStatisticCategory();
|
perf_msgs = new SrsStatisticCategory();
|
||||||
|
@ -666,6 +689,7 @@ void SrsStatistic::reset_perf()
|
||||||
perf_gso = new SrsStatisticCategory();
|
perf_gso = new SrsStatisticCategory();
|
||||||
perf_rtp = new SrsStatisticCategory();
|
perf_rtp = new SrsStatisticCategory();
|
||||||
perf_rtc = new SrsStatisticCategory();
|
perf_rtc = new SrsStatisticCategory();
|
||||||
|
perf_bytes = new SrsStatisticCategory();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SrsStatistic::perf_on_packets(SrsStatisticCategory* p, int nb_msgs)
|
void SrsStatistic::perf_on_packets(SrsStatisticCategory* p, int nb_msgs)
|
||||||
|
|
|
@ -174,6 +174,7 @@ private:
|
||||||
SrsStatisticCategory* perf_gso;
|
SrsStatisticCategory* perf_gso;
|
||||||
SrsStatisticCategory* perf_rtp;
|
SrsStatisticCategory* perf_rtp;
|
||||||
SrsStatisticCategory* perf_rtc;
|
SrsStatisticCategory* perf_rtc;
|
||||||
|
SrsStatisticCategory* perf_bytes;
|
||||||
private:
|
private:
|
||||||
SrsStatistic();
|
SrsStatistic();
|
||||||
virtual ~SrsStatistic();
|
virtual ~SrsStatistic();
|
||||||
|
@ -245,13 +246,11 @@ public:
|
||||||
// Stat for packets merged written, nb_packets is the number of RTP packets.
|
// Stat for packets merged written, nb_packets is the number of RTP packets.
|
||||||
// For example, a RTC/opus packet maybe package to three RTP packets.
|
// For example, a RTC/opus packet maybe package to three RTP packets.
|
||||||
virtual void perf_on_rtp_packets(int nb_packets);
|
virtual void perf_on_rtp_packets(int nb_packets);
|
||||||
// Dumps the perf statistic data for RTP packets, for performance analysis.
|
|
||||||
virtual srs_error_t dumps_perf_rtp_packets(SrsJsonObject* obj);
|
virtual srs_error_t dumps_perf_rtp_packets(SrsJsonObject* obj);
|
||||||
public:
|
public:
|
||||||
// Stat for packets UDP GSO, nb_packets is the merged RTP packets.
|
// Stat for packets UDP GSO, nb_packets is the merged RTP packets.
|
||||||
// For example, three RTP/audio packets maybe GSO to one msghdr.
|
// For example, three RTP/audio packets maybe GSO to one msghdr.
|
||||||
virtual void perf_on_gso_packets(int nb_packets);
|
virtual void perf_on_gso_packets(int nb_packets);
|
||||||
// Dumps the perf statistic data for UDP GSO, for performance analysis.
|
|
||||||
virtual srs_error_t dumps_perf_gso(SrsJsonObject* obj);
|
virtual srs_error_t dumps_perf_gso(SrsJsonObject* obj);
|
||||||
public:
|
public:
|
||||||
// Stat for TCP writev, nb_iovs is the total number of iovec.
|
// Stat for TCP writev, nb_iovs is the total number of iovec.
|
||||||
|
@ -259,9 +258,12 @@ public:
|
||||||
virtual srs_error_t dumps_perf_writev_iovs(SrsJsonObject* obj);
|
virtual srs_error_t dumps_perf_writev_iovs(SrsJsonObject* obj);
|
||||||
public:
|
public:
|
||||||
// Stat for packets UDP sendmmsg, nb_packets is the vlen for sendmmsg.
|
// Stat for packets UDP sendmmsg, nb_packets is the vlen for sendmmsg.
|
||||||
virtual void perf_sendmmsg_on_packets(int nb_packets);
|
virtual void perf_on_sendmmsg_packets(int nb_packets);
|
||||||
// Dumps the perf statistic data for UDP sendmmsg, for performance analysis.
|
|
||||||
virtual srs_error_t dumps_perf_sendmmsg(SrsJsonObject* obj);
|
virtual srs_error_t dumps_perf_sendmmsg(SrsJsonObject* obj);
|
||||||
|
public:
|
||||||
|
// Stat for bytes, nn_bytes is the size of bytes, nb_padding is padding bytes.
|
||||||
|
virtual void perf_on_rtc_bytes(int nn_bytes, int nn_padding);
|
||||||
|
virtual srs_error_t dumps_perf_bytes(SrsJsonObject* obj);
|
||||||
public:
|
public:
|
||||||
// Reset all perf stat data.
|
// Reset all perf stat data.
|
||||||
virtual void reset_perf();
|
virtual void reset_perf();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue