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);
|
data->set("query", p);
|
||||||
|
|
||||||
p->set("target", SrsJsonAny::str(target.c_str()));
|
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") {
|
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();
|
SrsJsonObject* p = SrsJsonAny::object();
|
||||||
data->set("sendmmsg", p);
|
data->set("sendmmsg", p);
|
||||||
if ((err = stat->dumps_perf_sendmmsg(p)) != srs_success) {
|
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();
|
SrsJsonObject* p = SrsJsonAny::object();
|
||||||
data->set("gso", p);
|
data->set("gso", p);
|
||||||
if ((err = stat->dumps_perf_gso(p)) != srs_success) {
|
if ((err = stat->dumps_perf_gso(p)) != srs_success) {
|
||||||
|
|
|
@ -609,6 +609,8 @@ srs_error_t SrsRtcSenderThread::cycle()
|
||||||
SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_play();
|
SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_play();
|
||||||
SrsAutoFree(SrsPithyPrint, pprint);
|
SrsAutoFree(SrsPithyPrint, pprint);
|
||||||
|
|
||||||
|
SrsStatistic* stat = SrsStatistic::instance();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
if ((err = trd->pull()) != srs_success) {
|
if ((err = trd->pull()) != srs_success) {
|
||||||
return srs_error_wrap(err, "rtc sender thread");
|
return srs_error_wrap(err, "rtc sender thread");
|
||||||
|
@ -647,6 +649,8 @@ srs_error_t SrsRtcSenderThread::cycle()
|
||||||
srs_freep(msg);
|
srs_freep(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stat->perf_mw_on_msgs(msg_count, pkts.nn_bytes, pkts.nn_rtp_pkts);
|
||||||
|
|
||||||
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.
|
||||||
|
|
|
@ -265,7 +265,6 @@ SrsStatistic::SrsStatistic()
|
||||||
|
|
||||||
perf_iovs = new SrsStatisticCategory();
|
perf_iovs = new SrsStatisticCategory();
|
||||||
perf_msgs = new SrsStatisticCategory();
|
perf_msgs = new SrsStatisticCategory();
|
||||||
perf_sys = new SrsStatisticCategory();
|
|
||||||
perf_sendmmsg = new SrsStatisticCategory();
|
perf_sendmmsg = new SrsStatisticCategory();
|
||||||
perf_gso = new SrsStatisticCategory();
|
perf_gso = new SrsStatisticCategory();
|
||||||
}
|
}
|
||||||
|
@ -304,7 +303,6 @@ SrsStatistic::~SrsStatistic()
|
||||||
|
|
||||||
srs_freep(perf_iovs);
|
srs_freep(perf_iovs);
|
||||||
srs_freep(perf_msgs);
|
srs_freep(perf_msgs);
|
||||||
srs_freep(perf_sys);
|
|
||||||
srs_freep(perf_sendmmsg);
|
srs_freep(perf_sendmmsg);
|
||||||
srs_freep(perf_gso);
|
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.
|
// For perf msgs, the nb_msgs stat.
|
||||||
// a: =1
|
// a: =1
|
||||||
// b: <10
|
// b: <3
|
||||||
// c: <100
|
// c: <6
|
||||||
// d: <200
|
// d: <12
|
||||||
// e: <300
|
// e: <128
|
||||||
// f: <400
|
// f: <256
|
||||||
// g: <500
|
// g: <512
|
||||||
// h: <600
|
// h: <600
|
||||||
// i: <1000
|
// i: <1000
|
||||||
// j: >=1000
|
// j: >=1000
|
||||||
if (nb_msgs == 1) {
|
if (nb_msgs == 1) {
|
||||||
perf_msgs->a++;
|
perf_msgs->a++;
|
||||||
} else if (nb_msgs < 10) {
|
} else if (nb_msgs < 3) {
|
||||||
perf_msgs->b++;
|
perf_msgs->b++;
|
||||||
} else if (nb_msgs < 100) {
|
} else if (nb_msgs < 6) {
|
||||||
perf_msgs->c++;
|
perf_msgs->c++;
|
||||||
} else if (nb_msgs < 200) {
|
} else if (nb_msgs < 12) {
|
||||||
perf_msgs->d++;
|
perf_msgs->d++;
|
||||||
} else if (nb_msgs < 300) {
|
} else if (nb_msgs < 128) {
|
||||||
perf_msgs->e++;
|
perf_msgs->e++;
|
||||||
} else if (nb_msgs < 400) {
|
} else if (nb_msgs < 256) {
|
||||||
perf_msgs->f++;
|
perf_msgs->f++;
|
||||||
} else if (nb_msgs < 500) {
|
} else if (nb_msgs < 512) {
|
||||||
perf_msgs->g++;
|
perf_msgs->g++;
|
||||||
} else if (nb_msgs < 600) {
|
} else if (nb_msgs < 600) {
|
||||||
perf_msgs->h++;
|
perf_msgs->h++;
|
||||||
|
@ -654,18 +652,6 @@ void SrsStatistic::perf_mw_on_msgs(int nb_msgs, int bytes_msgs, int nb_iovs)
|
||||||
} else {
|
} else {
|
||||||
perf_iovs->j++;
|
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)
|
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.
|
// For perf msgs, the nb_msgs stat.
|
||||||
// a: =1
|
// a: =1
|
||||||
// b: <10
|
// b: <3
|
||||||
// c: <100
|
// c: <6
|
||||||
// d: <200
|
// d: <12
|
||||||
// e: <300
|
// e: <128
|
||||||
// f: <400
|
// f: <256
|
||||||
// g: <500
|
// g: <512
|
||||||
// h: <600
|
// h: <600
|
||||||
// i: <1000
|
// i: <1000
|
||||||
// j: >=1000
|
// j: >=1000
|
||||||
p->set("lt_2", SrsJsonAny::integer(perf_msgs->a));
|
p->set("lt_2", SrsJsonAny::integer(perf_msgs->a));
|
||||||
p->set("lt_10", SrsJsonAny::integer(perf_msgs->b));
|
p->set("lt_3", SrsJsonAny::integer(perf_msgs->b));
|
||||||
p->set("lt_100", SrsJsonAny::integer(perf_msgs->c));
|
p->set("lt_6", SrsJsonAny::integer(perf_msgs->c));
|
||||||
p->set("lt_200", SrsJsonAny::integer(perf_msgs->d));
|
p->set("lt_12", SrsJsonAny::integer(perf_msgs->d));
|
||||||
p->set("lt_300", SrsJsonAny::integer(perf_msgs->e));
|
p->set("lt_128", SrsJsonAny::integer(perf_msgs->e));
|
||||||
p->set("lt_400", SrsJsonAny::integer(perf_msgs->f));
|
p->set("lt_256", SrsJsonAny::integer(perf_msgs->f));
|
||||||
p->set("lt_500", SrsJsonAny::integer(perf_msgs->g));
|
p->set("lt_512", SrsJsonAny::integer(perf_msgs->g));
|
||||||
p->set("lt_600", SrsJsonAny::integer(perf_msgs->h));
|
p->set("lt_600", SrsJsonAny::integer(perf_msgs->h));
|
||||||
p->set("lt_1000", SrsJsonAny::integer(perf_msgs->i));
|
p->set("lt_1000", SrsJsonAny::integer(perf_msgs->i));
|
||||||
p->set("gt_1000", SrsJsonAny::integer(perf_msgs->j));
|
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));
|
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;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -168,7 +168,6 @@ private:
|
||||||
// The perf stat for mw(merged write).
|
// The perf stat for mw(merged write).
|
||||||
SrsStatisticCategory* perf_iovs;
|
SrsStatisticCategory* perf_iovs;
|
||||||
SrsStatisticCategory* perf_msgs;
|
SrsStatisticCategory* perf_msgs;
|
||||||
SrsStatisticCategory* perf_sys;
|
|
||||||
SrsStatisticCategory* perf_sendmmsg;
|
SrsStatisticCategory* perf_sendmmsg;
|
||||||
SrsStatisticCategory* perf_gso;
|
SrsStatisticCategory* perf_gso;
|
||||||
private:
|
private:
|
||||||
|
@ -232,9 +231,6 @@ public:
|
||||||
// Stat for packets merged written, nb_msgs is the number of RTMP messages,
|
// 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.
|
// 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);
|
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.
|
// Dumps the perf statistic data for TCP writev, for performance analysis.
|
||||||
virtual srs_error_t dumps_perf_writev(SrsJsonObject* obj);
|
virtual srs_error_t dumps_perf_writev(SrsJsonObject* obj);
|
||||||
public:
|
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) {
|
if ((er = skt->writev(iovs, 2, NULL)) != srs_success) {
|
||||||
return srs_error_wrap(err, "writev");
|
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,
|
// 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.
|
// 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;
|
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,
|
// The protocol provides the rtmp-message-protocol services,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue