完善性能监控
This commit is contained in:
parent
38ba6b5876
commit
154536a37d
@ -20,6 +20,7 @@
|
||||
#include "GGListener.h"
|
||||
#include "IMListener.h"
|
||||
#include "cachemgr.h"
|
||||
#include "perfmonitor.h"
|
||||
|
||||
#include "ss_msgid.pb.h"
|
||||
#include "ss_proto.pb.h"
|
||||
@ -50,16 +51,6 @@ struct IMMsgNode
|
||||
const char* const PROJ_LOG_ROOT_FMT = "/data/logs/%s/logs";
|
||||
const char* const PROJ_LOG_FILENAME_FMT = "log_$pid_%Y%m%d.log";
|
||||
|
||||
static void SavePerfLog()
|
||||
{
|
||||
a8::UdpLog::Instance()->Info("max_mainloop_rundelay:%d",
|
||||
{
|
||||
App::Instance()->perf.max_run_delay_time,
|
||||
});
|
||||
App::Instance()->perf.max_run_delay_time = 0;
|
||||
App::Instance()->perf.max_timer_idle = 0;
|
||||
}
|
||||
|
||||
void App::Init(int argc, char* argv[])
|
||||
{
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
@ -86,6 +77,7 @@ void App::Init(int argc, char* argv[])
|
||||
InitLog();
|
||||
HandlerMgr::Instance()->Init();
|
||||
a8::Timer::Instance()->Init();
|
||||
PerfMonitor::Instance()->Init();
|
||||
f8::MsgQueue::Instance()->Init();
|
||||
f8::TGLog::Instance()->Init(a8::Format(PROJ_NAME_FMT, {}), false);
|
||||
JsonDataMgr::Instance()->Init();
|
||||
@ -97,18 +89,6 @@ void App::Init(int argc, char* argv[])
|
||||
CacheMgr::Instance()->Init();
|
||||
|
||||
a8::UdpLog::Instance()->Info("masterserver starting instance_id:%d pid:%d", {instance_id, getpid()});
|
||||
{
|
||||
int perf_log_time = 1000 * 60 * 5;
|
||||
if (getenv("is_dev_env")) {
|
||||
perf_log_time = 1000 * 10;
|
||||
}
|
||||
a8::Timer::Instance()->AddRepeatTimer(perf_log_time,
|
||||
a8::XParams(),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
SavePerfLog();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void App::UnInit()
|
||||
@ -123,6 +103,7 @@ void App::UnInit()
|
||||
GGListener::Instance()->UnInit();
|
||||
JsonDataMgr::Instance()->UnInit();
|
||||
f8::MsgQueue::Instance()->UnInit();
|
||||
PerfMonitor::Instance()->UnInit();
|
||||
a8::Timer::Instance()->UnInit();
|
||||
HandlerMgr::Instance()->UnInit();
|
||||
f8::TGLog::Instance()->UnInit();
|
||||
@ -150,8 +131,8 @@ int App::Run()
|
||||
SlowerExecute(delta_time);
|
||||
Schedule();
|
||||
a8::tick_t end_tick = a8::XGetTickCount();
|
||||
if (end_tick - begin_tick > perf.max_run_delay_time) {
|
||||
perf.max_run_delay_time = end_tick - begin_tick;
|
||||
if (end_tick - begin_tick > PerfMonitor::Instance()->max_run_delay_time) {
|
||||
PerfMonitor::Instance()->max_run_delay_time = end_tick - begin_tick;
|
||||
}
|
||||
delta_time = end_tick - begin_tick;
|
||||
}
|
||||
|
@ -54,7 +54,6 @@ public:
|
||||
int argc = 0;
|
||||
char** argv = nullptr;
|
||||
volatile bool terminated = false;
|
||||
PerfMonitor perf;
|
||||
a8::uuid::SnowFlake uuid;
|
||||
|
||||
public:
|
||||
|
@ -9,14 +9,15 @@
|
||||
#include "svrmgr.h"
|
||||
#include "imsmgr.h"
|
||||
#include "cachemgr.h"
|
||||
#include "perfmonitor.h"
|
||||
|
||||
static void _GMOpsSelfChecking(f8::JsonHttpRequest* request)
|
||||
{
|
||||
request->resp_xobj->SetVal("errcode", 0);
|
||||
request->resp_xobj->SetVal("errmsg", "");
|
||||
request->resp_xobj->SetVal("healthy", 1);
|
||||
request->resp_xobj->SetVal("max_rundelay", App::Instance()->perf.max_run_delay_time);
|
||||
request->resp_xobj->SetVal("max_timer_idle", App::Instance()->perf.max_timer_idle);
|
||||
request->resp_xobj->SetVal("max_rundelay", PerfMonitor::Instance()->max_run_delay_time);
|
||||
request->resp_xobj->SetVal("max_timer_idle", PerfMonitor::Instance()->max_timer_idle);
|
||||
}
|
||||
|
||||
static void _GMOpsReload(f8::JsonHttpRequest* request)
|
||||
|
@ -38,7 +38,6 @@ static void SavePerfLog()
|
||||
});
|
||||
PerfMonitor::Instance()->max_run_delay_time = 0;
|
||||
PerfMonitor::Instance()->max_timer_idle = 0;
|
||||
PerfMonitor::Instance()->max_login_time = 0;
|
||||
}
|
||||
|
||||
void PerfMonitor::Init()
|
||||
|
@ -8,6 +8,7 @@ class PerfMonitor : public a8::Singleton<PerfMonitor>
|
||||
|
||||
public:
|
||||
int max_run_delay_time = 0;
|
||||
int max_timer_idle = 0;
|
||||
int max_dispatchmsg_time = 0;
|
||||
long long out_data_size = 0;
|
||||
long long in_data_size = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user