From 9ffbd0ca4dde4c93b81e3178186653ba2cf475d9 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 15 Apr 2015 01:02:50 -0700 Subject: [PATCH] Mark proto ser/deser on server side --- src/cpp/server/async_server_context.cc | 4 ++++ src/cpp/server/server.cc | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/cpp/server/async_server_context.cc b/src/cpp/server/async_server_context.cc index 628822a3387..0162ddc97db 100644 --- a/src/cpp/server/async_server_context.cc +++ b/src/cpp/server/async_server_context.cc @@ -68,9 +68,11 @@ bool AsyncServerContext::StartRead(grpc::protobuf::Message* request) { bool AsyncServerContext::StartWrite(const grpc::protobuf::Message& response, int flags) { grpc_byte_buffer* buffer = nullptr; + GRPC_TIMER_MARK(SER_PROTO_BEGIN, call_->call()); if (!SerializeProto(response, &buffer)) { return false; } + GRPC_TIMER_MARK(SER_PROTO_END, call_->call()); grpc_call_error err = grpc_call_start_write_old(call_, buffer, this, flags); grpc_byte_buffer_destroy(buffer); return err == GRPC_CALL_OK; @@ -87,7 +89,9 @@ bool AsyncServerContext::StartWriteStatus(const Status& status) { bool AsyncServerContext::ParseRead(grpc_byte_buffer* read_buffer) { GPR_ASSERT(request_); + GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_->call()); bool success = DeserializeProto(read_buffer, request_); + GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_->call()); request_ = nullptr; return success; } diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index 046133c5eb1..b3cd1fdd74b 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -46,6 +46,7 @@ #include #include +#include "src/core/profiling/timers.h" #include "src/cpp/proto/proto_utils.h" #include "src/cpp/util/time.h" @@ -123,10 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { std::unique_ptr req; std::unique_ptr res; if (has_request_payload_) { + GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_.call()); req.reset(method_->AllocateRequestProto()); if (!DeserializeProto(request_payload_, req.get())) { abort(); // for now } + GRPC_TIMER_MARK(DESER_PROTO_END, call_.call()); } if (has_response_payload_) { res.reset(method_->AllocateResponseProto()); @@ -340,7 +343,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { bool orig_status = *status; if (*status && request_) { if (payload_) { + GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_); *status = DeserializeProto(payload_, request_); + GRPC_TIMER_MARK(DESER_PROTO_END, call_); } else { *status = false; }