Skip to content
Snippets Groups Projects
Commit 9ffbd0ca authored by Vijay Pai's avatar Vijay Pai
Browse files

Mark proto ser/deser on server side

parent 0fb96e8b
No related branches found
No related tags found
No related merge requests found
...@@ -68,9 +68,11 @@ bool AsyncServerContext::StartRead(grpc::protobuf::Message* request) { ...@@ -68,9 +68,11 @@ bool AsyncServerContext::StartRead(grpc::protobuf::Message* request) {
bool AsyncServerContext::StartWrite(const grpc::protobuf::Message& response, bool AsyncServerContext::StartWrite(const grpc::protobuf::Message& response,
int flags) { int flags) {
grpc_byte_buffer* buffer = nullptr; grpc_byte_buffer* buffer = nullptr;
GRPC_TIMER_MARK(SER_PROTO_BEGIN, call_->call());
if (!SerializeProto(response, &buffer)) { if (!SerializeProto(response, &buffer)) {
return false; return false;
} }
GRPC_TIMER_MARK(SER_PROTO_END, call_->call());
grpc_call_error err = grpc_call_start_write_old(call_, buffer, this, flags); grpc_call_error err = grpc_call_start_write_old(call_, buffer, this, flags);
grpc_byte_buffer_destroy(buffer); grpc_byte_buffer_destroy(buffer);
return err == GRPC_CALL_OK; return err == GRPC_CALL_OK;
...@@ -87,7 +89,9 @@ bool AsyncServerContext::StartWriteStatus(const Status& status) { ...@@ -87,7 +89,9 @@ bool AsyncServerContext::StartWriteStatus(const Status& status) {
bool AsyncServerContext::ParseRead(grpc_byte_buffer* read_buffer) { bool AsyncServerContext::ParseRead(grpc_byte_buffer* read_buffer) {
GPR_ASSERT(request_); GPR_ASSERT(request_);
GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_->call());
bool success = DeserializeProto(read_buffer, request_); bool success = DeserializeProto(read_buffer, request_);
GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_->call());
request_ = nullptr; request_ = nullptr;
return success; return success;
} }
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <grpc++/server_credentials.h> #include <grpc++/server_credentials.h>
#include <grpc++/thread_pool_interface.h> #include <grpc++/thread_pool_interface.h>
#include "src/core/profiling/timers.h"
#include "src/cpp/proto/proto_utils.h" #include "src/cpp/proto/proto_utils.h"
#include "src/cpp/util/time.h" #include "src/cpp/util/time.h"
...@@ -123,10 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag { ...@@ -123,10 +124,12 @@ class Server::SyncRequest GRPC_FINAL : public CompletionQueueTag {
std::unique_ptr<grpc::protobuf::Message> req; std::unique_ptr<grpc::protobuf::Message> req;
std::unique_ptr<grpc::protobuf::Message> res; std::unique_ptr<grpc::protobuf::Message> res;
if (has_request_payload_) { if (has_request_payload_) {
GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_.call());
req.reset(method_->AllocateRequestProto()); req.reset(method_->AllocateRequestProto());
if (!DeserializeProto(request_payload_, req.get())) { if (!DeserializeProto(request_payload_, req.get())) {
abort(); // for now abort(); // for now
} }
GRPC_TIMER_MARK(DESER_PROTO_END, call_.call());
} }
if (has_response_payload_) { if (has_response_payload_) {
res.reset(method_->AllocateResponseProto()); res.reset(method_->AllocateResponseProto());
...@@ -340,7 +343,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag { ...@@ -340,7 +343,9 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
bool orig_status = *status; bool orig_status = *status;
if (*status && request_) { if (*status && request_) {
if (payload_) { if (payload_) {
GRPC_TIMER_MARK(DESER_PROTO_BEGIN, call_);
*status = DeserializeProto(payload_, request_); *status = DeserializeProto(payload_, request_);
GRPC_TIMER_MARK(DESER_PROTO_END, call_);
} else { } else {
*status = false; *status = false;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment