1
This commit is contained in:
parent
a480c642bf
commit
0ed4c1f3e2
@ -59,28 +59,28 @@ static void SavePerfLog()
|
|||||||
"in_data_size:%d out_data_size:%d msgnode_size:%d read_count:%d max_login_time:%d "
|
"in_data_size:%d out_data_size:%d msgnode_size:%d read_count:%d max_login_time:%d "
|
||||||
"max_join_time:%d",
|
"max_join_time:%d",
|
||||||
{
|
{
|
||||||
App::Instance()->perf.max_run_delay_time,
|
App::Instance()->GetPerf().max_run_delay_time,
|
||||||
App::Instance()->perf.max_timer_idle,
|
App::Instance()->GetPerf().max_timer_idle,
|
||||||
App::Instance()->perf.in_data_size,
|
App::Instance()->GetPerf().in_data_size,
|
||||||
App::Instance()->perf.out_data_size,
|
App::Instance()->GetPerf().out_data_size,
|
||||||
//App::Instance()->msgnode_size_,
|
//App::Instance()->msgnode_size_,
|
||||||
App::Instance()->perf.read_count,
|
App::Instance()->GetPerf().read_count,
|
||||||
App::Instance()->perf.max_login_time,
|
App::Instance()->GetPerf().max_login_time,
|
||||||
App::Instance()->perf.max_join_time,
|
App::Instance()->GetPerf().max_join_time,
|
||||||
});
|
});
|
||||||
if (App::Instance()->HasFlag(2)) {
|
if (App::Instance()->HasFlag(2)) {
|
||||||
a8::XPrintf("mainloop_time:%d netmsg_time:%d send_node_num:%d sent_bytes_num:%d\n",
|
a8::XPrintf("mainloop_time:%d netmsg_time:%d send_node_num:%d sent_bytes_num:%d\n",
|
||||||
{
|
{
|
||||||
App::Instance()->perf.max_run_delay_time,
|
App::Instance()->GetPerf().max_run_delay_time,
|
||||||
App::Instance()->perf.max_dispatchmsg_time,
|
App::Instance()->GetPerf().max_dispatchmsg_time,
|
||||||
GCListener::Instance()->GetSendNodeNum(),
|
GCListener::Instance()->GetSendNodeNum(),
|
||||||
GCListener::Instance()->GetSentBytesNum()
|
GCListener::Instance()->GetSentBytesNum()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
App::Instance()->perf.max_run_delay_time = 0;
|
App::Instance()->GetPerf().max_run_delay_time = 0;
|
||||||
App::Instance()->perf.max_timer_idle = 0;
|
App::Instance()->GetPerf().max_timer_idle = 0;
|
||||||
App::Instance()->perf.max_login_time = 0;
|
App::Instance()->GetPerf().max_login_time = 0;
|
||||||
App::Instance()->perf.max_join_time = 0;
|
App::Instance()->GetPerf().max_join_time = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool App::Init(int argc, char* argv[])
|
bool App::Init(int argc, char* argv[])
|
||||||
@ -90,7 +90,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
this->argv_ = argv;
|
this->argv_ = argv;
|
||||||
|
|
||||||
if (!ParseOpt()) {
|
if (!ParseOpt()) {
|
||||||
terminated = true;
|
terminated_ = true;
|
||||||
if (node_id_ <= 0) {
|
if (node_id_ <= 0) {
|
||||||
a8::XPrintf("gameserver启动失败,缺少-n参数\n", {});
|
a8::XPrintf("gameserver启动失败,缺少-n参数\n", {});
|
||||||
} else if (node_id_ > MAX_NODE_ID) {
|
} else if (node_id_ > MAX_NODE_ID) {
|
||||||
@ -154,7 +154,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
[] (int event, const a8::Args* args)
|
[] (int event, const a8::Args* args)
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
App::Instance()->terminated = true;
|
App::Instance()->terminated_ = true;
|
||||||
App::Instance()->NotifyLoopCond();
|
App::Instance()->NotifyLoopCond();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ bool App::Init(int argc, char* argv[])
|
|||||||
[] (int event, const a8::Args* args)
|
[] (int event, const a8::Args* args)
|
||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
App::Instance()->shutdowned = true;
|
App::Instance()->shutdowned_ = true;
|
||||||
a8::XPrintf("shutdowned\n", {});
|
a8::XPrintf("shutdowned\n", {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,13 +207,13 @@ int App::Run()
|
|||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
f8::UdpLog::Instance()->Info("wsproxy running", {});
|
f8::UdpLog::Instance()->Info("wsproxy running", {});
|
||||||
while (!terminated) {
|
while (!terminated_) {
|
||||||
a8::tick_t begin_tick = a8::XGetTickCount();
|
a8::tick_t begin_tick = a8::XGetTickCount();
|
||||||
QuickExecute();
|
QuickExecute();
|
||||||
SlowerExecute();
|
SlowerExecute();
|
||||||
a8::tick_t end_tick = a8::XGetTickCount();
|
a8::tick_t end_tick = a8::XGetTickCount();
|
||||||
if (end_tick - begin_tick > perf.max_run_delay_time) {
|
if (end_tick - begin_tick > GetPerf().max_run_delay_time) {
|
||||||
perf.max_run_delay_time = end_tick - begin_tick;
|
GetPerf().max_run_delay_time = end_tick - begin_tick;
|
||||||
}
|
}
|
||||||
Schedule();
|
Schedule();
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ public:
|
|||||||
long long NewUuid();
|
long long NewUuid();
|
||||||
int GetNodeId() { return node_id_; }
|
int GetNodeId() { return node_id_; }
|
||||||
int GetInstanceId() { return instance_id_; }
|
int GetInstanceId() { return instance_id_; }
|
||||||
|
PerfMonitor& GetPerf() { return perf_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void QuickExecute();
|
void QuickExecute();
|
||||||
@ -62,14 +63,12 @@ private:
|
|||||||
void FreeSocketMsgQueue();
|
void FreeSocketMsgQueue();
|
||||||
void FreeUdpMsgQueue();
|
void FreeUdpMsgQueue();
|
||||||
|
|
||||||
public:
|
|
||||||
volatile bool terminated = false;
|
|
||||||
volatile bool shutdowned = false;
|
|
||||||
PerfMonitor perf;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int argc_ = 0;
|
int argc_ = 0;
|
||||||
char** argv_ = nullptr;
|
char** argv_ = nullptr;
|
||||||
|
PerfMonitor perf_;
|
||||||
|
volatile bool terminated_ = false;
|
||||||
|
volatile bool shutdowned_ = false;
|
||||||
|
|
||||||
int node_id_ = 0;
|
int node_id_ = 0;
|
||||||
int instance_id_ = 0;
|
int instance_id_ = 0;
|
||||||
|
@ -95,8 +95,8 @@ void DownStreamMgr::BindUpStream(int socket_handle, int conn_instance_id)
|
|||||||
{
|
{
|
||||||
if (auto pending_account = GetPendingAccount(socket_handle)) {
|
if (auto pending_account = GetPendingAccount(socket_handle)) {
|
||||||
long long cur_tick = a8::XGetTickCount();
|
long long cur_tick = a8::XGetTickCount();
|
||||||
if (cur_tick - pending_account->add_tick > App::Instance()->perf.max_join_time) {
|
if (cur_tick - pending_account->add_tick > App::Instance()->GetPerf().max_join_time) {
|
||||||
App::Instance()->perf.max_join_time = cur_tick - pending_account->add_tick;
|
App::Instance()->GetPerf().max_join_time = cur_tick - pending_account->add_tick;
|
||||||
}
|
}
|
||||||
f8::UdpLog::Instance()->Info("BindUpStream account_id:%s",
|
f8::UdpLog::Instance()->Info("BindUpStream account_id:%s",
|
||||||
{
|
{
|
||||||
@ -120,8 +120,8 @@ void DownStreamMgr::AddPendingAccount(const std::string& account_id, int socket_
|
|||||||
{
|
{
|
||||||
if (a8::TIMER_EXEC_EVENT == event) {
|
if (a8::TIMER_EXEC_EVENT == event) {
|
||||||
pending_account_hash_.erase(socket_handle);
|
pending_account_hash_.erase(socket_handle);
|
||||||
App::Instance()->perf.max_join_time =
|
App::Instance()->GetPerf().max_join_time =
|
||||||
std::max((long long)1000 * 10, App::Instance()->perf.max_join_time);
|
std::max((long long)1000 * 10, App::Instance()->GetPerf().max_join_time);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
&timer_attacher_
|
&timer_attacher_
|
||||||
|
@ -159,14 +159,14 @@ void MasterMgr::RequestTargetServer(f8::MsgHdr& hdr,
|
|||||||
req->socket_handle
|
req->socket_handle
|
||||||
);
|
);
|
||||||
long long req_handle_time = a8::XGetTickCount() - req->req_tick;
|
long long req_handle_time = a8::XGetTickCount() - req->req_tick;
|
||||||
if (req_handle_time > App::Instance()->perf.max_login_time) {
|
if (req_handle_time > App::Instance()->GetPerf().max_login_time) {
|
||||||
App::Instance()->perf.max_login_time = req_handle_time;
|
App::Instance()->GetPerf().max_login_time = req_handle_time;
|
||||||
}
|
}
|
||||||
DownStreamMgr::Instance()->AddPendingAccount(req->account_id, req->socket_handle, req->req_tick);
|
DownStreamMgr::Instance()->AddPendingAccount(req->account_id, req->socket_handle, req->req_tick);
|
||||||
} else if (ALLOC_TARGET_SERVER_SUCCESS_TIMER_EVENT == event) {
|
} else if (ALLOC_TARGET_SERVER_SUCCESS_TIMER_EVENT == event) {
|
||||||
long long req_handle_time = a8::XGetTickCount() - req->req_tick;
|
long long req_handle_time = a8::XGetTickCount() - req->req_tick;
|
||||||
if (req_handle_time > App::Instance()->perf.max_login_time) {
|
if (req_handle_time > App::Instance()->GetPerf().max_login_time) {
|
||||||
App::Instance()->perf.max_login_time = req_handle_time;
|
App::Instance()->GetPerf().max_login_time = req_handle_time;
|
||||||
}
|
}
|
||||||
DownStreamMgr::Instance()->AddPendingAccount(req->account_id, req->socket_handle, req->req_tick);
|
DownStreamMgr::Instance()->AddPendingAccount(req->account_id, req->socket_handle, req->req_tick);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user