From f82cb635cf0c8554d6e0ca0502e76c4f89ea23f5 Mon Sep 17 00:00:00 2001 From: qiaolongfei Date: Fri, 27 Apr 2018 17:57:20 +0800 Subject: [PATCH] optimize code, add more log --- paddle/fluid/operators/detail/grpc_server.cc | 2 +- paddle/fluid/operators/listen_and_serv_op.cc | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/operators/detail/grpc_server.cc b/paddle/fluid/operators/detail/grpc_server.cc index 95f4738b4f..25c6bb9ee2 100644 --- a/paddle/fluid/operators/detail/grpc_server.cc +++ b/paddle/fluid/operators/detail/grpc_server.cc @@ -336,9 +336,9 @@ void AsyncGRPCServer::HandleRequest(::grpc::ServerCompletionQueue* cq, switch (base->Status()) { case PROCESS: { - VLOG(4) << cq_name << " PROCESS status:" << base->Status(); TryToRegisterNewOne(); base->Process(); + VLOG(4) << cq_name << " PROCESS status:" << base->Status(); break; } case FINISH: { diff --git a/paddle/fluid/operators/listen_and_serv_op.cc b/paddle/fluid/operators/listen_and_serv_op.cc index 88b07d865f..36bd1d3993 100644 --- a/paddle/fluid/operators/listen_and_serv_op.cc +++ b/paddle/fluid/operators/listen_and_serv_op.cc @@ -188,9 +188,11 @@ void ListenAndServOp::RunSyncLoop(framework::Executor *executor, } static void AsyncUpdateThread( - const bool &exit_flag, const std::shared_ptr &queue, + const std::string &var_name, const bool &exit_flag, + const std::shared_ptr &queue, framework::Executor *executor, framework::ExecutorPrepareContext *prepared) { + VLOG(3) << "update thread for " << var_name << " started"; while (!exit_flag) { const detail::ReceivedMessage v = queue->Pop(); auto recv_var_name = v.first; @@ -206,6 +208,7 @@ static void AsyncUpdateThread( LOG(ERROR) << "run sub program error " << e.what(); } } + VLOG(3) << "update thread for " << var_name << " ended"; } void ListenAndServOp::RunAsyncLoop(framework::Executor *executor, @@ -246,7 +249,6 @@ void ListenAndServOp::RunAsyncLoop(framework::Executor *executor, grad_to_prepared_ctx[id_to_grad[block_list[i]]] = optimize_prepared[i]; } - VLOG(3) << "RunAsyncLoop into while"; bool exit_flag = false; VLOG(3) << "start async optimize threads"; @@ -255,11 +257,12 @@ void ListenAndServOp::RunAsyncLoop(framework::Executor *executor, std::string grad_name = iter->first; fs.push_back(framework::Async([grad_name, &exit_flag, &executor, &grad_to_queue, &grad_to_prepared_ctx]() { - AsyncUpdateThread(exit_flag, grad_to_queue[grad_name], executor, - grad_to_prepared_ctx[grad_name].get()); + AsyncUpdateThread(grad_name, exit_flag, grad_to_queue[grad_name], + executor, grad_to_prepared_ctx[grad_name].get()); })); } + VLOG(3) << "RunAsyncLoop into while"; while (!exit_flag) { const detail::ReceivedMessage v = rpc_service_->Get(); auto recv_var_name = v.first; -- GitLab