From a8c6b08c0167f51ef12e984e57169bb550d0a607 Mon Sep 17 00:00:00 2001 From: xuyongfei Date: Tue, 23 Mar 2021 14:04:18 +0800 Subject: [PATCH] Serving, add master and worker async handle time cost --- mindspore_serving/ccsrc/master/dispacther.cc | 2 -- mindspore_serving/ccsrc/master/grpc/grpc_server.h | 7 ++++++- mindspore_serving/ccsrc/worker/grpc/worker_process.cc | 2 -- mindspore_serving/ccsrc/worker/grpc/worker_server.h | 6 +++++- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mindspore_serving/ccsrc/master/dispacther.cc b/mindspore_serving/ccsrc/master/dispacther.cc index 363a687..e79495c 100644 --- a/mindspore_serving/ccsrc/master/dispacther.cc +++ b/mindspore_serving/ccsrc/master/dispacther.cc @@ -80,9 +80,7 @@ void Dispatcher::DispatchAsync(const proto::PredictRequest &request, proto::Pred this->infer_num_--; }; infer_num_++; - MSI_TIME_STAMP_START(Predict) status = DispatchAsyncInner(request, reply, callback); - MSI_TIME_STAMP_END(Predict) } catch (const std::bad_alloc &ex) { MSI_LOG(ERROR) << "Serving Error: malloc memory failed"; std::cout << "Serving Error: malloc memory failed" << std::endl; diff --git a/mindspore_serving/ccsrc/master/grpc/grpc_server.h b/mindspore_serving/ccsrc/master/grpc/grpc_server.h index d49cbb1..81fdf03 100644 --- a/mindspore_serving/ccsrc/master/grpc/grpc_server.h +++ b/mindspore_serving/ccsrc/master/grpc/grpc_server.h @@ -94,7 +94,12 @@ class MasterPredictContext : public MasterServiceContext { void HandleRequest() override { EnqueueRequest(service_impl_, async_service_, cq_); state_ = STATE::FINISH; - PredictOnFinish on_finish = [this]() { responder_.Finish(response_, grpc::Status::OK, this); }; + + MSI_TIME_STAMP_START(RequestHandle) + PredictOnFinish on_finish = [this, time_start_RequestHandle]() { + responder_.Finish(response_, grpc::Status::OK, this); + MSI_TIME_STAMP_END(RequestHandle) + }; service_impl_->PredictAsync(&request_, &response_, on_finish); } diff --git a/mindspore_serving/ccsrc/worker/grpc/worker_process.cc b/mindspore_serving/ccsrc/worker/grpc/worker_process.cc index 11b6d81..a94cec8 100644 --- a/mindspore_serving/ccsrc/worker/grpc/worker_process.cc +++ b/mindspore_serving/ccsrc/worker/grpc/worker_process.cc @@ -32,9 +32,7 @@ void MSWorkerImpl::PredictAsync(grpc::ServerContext *context, const proto::Predi Status status(FAILED); MSI_LOG(INFO) << "Begin call service Eval"; try { - MSI_TIME_STAMP_START(Predict) status = Worker::GetInstance().RunAsync(*request, reply, on_finish); - MSI_TIME_STAMP_END(Predict) } catch (const std::bad_alloc &ex) { MSI_LOG(ERROR) << "Serving Error: malloc memory failed"; std::cout << "Serving Error: malloc memory failed" << std::endl; diff --git a/mindspore_serving/ccsrc/worker/grpc/worker_server.h b/mindspore_serving/ccsrc/worker/grpc/worker_server.h index dbb3f13..803c9ca 100644 --- a/mindspore_serving/ccsrc/worker/grpc/worker_server.h +++ b/mindspore_serving/ccsrc/worker/grpc/worker_server.h @@ -100,7 +100,11 @@ class WorkerPredictContext : public WorkerServiceContext { void HandleRequest() override { EnqueueRequest(service_impl_, async_service_, cq_); state_ = STATE::FINISH; - PredictOnFinish on_finish = [this]() { responder_.Finish(response_, grpc::Status::OK, this); }; + MSI_TIME_STAMP_START(WorkerRequestHandle) + PredictOnFinish on_finish = [this, time_start_WorkerRequestHandle]() { + responder_.Finish(response_, grpc::Status::OK, this); + MSI_TIME_STAMP_END(WorkerRequestHandle) + }; service_impl_->PredictAsync(&ctx_, &request_, &response_, on_finish); }