|
|
|
@ -20,42 +20,10 @@
|
|
|
|
|
#include "paddle/fluid/operators/distributed/rpc_server.h"
|
|
|
|
|
#include "paddle/fluid/platform/profiler.h"
|
|
|
|
|
|
|
|
|
|
DEFINE_int32(rpc_server_profile_period, 0,
|
|
|
|
|
"the period of listen_and_serv to do profile");
|
|
|
|
|
DEFINE_string(rpc_server_profile_path, "/dev/null",
|
|
|
|
|
"the profile log file path");
|
|
|
|
|
|
|
|
|
|
namespace paddle {
|
|
|
|
|
namespace operators {
|
|
|
|
|
namespace distributed {
|
|
|
|
|
|
|
|
|
|
RPCServerProfiler::RPCServerProfiler(int profile_period,
|
|
|
|
|
const std::string& profile_log_path)
|
|
|
|
|
: profile_period_(profile_period), profile_log_path_(profile_log_path) {
|
|
|
|
|
step_ = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCServerProfiler::OneStep() {
|
|
|
|
|
PADDLE_ENFORCE_LE(step_, profile_period_,
|
|
|
|
|
"step_ should not be larger then "
|
|
|
|
|
"profile_period_");
|
|
|
|
|
if (profile_period_ <= 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (step_ == 0) {
|
|
|
|
|
auto pf_state = paddle::platform::ProfilerState::kCPU;
|
|
|
|
|
paddle::platform::EnableProfiler(pf_state);
|
|
|
|
|
}
|
|
|
|
|
if (step_ == profile_period_) {
|
|
|
|
|
paddle::platform::DisableProfiler(paddle::platform::EventSortingKey::kTotal,
|
|
|
|
|
profile_log_path_);
|
|
|
|
|
step_ = 0;
|
|
|
|
|
} else {
|
|
|
|
|
step_++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RPCServer::ShutDown() {
|
|
|
|
|
LOG(INFO) << "RPCServer ShutDown ";
|
|
|
|
|
ShutDownImpl();
|
|
|
|
|