Merge branch 'master' into pollset_set_test

pull/9054/head
Sree Kuchibhotla 8 years ago
commit c04f5b97fd
  1. 3
      BUILD
  2. 6
      src/proto/grpc/testing/BUILD
  3. 100
      test/cpp/microbenchmarks/bm_fullstack.cc

@ -1233,6 +1233,9 @@ grpc_cc_library(
public_hdrs = [ public_hdrs = [
"include/grpc++/impl/codegen/config_protobuf.h", "include/grpc++/impl/codegen/config_protobuf.h",
], ],
external_deps = [
"protobuf",
],
) )
grpc_cc_library( grpc_cc_library(

@ -42,11 +42,13 @@ grpc_proto_library(
name = "control_proto", name = "control_proto",
srcs = ["control.proto"], srcs = ["control.proto"],
deps = ["payloads_proto", "stats_proto"], deps = ["payloads_proto", "stats_proto"],
has_services = False,
) )
grpc_proto_library( grpc_proto_library(
name = "echo_messages_proto", name = "echo_messages_proto",
srcs = ["echo_messages.proto"], srcs = ["echo_messages.proto"],
has_services = False,
) )
grpc_proto_library( grpc_proto_library(
@ -58,11 +60,13 @@ grpc_proto_library(
grpc_proto_library( grpc_proto_library(
name = "empty_proto", name = "empty_proto",
srcs = ["empty.proto"], srcs = ["empty.proto"],
has_services = False,
) )
grpc_proto_library( grpc_proto_library(
name = "messages_proto", name = "messages_proto",
srcs = ["messages.proto"], srcs = ["messages.proto"],
has_services = False,
) )
grpc_proto_library( grpc_proto_library(
@ -73,6 +77,7 @@ grpc_proto_library(
grpc_proto_library( grpc_proto_library(
name = "payloads_proto", name = "payloads_proto",
srcs = ["payloads.proto"], srcs = ["payloads.proto"],
has_services = False,
) )
grpc_proto_library( grpc_proto_library(
@ -84,6 +89,7 @@ grpc_proto_library(
grpc_proto_library( grpc_proto_library(
name = "stats_proto", name = "stats_proto",
srcs = ["stats.proto"], srcs = ["stats.proto"],
has_services = False,
) )
grpc_proto_library( grpc_proto_library(

@ -84,6 +84,16 @@ static class InitializeStuff {
* FIXTURES * FIXTURES
*/ */
static void ApplyCommonServerBuilderConfig(ServerBuilder* b) {
b->SetMaxReceiveMessageSize(INT_MAX);
b->SetMaxSendMessageSize(INT_MAX);
}
static void ApplyCommonChannelArguments(ChannelArguments* c) {
c->SetInt(GRPC_ARG_MAX_RECEIVE_MESSAGE_LENGTH, INT_MAX);
c->SetInt(GRPC_ARG_MAX_SEND_MESSAGE_LENGTH, INT_MAX);
}
class FullstackFixture { class FullstackFixture {
public: public:
FullstackFixture(Service* service, const grpc::string& address) { FullstackFixture(Service* service, const grpc::string& address) {
@ -91,8 +101,11 @@ class FullstackFixture {
b.AddListeningPort(address, InsecureServerCredentials()); b.AddListeningPort(address, InsecureServerCredentials());
cq_ = b.AddCompletionQueue(true); cq_ = b.AddCompletionQueue(true);
b.RegisterService(service); b.RegisterService(service);
ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart(); server_ = b.BuildAndStart();
channel_ = CreateChannel(address, InsecureChannelCredentials()); ChannelArguments args;
ApplyCommonChannelArguments(&args);
channel_ = CreateCustomChannel(address, InsecureChannelCredentials(), args);
} }
virtual ~FullstackFixture() { virtual ~FullstackFixture() {
@ -146,6 +159,7 @@ class EndpointPairFixture {
ServerBuilder b; ServerBuilder b;
cq_ = b.AddCompletionQueue(true); cq_ = b.AddCompletionQueue(true);
b.RegisterService(service); b.RegisterService(service);
ApplyCommonServerBuilderConfig(&b);
server_ = b.BuildAndStart(); server_ = b.BuildAndStart();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@ -174,6 +188,7 @@ class EndpointPairFixture {
{ {
ChannelArguments args; ChannelArguments args;
args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority"); args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority");
ApplyCommonChannelArguments(&args);
grpc_channel_args c_args = args.c_channel_args(); grpc_channel_args c_args = args.c_channel_args();
grpc_transport* transport = grpc_transport* transport =
@ -343,6 +358,12 @@ static void BM_UnaryPingPong(benchmark::State& state) {
EchoRequest send_request; EchoRequest send_request;
EchoResponse send_response; EchoResponse send_response;
EchoResponse recv_response; EchoResponse recv_response;
if (state.range(0) > 0) {
send_request.set_message(std::string(state.range(0), 'a'));
}
if (state.range(1) > 0) {
send_response.set_message(std::string(state.range(1), 'a'));
}
Status recv_status; Status recv_status;
struct ServerEnv { struct ServerEnv {
ServerContext ctx; ServerContext ctx;
@ -365,6 +386,7 @@ static void BM_UnaryPingPong(benchmark::State& state) {
std::unique_ptr<EchoTestService::Stub> stub( std::unique_ptr<EchoTestService::Stub> stub(
EchoTestService::NewStub(fixture->channel())); EchoTestService::NewStub(fixture->channel()));
while (state.KeepRunning()) { while (state.KeepRunning()) {
recv_response.Clear();
ClientContext cli_ctx; ClientContext cli_ctx;
ClientContextMutator cli_ctx_mut(&cli_ctx); ClientContextMutator cli_ctx_mut(&cli_ctx);
std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader( std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
@ -396,55 +418,81 @@ static void BM_UnaryPingPong(benchmark::State& state) {
fixture.reset(); fixture.reset();
server_env[0]->~ServerEnv(); server_env[0]->~ServerEnv();
server_env[1]->~ServerEnv(); server_env[1]->~ServerEnv();
state.SetBytesProcessed(state.range(0) * state.iterations() +
state.range(1) * state.iterations());
} }
/******************************************************************************* /*******************************************************************************
* CONFIGURATIONS * CONFIGURATIONS
*/ */
BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator); static void SweepSizesArgs(benchmark::internal::Benchmark* b) {
BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator); b->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator); for (int i = 1; i <= 128 * 1024 * 1024; i *= 8) {
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator); b->Args({i, 0});
b->Args({0, i});
b->Args({i, i});
}
}
BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP, NoOpMutator, NoOpMutator)
->Apply(SweepSizesArgs);
BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS, NoOpMutator, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair, NoOpMutator, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, NoOpMutator)
->Apply(SweepSizesArgs);
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<10>, 1>, Client_AddMetadata<RandomBinaryMetadata<10>, 1>, NoOpMutator)
NoOpMutator); ->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<31>, 1>, Client_AddMetadata<RandomBinaryMetadata<31>, 1>, NoOpMutator)
NoOpMutator); ->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<100>, 1>, Client_AddMetadata<RandomBinaryMetadata<100>, 1>,
NoOpMutator); NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<10>, 2>, Client_AddMetadata<RandomBinaryMetadata<10>, 2>, NoOpMutator)
NoOpMutator); ->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<31>, 2>, Client_AddMetadata<RandomBinaryMetadata<31>, 2>, NoOpMutator)
NoOpMutator); ->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomBinaryMetadata<100>, 2>, Client_AddMetadata<RandomBinaryMetadata<100>, 2>,
NoOpMutator); NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>); Server_AddInitialMetadata<RandomBinaryMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>); Server_AddInitialMetadata<RandomBinaryMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>); Server_AddInitialMetadata<RandomBinaryMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator); Client_AddMetadata<RandomAsciiMetadata<10>, 1>, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator); Client_AddMetadata<RandomAsciiMetadata<31>, 1>, NoOpMutator)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2,
Client_AddMetadata<RandomAsciiMetadata<100>, 1>, Client_AddMetadata<RandomAsciiMetadata<100>, 1>, NoOpMutator)
NoOpMutator); ->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>); Server_AddInitialMetadata<RandomAsciiMetadata<10>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>); Server_AddInitialMetadata<RandomAsciiMetadata<31>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>); Server_AddInitialMetadata<RandomAsciiMetadata<100>, 1>)
->Args({0, 0});
BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator, BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2, NoOpMutator,
Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>); Server_AddInitialMetadata<RandomAsciiMetadata<10>, 100>)
->Args({0, 0});
} // namespace testing } // namespace testing
} // namespace grpc } // namespace grpc

Loading…
Cancel
Save