From 37f1bd13ab703d7b1c0eb641f2d0515ea91ce8af Mon Sep 17 00:00:00 2001 From: yang-g Date: Thu, 26 Oct 2017 14:42:51 -0700 Subject: clear the request --- test/cpp/qps/server_async.cc | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'test/cpp/qps') diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index 4576be5bb3..4cf80e9e3d 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -70,7 +70,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ServerAsyncReaderWriter *, CompletionQueue *, ServerCompletionQueue *, void *)> request_streaming_both_ways_function, - std::function process_rpc) : Server(config) { @@ -255,7 +255,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { grpc::ServerAsyncResponseWriter *, void *)> request_method, - std::function + std::function invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextUnaryImpl::invoker), @@ -301,8 +301,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { std::function *, void *)> request_method_; - std::function - invoke_method_; + std::function invoke_method_; grpc::ServerAsyncResponseWriter response_writer_; }; @@ -313,7 +312,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ServerContextType *, grpc::ServerAsyncReaderWriter *, void *)> request_method, - std::function + std::function invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextStreamingImpl::request_done), @@ -381,8 +380,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { ServerContextType *, grpc::ServerAsyncReaderWriter *, void *)> request_method_; - std::function - invoke_method_; + std::function invoke_method_; grpc::ServerAsyncReaderWriter stream_; }; @@ -394,7 +392,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { grpc::ServerAsyncReader *, void *)> request_method, - std::function + std::function invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextStreamingFromClientImpl::request_done), @@ -452,8 +450,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { grpc::ServerAsyncReader *, void *)> request_method_; - std::function - invoke_method_; + std::function invoke_method_; grpc::ServerAsyncReader stream_; }; @@ -464,7 +461,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { std::function *, void *)> request_method, - std::function + std::function invoke_method) : srv_ctx_(new ServerContextType), next_state_(&ServerRpcContextStreamingFromServerImpl::request_done), @@ -521,8 +518,7 @@ class AsyncQpsServerTest final : public grpc::testing::Server { std::function *, void *)> request_method_; - std::function - invoke_method_; + std::function invoke_method_; grpc::ServerAsyncWriter stream_; }; @@ -551,8 +547,7 @@ static void RegisterGenericService(ServerBuilder *builder, builder->RegisterAsyncGenericService(service); } -static Status ProcessSimpleRPC(const PayloadConfig &, - const SimpleRequest *request, +static Status ProcessSimpleRPC(const PayloadConfig &, SimpleRequest *request, SimpleResponse *response) { if (request->response_size() > 0) { if (!Server::SetPayload(request->response_type(), request->response_size(), @@ -560,12 +555,17 @@ static Status ProcessSimpleRPC(const PayloadConfig &, return Status(grpc::StatusCode::INTERNAL, "Error creating payload."); } } + // We are done using the request. Clear it to reduce working memory. + // This proves to reduce cache misses in large message size cases. + request->Clear(); return Status::OK; } static Status ProcessGenericRPC(const PayloadConfig &payload_config, - const ByteBuffer *request, - ByteBuffer *response) { + ByteBuffer *request, ByteBuffer *response) { + // We are done using the request. Clear it to reduce working memory. + // This proves to reduce cache misses in large message size cases. + request->Clear(); int resp_size = payload_config.bytebuf_params().resp_size(); std::unique_ptr buf(new char[resp_size]); Slice slice(buf.get(), resp_size); -- cgit v1.2.3