mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine stat for GSO
This commit is contained in:
parent
5b406d68d6
commit
03a03e4174
6 changed files with 31 additions and 64 deletions
|
@ -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) {
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue