aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2015-04-15 01:02:50 -0700
committerGravatar Vijay Pai <vpai@google.com>2015-04-15 01:02:50 -0700
commit9ffbd0ca4dde4c93b81e3178186653ba2cf475d9 (patch)
tree5c8e882f681b1f67fd838cf58e586d1ae361d862 /src
parent0fb96e8b5e32a8f8c7bc364ff8bc37df61a6e315 (diff)
Mark proto ser/deser on server side
Diffstat (limited to 'src')
-rw-r--r--src/cpp/server/async_server_context.cc4
-rw-r--r--src/cpp/server/server.cc5
2 files changed, 9 insertions, 0 deletions
diff --git a/src/cpp/server/async_server_context.cc b/src/cpp/server/async_server_context.cc
index 628822a338..0162ddc97d 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 046133c5eb..b3cd1fdd74 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -46,6 +46,7 @@
#include <grpc++/server_credentials.h>
#include <grpc++/thread_pool_interface.h>
+#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<grpc::protobuf::Message> req;
std::unique_ptr<grpc::protobuf::Message> 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;
}