Refactor pithy print logs

pull/1753/head
winlin 5 years ago
parent d5b3cf9af7
commit 37e2f8896c

@ -40,6 +40,7 @@ using namespace std;
#include <srs_kernel_error.hpp> #include <srs_kernel_error.hpp>
#include <srs_app_server.hpp> #include <srs_app_server.hpp>
#include <srs_app_utility.hpp> #include <srs_app_utility.hpp>
#include <srs_kernel_utility.hpp>
// set the max packet size. // set the max packet size.
#define SRS_UDP_MAX_PACKET_SIZE 65535 #define SRS_UDP_MAX_PACKET_SIZE 65535
@ -435,7 +436,11 @@ srs_error_t SrsUdpMuxListener::cycle()
SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_recv(); SrsPithyPrint* pprint = SrsPithyPrint::create_rtc_recv();
SrsAutoFree(SrsPithyPrint, pprint); SrsAutoFree(SrsPithyPrint, pprint);
uint64_t nn_msgs = 0;
uint64_t nn_msgs_stage = 0;
uint64_t nn_msgs_last = 0;
uint64_t nn_loop = 0; uint64_t nn_loop = 0;
srs_utime_t time_last = srs_get_system_time();
while (true) { while (true) {
if ((err = trd->pull()) != srs_success) { if ((err = trd->pull()) != srs_success) {
@ -453,7 +458,10 @@ srs_error_t SrsUdpMuxListener::cycle()
} }
// remux udp never return // remux udp never return
continue; continue;
} }
nn_msgs++;
nn_msgs_stage++;
if ((err = handler->on_udp_packet(&skt)) != srs_success) { if ((err = handler->on_udp_packet(&skt)) != srs_success) {
// remux udp never return // remux udp never return
@ -463,8 +471,27 @@ srs_error_t SrsUdpMuxListener::cycle()
pprint->elapse(); pprint->elapse();
if (pprint->can_print()) { if (pprint->can_print()) {
srs_trace("-> RTC #%d RECV schedule %" PRId64, srs_netfd_fileno(lfd), nn_loop); int pps_average = 0; int pps_last = 0;
nn_loop = 0; if (true) {
if (srs_get_system_time() > srs_get_system_startup_time()) {
pps_average = (int)(nn_msgs * SRS_UTIME_SECONDS / (srs_get_system_time() - srs_get_system_startup_time()));
}
if (srs_get_system_time() > time_last) {
pps_last = (int)((nn_msgs - nn_msgs_last) * SRS_UTIME_SECONDS / (srs_get_system_time() - time_last));
}
}
string pps_unit = "";
if (pps_last > 10000 || pps_average > 10000) {
pps_unit = "(w)"; pps_last /= 10000; pps_average /= 10000;
} else if (pps_last > 1000 || pps_average > 1000) {
pps_unit = "(k)"; pps_last /= 10000; pps_average /= 10000;
}
srs_trace("-> RTC #%d RECV %" PRId64 ", pps %d/%d%s, schedule %" PRId64,
srs_netfd_fileno(lfd), nn_msgs_stage, pps_average, pps_last, pps_unit.c_str(), nn_loop);
nn_msgs_last = nn_msgs; time_last = srs_get_system_time();
nn_loop = 0; nn_msgs_stage = 0;
} }
if (SrsUdpPacketRecvCycleInterval > 0) { if (SrsUdpPacketRecvCycleInterval > 0) {

@ -1729,8 +1729,15 @@ srs_error_t SrsRtcServer::cycle()
} }
} }
srs_trace("-> RTC #%d SEND %d by sendmmsg %d, pps %d/%d, sessions %d, schedule %" PRId64 "/%" PRId64 "/%"PRId64, string pps_unit = "";
srs_netfd_fileno(stfd), pos, max_sendmmsg, pps_average, pps_last, (int)map_username_session.size(), nn_loop, nn_wait, nn_msgs_max); if (pps_last > 10000 || pps_average > 10000) {
pps_unit = "(w)"; pps_last /= 10000; pps_average /= 10000;
} else if (pps_last > 1000 || pps_average > 1000) {
pps_unit = "(k)"; pps_last /= 10000; pps_average /= 10000;
}
srs_trace("-> RTC #%d SEND %d, pps %d/%d%s, schedule %" PRId64 "/%" PRId64 "/%" PRId64 ", sessions %d by sendmmsg %d",
srs_netfd_fileno(stfd), pos, pps_average, pps_last, pps_unit.c_str(), nn_loop, nn_wait, nn_msgs_max, (int)map_username_session.size(), max_sendmmsg);
nn_msgs_last = nn_msgs; time_last = srs_get_system_time(); nn_msgs_last = nn_msgs; time_last = srs_get_system_time();
nn_loop = nn_wait = nn_msgs_max = 0; nn_loop = nn_wait = nn_msgs_max = 0;
} }

Loading…
Cancel
Save