From 886d7ecb7ad77af47aa65996f3b5c791d394e1bc Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 14 May 2015 16:18:42 -0700 Subject: [PATCH 01/21] More scalable unary polling - admit only one poller for read and one for write at a time (poll is level triggered, so this avoids a thundering herd on each event) - wake only one poller when more pollers are needed, again avoiding a thundering herd --- src/core/iomgr/fd_posix.c | 75 +++++++++++++++---- src/core/iomgr/fd_posix.h | 4 +- .../pollset_multipoller_with_poll_posix.c | 2 +- src/core/iomgr/pollset_posix.c | 4 +- 4 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 9c8133d2d4c..afd6ddce64d 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -98,6 +98,7 @@ static grpc_fd *alloc_fd(int fd) { r->fd = fd; r->watcher_root.next = r->watcher_root.prev = &r->watcher_root; r->freelist_next = NULL; + r->read_watcher = r->write_watcher = NULL; return r; } @@ -147,14 +148,24 @@ int grpc_fd_is_orphaned(grpc_fd *fd) { return (gpr_atm_acq_load(&fd->refst) & 1) == 0; } -static void wake_watchers(grpc_fd *fd) { - grpc_fd_watcher *watcher; +static void maybe_wake_one_watcher_locked(grpc_fd *fd) { + if (fd->watcher_root.next != &fd->watcher_root) { + grpc_pollset_force_kick(fd->watcher_root.next->pollset); + } +} + +static void maybe_wake_one_watcher(grpc_fd *fd) { gpr_mu_lock(&fd->watcher_mu); + maybe_wake_one_watcher_locked(fd); + gpr_mu_unlock(&fd->watcher_mu); +} + +static void wake_all_watchers(grpc_fd *fd) { + grpc_fd_watcher *watcher; for (watcher = fd->watcher_root.next; watcher != &fd->watcher_root; watcher = watcher->next) { grpc_pollset_force_kick(watcher->pollset); } - gpr_mu_unlock(&fd->watcher_mu); } void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_cb_func on_done, void *user_data) { @@ -162,7 +173,7 @@ void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_cb_func on_done, void *user_data) { fd->on_done_user_data = user_data; shutdown(fd->fd, SHUT_RDWR); ref_by(fd, 1); /* remove active status, but keep referenced */ - wake_watchers(fd); + wake_all_watchers(fd); unref_by(fd, 2); /* drop the reference */ } @@ -204,7 +215,7 @@ static void notify_on(grpc_fd *fd, gpr_atm *st, grpc_iomgr_closure *closure, set_ready call. NOTE: we don't have an ABA problem here, since we should never have concurrent calls to the same notify_on function. */ - wake_watchers(fd); + maybe_wake_one_watcher(fd); return; } /* swap was unsuccessful due to an intervening set_ready call. @@ -290,29 +301,61 @@ void grpc_fd_notify_on_write(grpc_fd *fd, grpc_iomgr_closure *closure) { gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset, gpr_uint32 read_mask, gpr_uint32 write_mask, grpc_fd_watcher *watcher) { + gpr_uint32 mask = 0; /* keep track of pollers that have requested our events, in case they change */ grpc_fd_ref(fd); gpr_mu_lock(&fd->watcher_mu); - watcher->next = &fd->watcher_root; - watcher->prev = watcher->next->prev; - watcher->next->prev = watcher->prev->next = watcher; + /* if there is nobody polling for read, but we need to, then start doing so */ + if (!fd->read_watcher && gpr_atm_acq_load(&fd->readst) > READY) { + fd->read_watcher = watcher; + mask |= read_mask; + } + /* if there is nobody polling for write, but we need to, then start doing so */ + if (!fd->write_watcher && gpr_atm_acq_load(&fd->writest) > READY) { + fd->write_watcher = watcher; + mask |= write_mask; + } + /* if not polling, remember this watcher in case we need someone to later */ + if (mask == 0) { + watcher->next = &fd->watcher_root; + watcher->prev = watcher->next->prev; + watcher->next->prev = watcher->prev->next = watcher; + } watcher->pollset = pollset; watcher->fd = fd; gpr_mu_unlock(&fd->watcher_mu); - return (gpr_atm_acq_load(&fd->readst) != READY ? read_mask : 0) | - (gpr_atm_acq_load(&fd->writest) != READY ? write_mask : 0); + return mask; } -void grpc_fd_end_poll(grpc_fd_watcher *watcher) { - gpr_mu_lock(&watcher->fd->watcher_mu); - watcher->next->prev = watcher->prev; - watcher->prev->next = watcher->next; - gpr_mu_unlock(&watcher->fd->watcher_mu); +void grpc_fd_end_poll(grpc_fd_watcher *watcher, int got_read, int got_write) { + int was_polling = 0; + int kick = 0; + grpc_fd *fd = watcher->fd; + + gpr_mu_lock(&fd->watcher_mu); + if (watcher == fd->read_watcher) { + was_polling = 1; + kick |= !got_read; + fd->read_watcher = NULL; + } + if (watcher == fd->write_watcher) { + was_polling = 1; + kick |= !got_write; + fd->write_watcher = NULL; + } + if (!was_polling) { + watcher->next->prev = watcher->prev; + watcher->prev->next = watcher->next; + } + if (kick) { + maybe_wake_one_watcher_locked(fd); + } + gpr_mu_unlock(&fd->watcher_mu); - grpc_fd_unref(watcher->fd); + grpc_fd_unref(fd); } void grpc_fd_become_readable(grpc_fd *fd, int allow_synchronous_callback) { diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h index be21f2b55f8..af79d4c4495 100644 --- a/src/core/iomgr/fd_posix.h +++ b/src/core/iomgr/fd_posix.h @@ -68,6 +68,8 @@ struct grpc_fd { gpr_mu watcher_mu; grpc_fd_watcher watcher_root; + grpc_fd_watcher *read_watcher; + grpc_fd_watcher *write_watcher; gpr_atm readst; gpr_atm writest; @@ -103,7 +105,7 @@ gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset, gpr_uint32 read_mask, gpr_uint32 write_mask, grpc_fd_watcher *rec); /* Complete polling previously started with grpc_fd_begin_poll */ -void grpc_fd_end_poll(grpc_fd_watcher *rec); +void grpc_fd_end_poll(grpc_fd_watcher *rec, int got_read, int got_write); /* Return 1 if this fd is orphaned, 0 otherwise */ int grpc_fd_is_orphaned(grpc_fd *fd); diff --git a/src/core/iomgr/pollset_multipoller_with_poll_posix.c b/src/core/iomgr/pollset_multipoller_with_poll_posix.c index 25b7cfda1a1..4d36107ab0f 100644 --- a/src/core/iomgr/pollset_multipoller_with_poll_posix.c +++ b/src/core/iomgr/pollset_multipoller_with_poll_posix.c @@ -98,7 +98,7 @@ static void end_polling(grpc_pollset *pollset) { pollset_hdr *h; h = pollset->data.ptr; for (i = 1; i < h->pfd_count; i++) { - grpc_fd_end_poll(&h->watchers[i]); + grpc_fd_end_poll(&h->watchers[i], h->pfds[i].revents & POLLIN, h->pfds[i].revents & POLLOUT); } } diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index 4d1bcad9e27..ed744255559 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -410,10 +410,10 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher); - r = poll(pfd, GPR_ARRAY_SIZE(pfd), timeout); + r = poll(pfd, GPR_ARRAY_SIZE(pfd) - (pfd[1].events == 0), timeout); GRPC_TIMER_MARK(GRPC_PTAG_POLL_FINISHED, r); - grpc_fd_end_poll(&fd_watcher); + grpc_fd_end_poll(&fd_watcher, pfd[1].revents & POLLIN, pfd[1].revents & POLLOUT); if (r < 0) { if (errno != EINTR) { From 354bf6d77ba0c89288d8196abeebb6cb764d5a22 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 18 May 2015 10:18:03 -0700 Subject: [PATCH 02/21] Document variable usage in fd_posix Update some code based on that documentation --- src/core/iomgr/fd_posix.c | 20 +++++++++++++++----- src/core/iomgr/fd_posix.h | 24 +++++++++++++++++++++++- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index afd6ddce64d..4cbc46cd179 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -96,7 +96,7 @@ static grpc_fd *alloc_fd(int fd) { gpr_atm_rel_store(&r->writest, NOT_READY); gpr_atm_rel_store(&r->shutdown, 0); r->fd = fd; - r->watcher_root.next = r->watcher_root.prev = &r->watcher_root; + r->inactive_watcher_root.next = r->inactive_watcher_root.prev = &r->inactive_watcher_root; r->freelist_next = NULL; r->read_watcher = r->write_watcher = NULL; return r; @@ -149,8 +149,12 @@ int grpc_fd_is_orphaned(grpc_fd *fd) { } static void maybe_wake_one_watcher_locked(grpc_fd *fd) { - if (fd->watcher_root.next != &fd->watcher_root) { - grpc_pollset_force_kick(fd->watcher_root.next->pollset); + if (fd->inactive_watcher_root.next != &fd->inactive_watcher_root) { + grpc_pollset_force_kick(fd->inactive_watcher_root.next->pollset); + } else if (fd->read_watcher) { + grpc_pollset_force_kick(fd->read_watcher->pollset); + } else if (fd->write_watcher) { + grpc_pollset_force_kick(fd->write_watcher->pollset); } } @@ -162,10 +166,16 @@ static void maybe_wake_one_watcher(grpc_fd *fd) { static void wake_all_watchers(grpc_fd *fd) { grpc_fd_watcher *watcher; - for (watcher = fd->watcher_root.next; watcher != &fd->watcher_root; + for (watcher = fd->inactive_watcher_root.next; watcher != &fd->inactive_watcher_root; watcher = watcher->next) { grpc_pollset_force_kick(watcher->pollset); } + if (fd->read_watcher) { + grpc_pollset_force_kick(fd->read_watcher->pollset); + } + if (fd->write_watcher && fd->write_watcher != fd->read_watcher) { + grpc_pollset_force_kick(fd->write_watcher->pollset); + } } void grpc_fd_orphan(grpc_fd *fd, grpc_iomgr_cb_func on_done, void *user_data) { @@ -319,7 +329,7 @@ gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset, } /* if not polling, remember this watcher in case we need someone to later */ if (mask == 0) { - watcher->next = &fd->watcher_root; + watcher->next = &fd->inactive_watcher_root; watcher->prev = watcher->next->prev; watcher->next->prev = watcher->prev->next = watcher; } diff --git a/src/core/iomgr/fd_posix.h b/src/core/iomgr/fd_posix.h index af79d4c4495..cfc533b7f56 100644 --- a/src/core/iomgr/fd_posix.h +++ b/src/core/iomgr/fd_posix.h @@ -66,8 +66,30 @@ struct grpc_fd { gpr_mu set_state_mu; gpr_atm shutdown; + /* The watcher list. + + The following watcher related fields are protected by watcher_mu. + + An fd_watcher is an ephemeral object created when an fd wants to + begin polling, and destroyed after the poll. + + It denotes the fd's interest in whether to read poll or write poll + or both or neither on this fd. + + If a watcher is asked to poll for reads or writes, the read_watcher + or write_watcher fields are set respectively. A watcher may be asked + to poll for both, in which case both fields will be set. + + read_watcher and write_watcher may be NULL if no watcher has been + asked to poll for reads or writes. + + If an fd_watcher is not asked to poll for reads or writes, it's added + to a linked list of inactive watchers, rooted at inactive_watcher_root. + If at a later time there becomes need of a poller to poll, one of + the inactive pollers may be kicked out of their poll loops to take + that responsibility. */ gpr_mu watcher_mu; - grpc_fd_watcher watcher_root; + grpc_fd_watcher inactive_watcher_root; grpc_fd_watcher *read_watcher; grpc_fd_watcher *write_watcher; From 236d098395c5360e90f224435a14bed7f2cce6f2 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 18 May 2015 10:26:44 -0700 Subject: [PATCH 03/21] Add another little comment --- src/core/iomgr/fd_posix.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 4cbc46cd179..3ff27631be0 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -347,16 +347,19 @@ void grpc_fd_end_poll(grpc_fd_watcher *watcher, int got_read, int got_write) { gpr_mu_lock(&fd->watcher_mu); if (watcher == fd->read_watcher) { + /* remove read watcher, kick if we still need a read */ was_polling = 1; kick |= !got_read; fd->read_watcher = NULL; } if (watcher == fd->write_watcher) { + /* remove write watcher, kick if we still need a write */ was_polling = 1; kick |= !got_write; fd->write_watcher = NULL; } if (!was_polling) { + /* remove from inactive list */ watcher->next->prev = watcher->prev; watcher->prev->next = watcher->next; } From 2f24d956dfd53c3c58cf33623a1d468cc3900eea Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 18 May 2015 10:39:34 -0700 Subject: [PATCH 04/21] Clarify booleanness of kick --- src/core/iomgr/fd_posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 3ff27631be0..31a62b8ef8e 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -349,13 +349,13 @@ void grpc_fd_end_poll(grpc_fd_watcher *watcher, int got_read, int got_write) { if (watcher == fd->read_watcher) { /* remove read watcher, kick if we still need a read */ was_polling = 1; - kick |= !got_read; + kick = kick || !got_read; fd->read_watcher = NULL; } if (watcher == fd->write_watcher) { /* remove write watcher, kick if we still need a write */ was_polling = 1; - kick |= !got_write; + kick = kick || !got_write; fd->write_watcher = NULL; } if (!was_polling) { From 8e50fe97644bb62e48c58707eb10513c317d041f Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 18 May 2015 10:45:04 -0700 Subject: [PATCH 05/21] clang-format --- src/core/iomgr/fd_posix.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/core/iomgr/fd_posix.c b/src/core/iomgr/fd_posix.c index 3ff27631be0..63615ea25f7 100644 --- a/src/core/iomgr/fd_posix.c +++ b/src/core/iomgr/fd_posix.c @@ -96,7 +96,8 @@ static grpc_fd *alloc_fd(int fd) { gpr_atm_rel_store(&r->writest, NOT_READY); gpr_atm_rel_store(&r->shutdown, 0); r->fd = fd; - r->inactive_watcher_root.next = r->inactive_watcher_root.prev = &r->inactive_watcher_root; + r->inactive_watcher_root.next = r->inactive_watcher_root.prev = + &r->inactive_watcher_root; r->freelist_next = NULL; r->read_watcher = r->write_watcher = NULL; return r; @@ -166,8 +167,8 @@ static void maybe_wake_one_watcher(grpc_fd *fd) { static void wake_all_watchers(grpc_fd *fd) { grpc_fd_watcher *watcher; - for (watcher = fd->inactive_watcher_root.next; watcher != &fd->inactive_watcher_root; - watcher = watcher->next) { + for (watcher = fd->inactive_watcher_root.next; + watcher != &fd->inactive_watcher_root; watcher = watcher->next) { grpc_pollset_force_kick(watcher->pollset); } if (fd->read_watcher) { @@ -322,7 +323,8 @@ gpr_uint32 grpc_fd_begin_poll(grpc_fd *fd, grpc_pollset *pollset, fd->read_watcher = watcher; mask |= read_mask; } - /* if there is nobody polling for write, but we need to, then start doing so */ + /* if there is nobody polling for write, but we need to, then start doing so + */ if (!fd->write_watcher && gpr_atm_acq_load(&fd->writest) > READY) { fd->write_watcher = watcher; mask |= write_mask; @@ -349,13 +351,13 @@ void grpc_fd_end_poll(grpc_fd_watcher *watcher, int got_read, int got_write) { if (watcher == fd->read_watcher) { /* remove read watcher, kick if we still need a read */ was_polling = 1; - kick |= !got_read; + kick = kick || !got_read; fd->read_watcher = NULL; } if (watcher == fd->write_watcher) { /* remove write watcher, kick if we still need a write */ was_polling = 1; - kick |= !got_write; + kick = kick || !got_write; fd->write_watcher = NULL; } if (!was_polling) { From cdbdedbf23203c5edae587fb42168eb3e2cdd3f3 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 18 May 2015 17:28:52 -0700 Subject: [PATCH 06/21] Refactored benchmark reporting mechanism. It now allows pluggging in "reporter" instances to process the benchmark results arbitrarily. This would allow, for example, to send results to a leaderboard and/or other systems for tracking performance metrics. --- .../cpp/qps/async_streaming_ping_pong_test.cc | 11 +- test/cpp/qps/async_unary_ping_pong_test.cc | 11 +- test/cpp/qps/qps_driver.cc | 22 ++-- test/cpp/qps/qps_test.cc | 12 +- test/cpp/qps/report.cc | 66 +++++++++-- test/cpp/qps/report.h | 112 ++++++++++++++++-- test/cpp/qps/sync_streaming_ping_pong_test.cc | 12 +- test/cpp/qps/sync_unary_ping_pong_test.cc | 11 +- 8 files changed, 219 insertions(+), 38 deletions(-) diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc index a1822b7e156..3106f26d66f 100644 --- a/test/cpp/qps/async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/async_streaming_ping_pong_test.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -47,6 +49,9 @@ static const int BENCHMARK = 10; static void RunAsyncStreamingPingPong() { gpr_log(GPR_INFO, "Running Async Streaming Ping Pong"); + ReportersRegistry reporters_registry; + reporters_registry.Register(new GprLogReporter("LogReporter")); + ClientConfig client_config; client_config.set_client_type(ASYNC_CLIENT); client_config.set_enable_ssl(false); @@ -64,8 +69,10 @@ static void RunAsyncStreamingPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(result); - ReportLatency(result); + std::set types; + types.insert(grpc::testing::ReportType::REPORT_QPS); + types.insert(grpc::testing::ReportType::REPORT_LATENCY); + reporters_registry.Report({client_config, server_config, result}, types); } } // namespace testing diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc index 8b037a86562..a51badd9c1e 100644 --- a/test/cpp/qps/async_unary_ping_pong_test.cc +++ b/test/cpp/qps/async_unary_ping_pong_test.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -47,6 +49,9 @@ static const int BENCHMARK = 10; static void RunAsyncUnaryPingPong() { gpr_log(GPR_INFO, "Running Async Unary Ping Pong"); + ReportersRegistry reporters_registry; + reporters_registry.Register(new GprLogReporter("LogReporter")); + ClientConfig client_config; client_config.set_client_type(ASYNC_CLIENT); client_config.set_enable_ssl(false); @@ -64,8 +69,10 @@ static void RunAsyncUnaryPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(result); - ReportLatency(result); + std::set types; + types.insert(grpc::testing::ReportType::REPORT_QPS); + types.insert(grpc::testing::ReportType::REPORT_LATENCY); + reporters_registry.Report({client_config, server_config, result}, types); } } // namespace testing diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index fc8e04201cd..3aa215b4485 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -67,10 +69,17 @@ using grpc::testing::ClientType; using grpc::testing::ServerType; using grpc::testing::RpcType; using grpc::testing::ResourceUsage; +using grpc::testing::ReportersRegistry; +using grpc::testing::GprLogReporter; +using grpc::testing::ReportData; +using grpc::testing::ReportType; int main(int argc, char** argv) { grpc::testing::InitTest(&argc, &argv, true); + ReportersRegistry reporters_registry; + reporters_registry.Register(new GprLogReporter("LogReporter")); + RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); @@ -103,14 +112,13 @@ int main(int argc, char** argv) { FLAGS_server_threads < FLAGS_client_channels * FLAGS_outstanding_rpcs_per_channel)); - auto result = RunScenario(client_config, FLAGS_num_clients, - server_config, FLAGS_num_servers, - FLAGS_warmup_seconds, FLAGS_benchmark_seconds, - FLAGS_local_workers); + const auto result = RunScenario( + client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, + FLAGS_warmup_seconds, FLAGS_benchmark_seconds, FLAGS_local_workers); - ReportQPSPerCore(result, server_config); - ReportLatency(result); - ReportTimes(result); + std::set types; + types.insert(grpc::testing::ReportType::REPORT_ALL); + reporters_registry.Report({client_config, server_config, result}, types); return 0; } diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index f567e4cf061..2f72519397d 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -47,6 +49,9 @@ static const int BENCHMARK = 10; static void RunQPS() { gpr_log(GPR_INFO, "Running QPS test"); + ReportersRegistry reporters_registry; + reporters_registry.Register(new GprLogReporter("LogReporter")); + ClientConfig client_config; client_config.set_client_type(ASYNC_CLIENT); client_config.set_enable_ssl(false); @@ -64,8 +69,11 @@ static void RunQPS() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPSPerCore(result, server_config); - ReportLatency(result); + std::set types; + types.insert(grpc::testing::ReportType::REPORT_QPS_PER_CORE); + types.insert(grpc::testing::ReportType::REPORT_LATENCY); + reporters_registry.Report({client_config, server_config, result}, types); + } } // namespace testing diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 29d88da344a..72b3a3643d5 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -39,27 +39,73 @@ namespace grpc { namespace testing { -// QPS: XXX -void ReportQPS(const ScenarioResult& result) { +// ReporterRegistry implementation. +void ReportersRegistry::Register(const Reporter* reporter) { + reporters_.emplace_back(reporter); +} + +std::vector ReportersRegistry::GetNamesRegistered() const { + std::vector names; + for (const auto& reporter : reporters_) { + names.push_back(reporter->name()); + } + return names; +} + +void ReportersRegistry::Report(const ReportData& data, + const std::set& types) const { + for (const auto& reporter : reporters_) { + reporter->Report(data, types); + } +} + +// Reporter implementation. +void Reporter::Report(const ReportData& data, + const std::set& types) const { + for (ReportType rtype : types) { + bool all = false; + switch (rtype) { + case REPORT_ALL: + all = true; + case REPORT_QPS: + ReportQPS(data.scenario_result); + if (!all) break; + case REPORT_QPS_PER_CORE: + ReportQPSPerCore(data.scenario_result, data.server_config); + if (!all) break; + case REPORT_LATENCY: + ReportLatency(data.scenario_result); + if (!all) break; + case REPORT_TIMES: + ReportTimes(data.scenario_result); + if (!all) break; + } + if (all) break; + } +} + +// GprLogReporter implementation. +void GprLogReporter::ReportQPS(const ScenarioResult& result) const { gpr_log(GPR_INFO, "QPS: %.1f", result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; })); } -// QPS: XXX (YYY/server core) -void ReportQPSPerCore(const ScenarioResult& result, const ServerConfig& server_config) { - auto qps = +void GprLogReporter::ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& server_config) const { + auto qps = result.latencies.Count() / average(result.client_resources, [](ResourceUsage u) { return u.wall_time; }); - gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps, qps/server_config.threads()); + gpr_log(GPR_INFO, "QPS: %.1f (%.1f/server core)", qps, + qps / server_config.threads()); } -// Latency (50/90/95/99/99.9%-ile): AA/BB/CC/DD/EE us -void ReportLatency(const ScenarioResult& result) { - gpr_log(GPR_INFO, "Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us", +void GprLogReporter::ReportLatency(const ScenarioResult& result) const { + gpr_log(GPR_INFO, + "Latencies (50/90/95/99/99.9%%-ile): %.1f/%.1f/%.1f/%.1f/%.1f us", result.latencies.Percentile(50) / 1000, result.latencies.Percentile(90) / 1000, result.latencies.Percentile(95) / 1000, @@ -67,7 +113,7 @@ void ReportLatency(const ScenarioResult& result) { result.latencies.Percentile(99.9) / 1000); } -void ReportTimes(const ScenarioResult& result) { +void GprLogReporter::ReportTimes(const ScenarioResult& result) const { gpr_log(GPR_INFO, "Server system time: %.2f%%", 100.0 * sum(result.server_resources, [](ResourceUsage u) { return u.system_time; }) / diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 343e426ca4a..e62b9deb32b 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -34,22 +34,112 @@ #ifndef TEST_QPS_REPORT_H #define TEST_QPS_REPORT_H +#include +#include +#include +#include + #include "test/cpp/qps/driver.h" +#include "test/cpp/qps/qpstest.grpc.pb.h" namespace grpc { namespace testing { -// QPS: XXX -void ReportQPS(const ScenarioResult& result); -// QPS: XXX (YYY/server core) -void ReportQPSPerCore(const ScenarioResult& result, const ServerConfig& config); -// Latency (50/90/95/99/99.9%-ile): AA/BB/CC/DD/EE us -void ReportLatency(const ScenarioResult& result); -// Server system time: XX% -// Server user time: XX% -// Client system time: XX% -// Client user time: XX% -void ReportTimes(const ScenarioResult& result); +/** General set of data required for report generation. */ +struct ReportData { + const ClientConfig& client_config; + const ServerConfig& server_config; + const ScenarioResult& scenario_result; +}; + +/** Specifies the type of performance report we are interested in. + * + * \note The special type \c REPORT_ALL is equivalent to specifying all the + * other fields. */ +enum ReportType { + /** Equivalent to the combination of all other fields. */ + REPORT_ALL, + /** Report only QPS information. */ + REPORT_QPS, + /** Report only QPS per core information. */ + REPORT_QPS_PER_CORE, + /** Report latency info for the 50, 90, 95, 99 and 99.9th percentiles. */ + REPORT_LATENCY, + /** Report user and system time. */ + REPORT_TIMES +}; + +class Reporter; + +/** A registry of Reporter instances. + * + * Instances registered will be taken into account by the Report() method. + */ +class ReportersRegistry { + public: + /** Adds the \c reporter to the registry. + * \attention Takes ownership of \c reporter. */ + void Register(const Reporter* reporter); + + /** Returns the names of the registered \c Reporter instances. */ + std::vector GetNamesRegistered() const; + + /** Triggers the reporting for all registered \c Reporter instances. + * + * \param data Configuration and results for the scenario being reported. + * \param types A collection of report types to include in the report. */ + void Report(const ReportData& data, + const std::set& types) const; + + private: + std::vector > reporters_; +}; + +/** Interface for all reporters. */ +class Reporter { + public: + /** Construct a reporter with the given \a name. */ + Reporter(const string& name) : name_(name) {} + + /** Returns this reporter's name. + * + * Names are constants, set at construction time. */ + string name() const { return name_; } + + /** Template method responsible for the generation of the requested types. */ + void Report(const ReportData& data, const std::set& types) const; + + protected: + /** Reports QPS for the given \a result. */ + virtual void ReportQPS(const ScenarioResult& result) const = 0; + /** Reports QPS per core as (YYY/server core). */ + virtual void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const = 0; + /** Reports latencies for the 50, 90, 95, 99 and 99.9 percentiles, in ms. */ + virtual void ReportLatency(const ScenarioResult& result) const = 0; + + /** Reports system and user time for client and server systems. */ + virtual void ReportTimes(const ScenarioResult& result) const = 0; + + private: + const string name_; +}; + + +// Reporters. + +/** Reporter to gpr_log(GPR_INFO). */ +class GprLogReporter : public Reporter { + public: + GprLogReporter(const string& name) : Reporter(name) {} + + private: + void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const GRPC_OVERRIDE; + void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; +}; } // namespace testing } // namespace grpc diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index 48c7ff63e03..ddc1573bfdd 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -47,6 +49,9 @@ static const int BENCHMARK = 10; static void RunSynchronousStreamingPingPong() { gpr_log(GPR_INFO, "Running Synchronous Streaming Ping Pong"); + ReportersRegistry reporters_registry; + reporters_registry.Register(new GprLogReporter("LogReporter")); + ClientConfig client_config; client_config.set_client_type(SYNCHRONOUS_CLIENT); client_config.set_enable_ssl(false); @@ -63,8 +68,11 @@ static void RunSynchronousStreamingPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(result); - ReportLatency(result); + std::set types; + types.insert(grpc::testing::ReportType::REPORT_QPS); + types.insert(grpc::testing::ReportType::REPORT_LATENCY); + reporters_registry.Report({client_config, server_config, result}, types); + } } // namespace testing diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index 4c4de6377b8..a1bd1f1705d 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -31,6 +31,8 @@ * */ +#include + #include #include @@ -47,6 +49,9 @@ static const int BENCHMARK = 10; static void RunSynchronousUnaryPingPong() { gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong"); + ReportersRegistry reporters_registry; + reporters_registry.Register(new GprLogReporter("LogReporter")); + ClientConfig client_config; client_config.set_client_type(SYNCHRONOUS_CLIENT); client_config.set_enable_ssl(false); @@ -63,8 +68,10 @@ static void RunSynchronousUnaryPingPong() { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - ReportQPS(result); - ReportLatency(result); + std::set types; + types.insert(grpc::testing::ReportType::REPORT_QPS); + types.insert(grpc::testing::ReportType::REPORT_LATENCY); + reporters_registry.Report({client_config, server_config, result}, types); } } // namespace testing From 3cc9ec92d90cf24603ee556da2d8b188428e2615 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 18 May 2015 22:33:02 -0700 Subject: [PATCH 07/21] Removed registry for benchmark reports & introduced benchmark_config.{h,cc} in the spirit of test_config.{h,cc}. The purpose of benchmark_config is to allow for different behaviors to be decided at compile-time. --- Makefile | 85 ++++++++++++++----- build.json | 16 +++- .../cpp/qps/async_streaming_ping_pong_test.cc | 17 ++-- test/cpp/qps/async_unary_ping_pong_test.cc | 16 ++-- test/cpp/qps/qps_driver.cc | 30 ++++--- test/cpp/qps/qps_test.cc | 16 ++-- test/cpp/qps/report.cc | 20 ----- test/cpp/qps/report.h | 24 ------ test/cpp/qps/sync_streaming_ping_pong_test.cc | 18 ++-- test/cpp/qps/sync_unary_ping_pong_test.cc | 13 ++- 10 files changed, 149 insertions(+), 106 deletions(-) diff --git a/Makefile b/Makefile index a17dc63e601..6017455a4a2 100644 --- a/Makefile +++ b/Makefile @@ -1153,7 +1153,7 @@ privatelibs: privatelibs_c privatelibs_cxx privatelibs_c: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util_unsecure.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fake_security.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_fullstack_uds_posix.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_simple_ssl_with_oauth2_fullstack.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair_one_byte_at_a_time.a $(LIBDIR)/$(CONFIG)/libend2end_fixture_chttp2_socket_pair_with_grpc_trace.a $(LIBDIR)/$(CONFIG)/libend2end_test_bad_hostname.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_accept.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_accept_and_writes_closed.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_after_invoke.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_before_invoke.a $(LIBDIR)/$(CONFIG)/libend2end_test_cancel_in_a_vacuum.a $(LIBDIR)/$(CONFIG)/libend2end_test_census_simple_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_disappearing_server.a $(LIBDIR)/$(CONFIG)/libend2end_test_early_server_shutdown_finishes_inflight_calls.a $(LIBDIR)/$(CONFIG)/libend2end_test_early_server_shutdown_finishes_tags.a $(LIBDIR)/$(CONFIG)/libend2end_test_empty_batch.a $(LIBDIR)/$(CONFIG)/libend2end_test_graceful_server_shutdown.a $(LIBDIR)/$(CONFIG)/libend2end_test_invoke_large_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_max_concurrent_streams.a $(LIBDIR)/$(CONFIG)/libend2end_test_max_message_length.a $(LIBDIR)/$(CONFIG)/libend2end_test_no_op.a $(LIBDIR)/$(CONFIG)/libend2end_test_ping_pong_streaming.a $(LIBDIR)/$(CONFIG)/libend2end_test_registered_call.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_binary_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_payload_and_call_creds.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_response_with_trailing_metadata_and_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_large_metadata.a $(LIBDIR)/$(CONFIG)/libend2end_test_request_with_payload.a $(LIBDIR)/$(CONFIG)/libend2end_test_server_finishes_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_delayed_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_request.a $(LIBDIR)/$(CONFIG)/libend2end_test_simple_request_with_high_initial_sequence_number.a $(LIBDIR)/$(CONFIG)/libend2end_certs.a -privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a +privatelibs_cxx: $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libinterop_client_helper.a $(LIBDIR)/$(CONFIG)/libinterop_client_main.a $(LIBDIR)/$(CONFIG)/libinterop_server_helper.a $(LIBDIR)/$(CONFIG)/libinterop_server_main.a $(LIBDIR)/$(CONFIG)/libqps.a buildtests: buildtests_c buildtests_cxx @@ -3198,6 +3198,53 @@ endif endif +LIBGRPC++_BENCHMARK_CONFIG_SRC = \ + test/cpp/util/benchmark_config.cc \ + + +LIBGRPC++_BENCHMARK_CONFIG_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(LIBGRPC++_BENCHMARK_CONFIG_SRC)))) + +ifeq ($(NO_SECURE),true) + +# You can't build secure libraries if you don't have OpenSSL with ALPN. + +$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: openssl_dep_error + + +else + +ifeq ($(NO_PROTOBUF),true) + +# You can't build a C++ library if you don't have protobuf - a bit overreached, but still okay. + +$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: protobuf_dep_error + + +else + +$(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a: $(ZLIB_DEP) $(OPENSSL_DEP) $(PROTOBUF_DEP) $(LIBGRPC++_BENCHMARK_CONFIG_OBJS) + $(E) "[AR] Creating $@" + $(Q) mkdir -p `dirname $@` + $(Q) rm -f $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a + $(Q) $(AR) rcs $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBGRPC++_BENCHMARK_CONFIG_OBJS) +ifeq ($(SYSTEM),Darwin) + $(Q) ranlib $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a +endif + + + + +endif + +endif + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(LIBGRPC++_BENCHMARK_CONFIG_OBJS:.o=.dep) +endif +endif + + LIBGRPC++_TEST_CONFIG_SRC = \ test/cpp/util/test_config.cc \ @@ -7069,16 +7116,16 @@ $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test + $(Q) $(LDXX) $(LDFLAGS) $(ASYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_streaming_ping_pong_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/async_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/cpp/qps/async_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_async_streaming_ping_pong_test: $(ASYNC_STREAMING_PING_PONG_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -7109,16 +7156,16 @@ $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/async_unary_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/async_unary_ping_pong_test: $(PROTOBUF_DEP) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test + $(Q) $(LDXX) $(LDFLAGS) $(ASYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/async_unary_ping_pong_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/async_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/cpp/qps/async_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_async_unary_ping_pong_test: $(ASYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -7827,16 +7874,16 @@ $(BINDIR)/$(CONFIG)/qps_driver: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/qps_driver: $(PROTOBUF_DEP) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(BINDIR)/$(CONFIG)/qps_driver: $(PROTOBUF_DEP) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_driver + $(Q) $(LDXX) $(LDFLAGS) $(QPS_DRIVER_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_driver endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_driver.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_driver.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a deps_qps_driver: $(QPS_DRIVER_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -7867,16 +7914,16 @@ $(BINDIR)/$(CONFIG)/qps_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/qps_test: $(PROTOBUF_DEP) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(BINDIR)/$(CONFIG)/qps_test: $(PROTOBUF_DEP) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_test + $(Q) $(LDXX) $(LDFLAGS) $(QPS_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/qps_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a +$(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_config.a deps_qps_test: $(QPS_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -7987,16 +8034,16 @@ $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test + $(Q) $(LDXX) $(LDFLAGS) $(SYNC_STREAMING_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_streaming_ping_pong_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_streaming_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_sync_streaming_ping_pong_test: $(SYNC_STREAMING_PING_PONG_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) @@ -8027,16 +8074,16 @@ $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test: protobuf_dep_error else -$(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test: $(PROTOBUF_DEP) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LDXX) $(LDFLAGS) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test + $(Q) $(LDXX) $(LDFLAGS) $(SYNC_UNARY_PING_PONG_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/sync_unary_ping_pong_test endif endif -$(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(OBJDIR)/$(CONFIG)/test/cpp/qps/sync_unary_ping_pong_test.o: $(LIBDIR)/$(CONFIG)/libqps.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++_benchmark_config.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a deps_sync_unary_ping_pong_test: $(SYNC_UNARY_PING_PONG_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) diff --git a/build.json b/build.json index 8a7e65b99ab..4952b890a9f 100644 --- a/build.json +++ b/build.json @@ -525,6 +525,14 @@ "secure": "check", "vs_project_guid": "{C187A093-A0FE-489D-A40A-6E33DE0F9FEB}" }, + { + "name": "grpc++_benchmark_config", + "build": "private", + "language": "c++", + "src": [ + "test/cpp/util/benchmark_config.cc" + ] + }, { "name": "grpc++_test_config", "build": "private", @@ -1820,6 +1828,7 @@ "deps": [ "qps", "grpc++_test_util", + "grpc++_benchmark_config", "grpc_test_util", "grpc++", "grpc", @@ -1837,6 +1846,7 @@ "deps": [ "qps", "grpc++_test_util", + "grpc++_benchmark_config", "grpc_test_util", "grpc++", "grpc", @@ -2144,7 +2154,8 @@ "grpc", "gpr_test_util", "gpr", - "grpc++_test_config" + "grpc++_test_config", + "grpc++_benchmark_config" ] }, { @@ -2157,6 +2168,7 @@ "deps": [ "qps", "grpc++_test_util", + "grpc++_benchmark_config", "grpc_test_util", "grpc++", "grpc", @@ -2212,6 +2224,7 @@ "deps": [ "qps", "grpc++_test_util", + "grpc++_benchmark_config", "grpc_test_util", "grpc++", "grpc", @@ -2229,6 +2242,7 @@ "deps": [ "qps", "grpc++_test_util", + "grpc++_benchmark_config", "grpc_test_util", "grpc++", "grpc", diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc index 3106f26d66f..c7367d876d8 100644 --- a/test/cpp/qps/async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/async_streaming_ping_pong_test.cc @@ -39,6 +39,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -46,12 +47,10 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunAsyncStreamingPingPong() { +static void RunAsyncStreamingPingPong( + const std::vector >& reporters) { gpr_log(GPR_INFO, "Running Async Streaming Ping Pong"); - ReportersRegistry reporters_registry; - reporters_registry.Register(new GprLogReporter("LogReporter")); - ClientConfig client_config; client_config.set_client_type(ASYNC_CLIENT); client_config.set_enable_ssl(false); @@ -72,15 +71,19 @@ static void RunAsyncStreamingPingPong() { std::set types; types.insert(grpc::testing::ReportType::REPORT_QPS); types.insert(grpc::testing::ReportType::REPORT_LATENCY); - reporters_registry.Report({client_config, server_config, result}, types); + for (const auto& reporter : reporters) { + reporter->Report({client_config, server_config, result}, types); + } } } // namespace testing } // namespace grpc int main(int argc, char** argv) { - signal(SIGPIPE, SIG_IGN); - grpc::testing::RunAsyncStreamingPingPong(); + grpc::testing::InitBenchmark(&argc, &argv, true); + const auto& reporters = grpc::testing::InitBenchmarkReporters(); + signal(SIGPIPE, SIG_IGN); + grpc::testing::RunAsyncStreamingPingPong(reporters); return 0; } diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc index a51badd9c1e..50e824bf0ea 100644 --- a/test/cpp/qps/async_unary_ping_pong_test.cc +++ b/test/cpp/qps/async_unary_ping_pong_test.cc @@ -39,6 +39,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -46,12 +47,10 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunAsyncUnaryPingPong() { +static void RunAsyncUnaryPingPong( + const std::vector >& reporters) { gpr_log(GPR_INFO, "Running Async Unary Ping Pong"); - ReportersRegistry reporters_registry; - reporters_registry.Register(new GprLogReporter("LogReporter")); - ClientConfig client_config; client_config.set_client_type(ASYNC_CLIENT); client_config.set_enable_ssl(false); @@ -72,15 +71,18 @@ static void RunAsyncUnaryPingPong() { std::set types; types.insert(grpc::testing::ReportType::REPORT_QPS); types.insert(grpc::testing::ReportType::REPORT_LATENCY); - reporters_registry.Report({client_config, server_config, result}, types); + for (const auto& reporter : reporters) { + reporter->Report({client_config, server_config, result}, types); + } } - } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunAsyncUnaryPingPong(); + grpc::testing::RunAsyncUnaryPingPong(reporters); return 0; } diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 3aa215b4485..b06b88d8a0b 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -31,6 +31,7 @@ * */ +#include #include #include @@ -38,7 +39,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" -#include "test/cpp/util/test_config.h" +#include "test/cpp/util/benchmark_config.h" DEFINE_int32(num_clients, 1, "Number of client binaries"); DEFINE_int32(num_servers, 1, "Number of server binaries"); @@ -69,17 +70,13 @@ using grpc::testing::ClientType; using grpc::testing::ServerType; using grpc::testing::RpcType; using grpc::testing::ResourceUsage; -using grpc::testing::ReportersRegistry; -using grpc::testing::GprLogReporter; -using grpc::testing::ReportData; using grpc::testing::ReportType; -int main(int argc, char** argv) { - grpc::testing::InitTest(&argc, &argv, true); - - ReportersRegistry reporters_registry; - reporters_registry.Register(new GprLogReporter("LogReporter")); +namespace grpc { +namespace testing { +static void QpsDriver( + const std::vector >& reporters) { RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); @@ -118,7 +115,20 @@ int main(int argc, char** argv) { std::set types; types.insert(grpc::testing::ReportType::REPORT_ALL); - reporters_registry.Report({client_config, server_config, result}, types); + for (const auto& reporter : reporters) { + reporter->Report({client_config, server_config, result}, types); + } +} + +} // namespace testing +} // namespace grpc + +int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + const auto& reporters = grpc::testing::InitBenchmarkReporters(); + + signal(SIGPIPE, SIG_IGN); + grpc::testing::QpsDriver(reporters); return 0; } diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index 2f72519397d..869ec19179c 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -39,6 +39,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -46,12 +47,9 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunQPS() { +static void RunQPS(const std::vector >& reporters) { gpr_log(GPR_INFO, "Running QPS test"); - ReportersRegistry reporters_registry; - reporters_registry.Register(new GprLogReporter("LogReporter")); - ClientConfig client_config; client_config.set_client_type(ASYNC_CLIENT); client_config.set_enable_ssl(false); @@ -72,16 +70,20 @@ static void RunQPS() { std::set types; types.insert(grpc::testing::ReportType::REPORT_QPS_PER_CORE); types.insert(grpc::testing::ReportType::REPORT_LATENCY); - reporters_registry.Report({client_config, server_config, result}, types); - + for (const auto& reporter : reporters) { + reporter->Report({client_config, server_config, result}, types); + } } } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + const auto& reporters = grpc::testing::InitBenchmarkReporters(); + signal(SIGPIPE, SIG_IGN); - grpc::testing::RunQPS(); + grpc::testing::RunQPS(reporters); return 0; } diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 72b3a3643d5..55726fbd00a 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -39,26 +39,6 @@ namespace grpc { namespace testing { -// ReporterRegistry implementation. -void ReportersRegistry::Register(const Reporter* reporter) { - reporters_.emplace_back(reporter); -} - -std::vector ReportersRegistry::GetNamesRegistered() const { - std::vector names; - for (const auto& reporter : reporters_) { - names.push_back(reporter->name()); - } - return names; -} - -void ReportersRegistry::Report(const ReportData& data, - const std::set& types) const { - for (const auto& reporter : reporters_) { - reporter->Report(data, types); - } -} - // Reporter implementation. void Reporter::Report(const ReportData& data, const std::set& types) const { diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index e62b9deb32b..64e92b1e890 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -71,30 +71,6 @@ enum ReportType { class Reporter; -/** A registry of Reporter instances. - * - * Instances registered will be taken into account by the Report() method. - */ -class ReportersRegistry { - public: - /** Adds the \c reporter to the registry. - * \attention Takes ownership of \c reporter. */ - void Register(const Reporter* reporter); - - /** Returns the names of the registered \c Reporter instances. */ - std::vector GetNamesRegistered() const; - - /** Triggers the reporting for all registered \c Reporter instances. - * - * \param data Configuration and results for the scenario being reported. - * \param types A collection of report types to include in the report. */ - void Report(const ReportData& data, - const std::set& types) const; - - private: - std::vector > reporters_; -}; - /** Interface for all reporters. */ class Reporter { public: diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index ddc1573bfdd..b17a3f6e483 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -39,6 +39,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -46,12 +47,10 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunSynchronousStreamingPingPong() { +static void RunSynchronousStreamingPingPong( + const std::vector >& reporters) { gpr_log(GPR_INFO, "Running Synchronous Streaming Ping Pong"); - ReportersRegistry reporters_registry; - reporters_registry.Register(new GprLogReporter("LogReporter")); - ClientConfig client_config; client_config.set_client_type(SYNCHRONOUS_CLIENT); client_config.set_enable_ssl(false); @@ -71,16 +70,19 @@ static void RunSynchronousStreamingPingPong() { std::set types; types.insert(grpc::testing::ReportType::REPORT_QPS); types.insert(grpc::testing::ReportType::REPORT_LATENCY); - reporters_registry.Report({client_config, server_config, result}, types); - + for (const auto& reporter : reporters) { + reporter->Report({client_config, server_config, result}, types); + } } - } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + const auto& reporters = grpc::testing::InitBenchmarkReporters(); + signal(SIGPIPE, SIG_IGN); - grpc::testing::RunSynchronousStreamingPingPong(); + grpc::testing::RunSynchronousStreamingPingPong(reporters); return 0; } diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index a1bd1f1705d..ff4038a3860 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -39,6 +39,7 @@ #include "test/cpp/qps/driver.h" #include "test/cpp/qps/report.h" +#include "test/cpp/util/benchmark_config.h" namespace grpc { namespace testing { @@ -46,7 +47,8 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunSynchronousUnaryPingPong() { +static void RunSynchronousUnaryPingPong( + const std::vector >& reporters) { gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong"); ReportersRegistry reporters_registry; @@ -71,15 +73,20 @@ static void RunSynchronousUnaryPingPong() { std::set types; types.insert(grpc::testing::ReportType::REPORT_QPS); types.insert(grpc::testing::ReportType::REPORT_LATENCY); - reporters_registry.Report({client_config, server_config, result}, types); + for (const auto& reporter : reporters) { + reporter->Report({client_config, server_config, result}, types); + } } } // namespace testing } // namespace grpc int main(int argc, char** argv) { + grpc::testing::InitBenchmark(&argc, &argv, true); + const auto& reporters = grpc::testing::InitBenchmarkReporters(); + signal(SIGPIPE, SIG_IGN); - grpc::testing::RunSynchronousUnaryPingPong(); + grpc::testing::RunSynchronousUnaryPingPong(reporters); return 0; } From 87ca82768dda5b32774f7ec49d279be01c79e4d6 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 19 May 2015 15:51:14 -0700 Subject: [PATCH 08/21] Added missing benchmark_config.* files --- test/cpp/qps/report.h | 2 + test/cpp/util/benchmark_config.cc | 63 +++++++++++++++++++++++++++++++ test/cpp/util/benchmark_config.h | 51 +++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 test/cpp/util/benchmark_config.cc create mode 100644 test/cpp/util/benchmark_config.h diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 64e92b1e890..b28506cba3e 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -88,9 +88,11 @@ class Reporter { protected: /** Reports QPS for the given \a result. */ virtual void ReportQPS(const ScenarioResult& result) const = 0; + /** Reports QPS per core as (YYY/server core). */ virtual void ReportQPSPerCore(const ScenarioResult& result, const ServerConfig& config) const = 0; + /** Reports latencies for the 50, 90, 95, 99 and 99.9 percentiles, in ms. */ virtual void ReportLatency(const ScenarioResult& result) const = 0; diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc new file mode 100644 index 00000000000..1f019c9715e --- /dev/null +++ b/test/cpp/util/benchmark_config.cc @@ -0,0 +1,63 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include "test/cpp/util/benchmark_config.h" + +DEFINE_bool(enable_log_reporter, false, + "Enable reporting of benchmark results through GprLog"); + +// In some distros, gflags is in the namespace google, and in some others, +// in gflags. This hack is enabling us to find both. +namespace google {} +namespace gflags {} +using namespace google; +using namespace gflags; + +namespace grpc { +namespace testing { + +void InitBenchmark(int* argc, char*** argv, bool remove_flags) { + ParseCommandLineFlags(argc, argv, remove_flags); +} + +std::vector > InitBenchmarkReporters() { + std::vector > reporters; + if (FLAGS_enable_log_reporter) { + reporters.emplace_back(new GprLogReporter("LogReporter")); + } + return reporters; +} + +} // namespace testing +} // namespace grpc diff --git a/test/cpp/util/benchmark_config.h b/test/cpp/util/benchmark_config.h new file mode 100644 index 00000000000..efbcad88f07 --- /dev/null +++ b/test/cpp/util/benchmark_config.h @@ -0,0 +1,51 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_TEST_CPP_UTIL_BENCHMARK_CONFIG_H +#define GRPC_TEST_CPP_UTIL_BENCHMARK_CONFIG_H + +#include +#include + +#include "test/cpp/qps/report.h" + +namespace grpc { +namespace testing { + +void InitBenchmark(int* argc, char*** argv, bool remove_flags); +std::vector > InitBenchmarkReporters(); + +} // namespace testing +} // namespace grpc + +#endif // GRPC_TEST_CPP_UTIL_BENCHMARK_CONFIG_H From 226beffea1fe772e172b6eb3125b096d0d11b2b2 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 19 May 2015 16:55:08 -0700 Subject: [PATCH 09/21] Simplified code based on comments and fixed build.json --- Makefile | 3 +- build.json | 2 +- .../cpp/qps/async_streaming_ping_pong_test.cc | 6 ++-- test/cpp/qps/async_unary_ping_pong_test.cc | 6 ++-- test/cpp/qps/qps_driver.cc | 8 ++--- test/cpp/qps/qps_test.cc | 6 ++-- test/cpp/qps/report.cc | 26 --------------- test/cpp/qps/report.h | 33 ------------------- test/cpp/qps/sync_streaming_ping_pong_test.cc | 6 ++-- test/cpp/qps/sync_unary_ping_pong_test.cc | 9 ++--- test/cpp/util/benchmark_config.cc | 2 +- 11 files changed, 17 insertions(+), 90 deletions(-) diff --git a/Makefile b/Makefile index 6017455a4a2..f2473f3518f 100644 --- a/Makefile +++ b/Makefile @@ -3199,6 +3199,7 @@ endif LIBGRPC++_BENCHMARK_CONFIG_SRC = \ + test/cpp/qps/report.cc \ test/cpp/util/benchmark_config.cc \ @@ -3756,7 +3757,6 @@ LIBQPS_SRC = \ test/cpp/qps/client_sync.cc \ test/cpp/qps/driver.cc \ test/cpp/qps/qps_worker.cc \ - test/cpp/qps/report.cc \ test/cpp/qps/server_async.cc \ test/cpp/qps/server_sync.cc \ test/cpp/qps/timer.cc \ @@ -3807,7 +3807,6 @@ $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_async.o: $(GENDIR)/test/cpp/qps/qpstest. $(OBJDIR)/$(CONFIG)/test/cpp/qps/client_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/driver.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/qps_worker.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc -$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_async.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/server_sync.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc $(OBJDIR)/$(CONFIG)/test/cpp/qps/timer.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc diff --git a/build.json b/build.json index 4952b890a9f..a3595f1357c 100644 --- a/build.json +++ b/build.json @@ -530,6 +530,7 @@ "build": "private", "language": "c++", "src": [ + "test/cpp/qps/report.cc", "test/cpp/util/benchmark_config.cc" ] }, @@ -701,7 +702,6 @@ "test/cpp/qps/client_sync.cc", "test/cpp/qps/driver.cc", "test/cpp/qps/qps_worker.cc", - "test/cpp/qps/report.cc", "test/cpp/qps/server_async.cc", "test/cpp/qps/server_sync.cc", "test/cpp/qps/timer.cc" diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc index c7367d876d8..8cb0949bb4d 100644 --- a/test/cpp/qps/async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/async_streaming_ping_pong_test.cc @@ -68,11 +68,9 @@ static void RunAsyncStreamingPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - std::set types; - types.insert(grpc::testing::ReportType::REPORT_QPS); - types.insert(grpc::testing::ReportType::REPORT_LATENCY); for (const auto& reporter : reporters) { - reporter->Report({client_config, server_config, result}, types); + reporter->ReportQPS(result); + reporter->ReportLatency(result); } } diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc index 50e824bf0ea..997cbced302 100644 --- a/test/cpp/qps/async_unary_ping_pong_test.cc +++ b/test/cpp/qps/async_unary_ping_pong_test.cc @@ -68,11 +68,9 @@ static void RunAsyncUnaryPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - std::set types; - types.insert(grpc::testing::ReportType::REPORT_QPS); - types.insert(grpc::testing::ReportType::REPORT_LATENCY); for (const auto& reporter : reporters) { - reporter->Report({client_config, server_config, result}, types); + reporter->ReportQPS(result); + reporter->ReportLatency(result); } } } // namespace testing diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index b06b88d8a0b..1f17424fad0 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -70,7 +70,6 @@ using grpc::testing::ClientType; using grpc::testing::ServerType; using grpc::testing::RpcType; using grpc::testing::ResourceUsage; -using grpc::testing::ReportType; namespace grpc { namespace testing { @@ -113,10 +112,11 @@ static void QpsDriver( client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, FLAGS_warmup_seconds, FLAGS_benchmark_seconds, FLAGS_local_workers); - std::set types; - types.insert(grpc::testing::ReportType::REPORT_ALL); for (const auto& reporter : reporters) { - reporter->Report({client_config, server_config, result}, types); + reporter->ReportQPS(result); + reporter->ReportQPSPerCore(result, server_config); + reporter->ReportLatency(result); + reporter->ReportTimes(result); } } diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index 869ec19179c..92940795a7a 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -67,11 +67,9 @@ static void RunQPS(const std::vector >& reporters) { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - std::set types; - types.insert(grpc::testing::ReportType::REPORT_QPS_PER_CORE); - types.insert(grpc::testing::ReportType::REPORT_LATENCY); for (const auto& reporter : reporters) { - reporter->Report({client_config, server_config, result}, types); + reporter->ReportQPSPerCore(result, server_config); + reporter->ReportLatency(result); } } diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 55726fbd00a..9c4bb0d9541 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -39,32 +39,6 @@ namespace grpc { namespace testing { -// Reporter implementation. -void Reporter::Report(const ReportData& data, - const std::set& types) const { - for (ReportType rtype : types) { - bool all = false; - switch (rtype) { - case REPORT_ALL: - all = true; - case REPORT_QPS: - ReportQPS(data.scenario_result); - if (!all) break; - case REPORT_QPS_PER_CORE: - ReportQPSPerCore(data.scenario_result, data.server_config); - if (!all) break; - case REPORT_LATENCY: - ReportLatency(data.scenario_result); - if (!all) break; - case REPORT_TIMES: - ReportTimes(data.scenario_result); - if (!all) break; - } - if (all) break; - } -} - -// GprLogReporter implementation. void GprLogReporter::ReportQPS(const ScenarioResult& result) const { gpr_log(GPR_INFO, "QPS: %.1f", result.latencies.Count() / diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index b28506cba3e..32b948c34f9 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -45,32 +45,6 @@ namespace grpc { namespace testing { -/** General set of data required for report generation. */ -struct ReportData { - const ClientConfig& client_config; - const ServerConfig& server_config; - const ScenarioResult& scenario_result; -}; - -/** Specifies the type of performance report we are interested in. - * - * \note The special type \c REPORT_ALL is equivalent to specifying all the - * other fields. */ -enum ReportType { - /** Equivalent to the combination of all other fields. */ - REPORT_ALL, - /** Report only QPS information. */ - REPORT_QPS, - /** Report only QPS per core information. */ - REPORT_QPS_PER_CORE, - /** Report latency info for the 50, 90, 95, 99 and 99.9th percentiles. */ - REPORT_LATENCY, - /** Report user and system time. */ - REPORT_TIMES -}; - -class Reporter; - /** Interface for all reporters. */ class Reporter { public: @@ -82,10 +56,6 @@ class Reporter { * Names are constants, set at construction time. */ string name() const { return name_; } - /** Template method responsible for the generation of the requested types. */ - void Report(const ReportData& data, const std::set& types) const; - - protected: /** Reports QPS for the given \a result. */ virtual void ReportQPS(const ScenarioResult& result) const = 0; @@ -103,9 +73,6 @@ class Reporter { const string name_; }; - -// Reporters. - /** Reporter to gpr_log(GPR_INFO). */ class GprLogReporter : public Reporter { public: diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index b17a3f6e483..6da107aa732 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -67,11 +67,9 @@ static void RunSynchronousStreamingPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - std::set types; - types.insert(grpc::testing::ReportType::REPORT_QPS); - types.insert(grpc::testing::ReportType::REPORT_LATENCY); for (const auto& reporter : reporters) { - reporter->Report({client_config, server_config, result}, types); + reporter->ReportQPS(result); + reporter->ReportLatency(result); } } } // namespace testing diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index ff4038a3860..eb930def2a2 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -51,9 +51,6 @@ static void RunSynchronousUnaryPingPong( const std::vector >& reporters) { gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong"); - ReportersRegistry reporters_registry; - reporters_registry.Register(new GprLogReporter("LogReporter")); - ClientConfig client_config; client_config.set_client_type(SYNCHRONOUS_CLIENT); client_config.set_enable_ssl(false); @@ -70,11 +67,9 @@ static void RunSynchronousUnaryPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - std::set types; - types.insert(grpc::testing::ReportType::REPORT_QPS); - types.insert(grpc::testing::ReportType::REPORT_LATENCY); for (const auto& reporter : reporters) { - reporter->Report({client_config, server_config, result}, types); + reporter->ReportQPS(result); + reporter->ReportLatency(result); } } diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 1f019c9715e..914afa91ca1 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -34,7 +34,7 @@ #include #include "test/cpp/util/benchmark_config.h" -DEFINE_bool(enable_log_reporter, false, +DEFINE_bool(enable_log_reporter, true, "Enable reporting of benchmark results through GprLog"); // In some distros, gflags is in the namespace google, and in some others, From a6b559a76ae3d96f8df4abe07173c8b56fbfc032 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 20 May 2015 22:08:24 -0700 Subject: [PATCH 10/21] Improvements to reporting mechanism based on comments. Turned the reporter into a composite, much cleaner arch. --- .../cpp/qps/async_streaming_ping_pong_test.cc | 12 +++----- test/cpp/qps/async_unary_ping_pong_test.cc | 12 +++----- test/cpp/qps/qps_driver.cc | 16 ++++------ test/cpp/qps/qps_test.cc | 11 +++---- test/cpp/qps/report.cc | 30 +++++++++++++++++++ test/cpp/qps/report.h | 20 +++++++++++++ test/cpp/qps/sync_streaming_ping_pong_test.cc | 12 +++----- test/cpp/qps/sync_unary_ping_pong_test.cc | 12 +++----- test/cpp/util/benchmark_config.cc | 14 ++++++--- test/cpp/util/benchmark_config.h | 8 ++++- 10 files changed, 93 insertions(+), 54 deletions(-) diff --git a/test/cpp/qps/async_streaming_ping_pong_test.cc b/test/cpp/qps/async_streaming_ping_pong_test.cc index 8cb0949bb4d..dc972443ff6 100644 --- a/test/cpp/qps/async_streaming_ping_pong_test.cc +++ b/test/cpp/qps/async_streaming_ping_pong_test.cc @@ -47,8 +47,7 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunAsyncStreamingPingPong( - const std::vector >& reporters) { +static void RunAsyncStreamingPingPong() { gpr_log(GPR_INFO, "Running Async Streaming Ping Pong"); ClientConfig client_config; @@ -68,10 +67,8 @@ static void RunAsyncStreamingPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - for (const auto& reporter : reporters) { - reporter->ReportQPS(result); - reporter->ReportLatency(result); - } + GetReporter()->ReportQPS(result); + GetReporter()->ReportLatency(result); } } // namespace testing @@ -79,9 +76,8 @@ static void RunAsyncStreamingPingPong( int main(int argc, char** argv) { grpc::testing::InitBenchmark(&argc, &argv, true); - const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunAsyncStreamingPingPong(reporters); + grpc::testing::RunAsyncStreamingPingPong(); return 0; } diff --git a/test/cpp/qps/async_unary_ping_pong_test.cc b/test/cpp/qps/async_unary_ping_pong_test.cc index 997cbced302..05bc08a3200 100644 --- a/test/cpp/qps/async_unary_ping_pong_test.cc +++ b/test/cpp/qps/async_unary_ping_pong_test.cc @@ -47,8 +47,7 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunAsyncUnaryPingPong( - const std::vector >& reporters) { +static void RunAsyncUnaryPingPong() { gpr_log(GPR_INFO, "Running Async Unary Ping Pong"); ClientConfig client_config; @@ -68,19 +67,16 @@ static void RunAsyncUnaryPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - for (const auto& reporter : reporters) { - reporter->ReportQPS(result); - reporter->ReportLatency(result); - } + GetReporter()->ReportQPS(result); + GetReporter()->ReportLatency(result); } } // namespace testing } // namespace grpc int main(int argc, char** argv) { grpc::testing::InitBenchmark(&argc, &argv, true); - const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunAsyncUnaryPingPong(reporters); + grpc::testing::RunAsyncUnaryPingPong(); return 0; } diff --git a/test/cpp/qps/qps_driver.cc b/test/cpp/qps/qps_driver.cc index 1f17424fad0..2e491eeb05d 100644 --- a/test/cpp/qps/qps_driver.cc +++ b/test/cpp/qps/qps_driver.cc @@ -74,8 +74,7 @@ using grpc::testing::ResourceUsage; namespace grpc { namespace testing { -static void QpsDriver( - const std::vector >& reporters) { +static void QpsDriver() { RpcType rpc_type; GPR_ASSERT(RpcType_Parse(FLAGS_rpc_type, &rpc_type)); @@ -112,12 +111,10 @@ static void QpsDriver( client_config, FLAGS_num_clients, server_config, FLAGS_num_servers, FLAGS_warmup_seconds, FLAGS_benchmark_seconds, FLAGS_local_workers); - for (const auto& reporter : reporters) { - reporter->ReportQPS(result); - reporter->ReportQPSPerCore(result, server_config); - reporter->ReportLatency(result); - reporter->ReportTimes(result); - } + GetReporter()->ReportQPS(result); + GetReporter()->ReportQPSPerCore(result, server_config); + GetReporter()->ReportLatency(result); + GetReporter()->ReportTimes(result); } } // namespace testing @@ -125,10 +122,9 @@ static void QpsDriver( int main(int argc, char** argv) { grpc::testing::InitBenchmark(&argc, &argv, true); - const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::QpsDriver(reporters); + grpc::testing::QpsDriver(); return 0; } diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc index 92940795a7a..03c9c2c4238 100644 --- a/test/cpp/qps/qps_test.cc +++ b/test/cpp/qps/qps_test.cc @@ -47,7 +47,7 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunQPS(const std::vector >& reporters) { +static void RunQPS() { gpr_log(GPR_INFO, "Running QPS test"); ClientConfig client_config; @@ -67,10 +67,8 @@ static void RunQPS(const std::vector >& reporters) { const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - for (const auto& reporter : reporters) { - reporter->ReportQPSPerCore(result, server_config); - reporter->ReportLatency(result); - } + GetReporter()->ReportQPSPerCore(result, server_config); + GetReporter()->ReportLatency(result); } } // namespace testing @@ -78,10 +76,9 @@ static void RunQPS(const std::vector >& reporters) { int main(int argc, char** argv) { grpc::testing::InitBenchmark(&argc, &argv, true); - const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunQPS(reporters); + grpc::testing::RunQPS(); return 0; } diff --git a/test/cpp/qps/report.cc b/test/cpp/qps/report.cc index 9c4bb0d9541..e116175e3b3 100644 --- a/test/cpp/qps/report.cc +++ b/test/cpp/qps/report.cc @@ -39,6 +39,36 @@ namespace grpc { namespace testing { +void CompositeReporter::add(std::unique_ptr reporter) { + reporters_.emplace_back(std::move(reporter)); +} + +void CompositeReporter::ReportQPS(const ScenarioResult& result) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportQPS(result); + } +} + +void CompositeReporter::ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportQPSPerCore(result, config); + } +} + +void CompositeReporter::ReportLatency(const ScenarioResult& result) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportLatency(result); + } +} + +void CompositeReporter::ReportTimes(const ScenarioResult& result) const { + for (size_t i = 0; i < reporters_.size(); ++i) { + reporters_[i]->ReportTimes(result); + } +} + + void GprLogReporter::ReportQPS(const ScenarioResult& result) const { gpr_log(GPR_INFO, "QPS: %.1f", result.latencies.Count() / diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 32b948c34f9..3712f67a47b 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -51,6 +51,8 @@ class Reporter { /** Construct a reporter with the given \a name. */ Reporter(const string& name) : name_(name) {} + virtual ~Reporter() {} + /** Returns this reporter's name. * * Names are constants, set at construction time. */ @@ -73,6 +75,24 @@ class Reporter { const string name_; }; +/** A composite for all reporters to be considered. */ +class CompositeReporter : public Reporter { + public: + CompositeReporter() : Reporter("CompositeReporter") {} + + /** Adds a \a reporter to the composite. */ + void add(std::unique_ptr reporter); + + void ReportQPS(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportQPSPerCore(const ScenarioResult& result, + const ServerConfig& config) const GRPC_OVERRIDE; + void ReportLatency(const ScenarioResult& result) const GRPC_OVERRIDE; + void ReportTimes(const ScenarioResult& result) const GRPC_OVERRIDE; + + private: + std::vector > reporters_; +}; + /** Reporter to gpr_log(GPR_INFO). */ class GprLogReporter : public Reporter { public: diff --git a/test/cpp/qps/sync_streaming_ping_pong_test.cc b/test/cpp/qps/sync_streaming_ping_pong_test.cc index 6da107aa732..776fbdde1c0 100644 --- a/test/cpp/qps/sync_streaming_ping_pong_test.cc +++ b/test/cpp/qps/sync_streaming_ping_pong_test.cc @@ -47,8 +47,7 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunSynchronousStreamingPingPong( - const std::vector >& reporters) { +static void RunSynchronousStreamingPingPong() { gpr_log(GPR_INFO, "Running Synchronous Streaming Ping Pong"); ClientConfig client_config; @@ -67,20 +66,17 @@ static void RunSynchronousStreamingPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - for (const auto& reporter : reporters) { - reporter->ReportQPS(result); - reporter->ReportLatency(result); - } + GetReporter()->ReportQPS(result); + GetReporter()->ReportLatency(result); } } // namespace testing } // namespace grpc int main(int argc, char** argv) { grpc::testing::InitBenchmark(&argc, &argv, true); - const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunSynchronousStreamingPingPong(reporters); + grpc::testing::RunSynchronousStreamingPingPong(); return 0; } diff --git a/test/cpp/qps/sync_unary_ping_pong_test.cc b/test/cpp/qps/sync_unary_ping_pong_test.cc index eb930def2a2..e79b820ce38 100644 --- a/test/cpp/qps/sync_unary_ping_pong_test.cc +++ b/test/cpp/qps/sync_unary_ping_pong_test.cc @@ -47,8 +47,7 @@ namespace testing { static const int WARMUP = 5; static const int BENCHMARK = 10; -static void RunSynchronousUnaryPingPong( - const std::vector >& reporters) { +static void RunSynchronousUnaryPingPong() { gpr_log(GPR_INFO, "Running Synchronous Unary Ping Pong"); ClientConfig client_config; @@ -67,10 +66,8 @@ static void RunSynchronousUnaryPingPong( const auto result = RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2); - for (const auto& reporter : reporters) { - reporter->ReportQPS(result); - reporter->ReportLatency(result); - } + GetReporter()->ReportQPS(result); + GetReporter()->ReportLatency(result); } } // namespace testing @@ -78,10 +75,9 @@ static void RunSynchronousUnaryPingPong( int main(int argc, char** argv) { grpc::testing::InitBenchmark(&argc, &argv, true); - const auto& reporters = grpc::testing::InitBenchmarkReporters(); signal(SIGPIPE, SIG_IGN); - grpc::testing::RunSynchronousUnaryPingPong(reporters); + grpc::testing::RunSynchronousUnaryPingPong(); return 0; } diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 914afa91ca1..1b15ddcbcc8 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -51,12 +51,18 @@ void InitBenchmark(int* argc, char*** argv, bool remove_flags) { ParseCommandLineFlags(argc, argv, remove_flags); } -std::vector > InitBenchmarkReporters() { - std::vector > reporters; +static std::shared_ptr InitBenchmarkReporters() { + auto* composite_reporter = new CompositeReporter; if (FLAGS_enable_log_reporter) { - reporters.emplace_back(new GprLogReporter("LogReporter")); + composite_reporter->add( + std::unique_ptr(new GprLogReporter("LogReporter"))); } - return reporters; + return std::shared_ptr(composite_reporter); +} + +const std::shared_ptr& GetReporter() { + static std::shared_ptr reporter(InitBenchmarkReporters()); + return reporter; } } // namespace testing diff --git a/test/cpp/util/benchmark_config.h b/test/cpp/util/benchmark_config.h index efbcad88f07..3a3a6d61ae6 100644 --- a/test/cpp/util/benchmark_config.h +++ b/test/cpp/util/benchmark_config.h @@ -43,7 +43,13 @@ namespace grpc { namespace testing { void InitBenchmark(int* argc, char*** argv, bool remove_flags); -std::vector > InitBenchmarkReporters(); + +/** Returns the benchmark Reporter instance. + * + * The returned instane will take care of generating reports for all the actual + * reporters configured via the "enable_*_reporter" command line flags (see + * benchmark_config.cc). */ +const std::shared_ptr& GetReporter(); } // namespace testing } // namespace grpc From 30ecd2b8d901ddfbaa1b607fa514e96e5f49cb11 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 20 May 2015 23:06:44 -0700 Subject: [PATCH 11/21] Return shared_ptr by value plus minor dependency fix --- Makefile | 3 +++ build.json | 1 + test/cpp/qps/report.h | 2 +- test/cpp/util/benchmark_config.cc | 2 +- test/cpp/util/benchmark_config.h | 2 +- 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index f2473f3518f..fc742bc785d 100644 --- a/Makefile +++ b/Makefile @@ -3199,6 +3199,7 @@ endif LIBGRPC++_BENCHMARK_CONFIG_SRC = \ + $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc \ test/cpp/qps/report.cc \ test/cpp/util/benchmark_config.cc \ @@ -3244,6 +3245,8 @@ ifneq ($(NO_DEPS),true) -include $(LIBGRPC++_BENCHMARK_CONFIG_OBJS:.o=.dep) endif endif +$(OBJDIR)/$(CONFIG)/test/cpp/qps/report.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc +$(OBJDIR)/$(CONFIG)/test/cpp/util/benchmark_config.o: $(GENDIR)/test/cpp/qps/qpstest.pb.cc $(GENDIR)/test/cpp/qps/qpstest.grpc.pb.cc LIBGRPC++_TEST_CONFIG_SRC = \ diff --git a/build.json b/build.json index a3595f1357c..4e6accd0203 100644 --- a/build.json +++ b/build.json @@ -530,6 +530,7 @@ "build": "private", "language": "c++", "src": [ + "test/cpp/qps/qpstest.proto", "test/cpp/qps/report.cc", "test/cpp/util/benchmark_config.cc" ] diff --git a/test/cpp/qps/report.h b/test/cpp/qps/report.h index 3712f67a47b..630275ecda2 100644 --- a/test/cpp/qps/report.h +++ b/test/cpp/qps/report.h @@ -63,7 +63,7 @@ class Reporter { /** Reports QPS per core as (YYY/server core). */ virtual void ReportQPSPerCore(const ScenarioResult& result, - const ServerConfig& config) const = 0; + const ServerConfig& config) const = 0; /** Reports latencies for the 50, 90, 95, 99 and 99.9 percentiles, in ms. */ virtual void ReportLatency(const ScenarioResult& result) const = 0; diff --git a/test/cpp/util/benchmark_config.cc b/test/cpp/util/benchmark_config.cc index 1b15ddcbcc8..5b3c1daf5db 100644 --- a/test/cpp/util/benchmark_config.cc +++ b/test/cpp/util/benchmark_config.cc @@ -60,7 +60,7 @@ static std::shared_ptr InitBenchmarkReporters() { return std::shared_ptr(composite_reporter); } -const std::shared_ptr& GetReporter() { +std::shared_ptr GetReporter() { static std::shared_ptr reporter(InitBenchmarkReporters()); return reporter; } diff --git a/test/cpp/util/benchmark_config.h b/test/cpp/util/benchmark_config.h index 3a3a6d61ae6..9e98dc3550f 100644 --- a/test/cpp/util/benchmark_config.h +++ b/test/cpp/util/benchmark_config.h @@ -49,7 +49,7 @@ void InitBenchmark(int* argc, char*** argv, bool remove_flags); * The returned instane will take care of generating reports for all the actual * reporters configured via the "enable_*_reporter" command line flags (see * benchmark_config.cc). */ -const std::shared_ptr& GetReporter(); +std::shared_ptr GetReporter(); } // namespace testing } // namespace grpc From 1d780fd3df602d5291ad30d52fd5360810a3ac03 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 22 May 2015 10:37:27 -0700 Subject: [PATCH 12/21] Fixed typo --- test/cpp/util/benchmark_config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cpp/util/benchmark_config.h b/test/cpp/util/benchmark_config.h index 9e98dc3550f..6b308a15ff4 100644 --- a/test/cpp/util/benchmark_config.h +++ b/test/cpp/util/benchmark_config.h @@ -46,7 +46,7 @@ void InitBenchmark(int* argc, char*** argv, bool remove_flags); /** Returns the benchmark Reporter instance. * - * The returned instane will take care of generating reports for all the actual + * The returned instance will take care of generating reports for all the actual * reporters configured via the "enable_*_reporter" command line flags (see * benchmark_config.cc). */ std::shared_ptr GetReporter(); From 8ed4c3e2675ba27dab0b198ba650d902c5db7748 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 27 May 2015 09:01:17 -0700 Subject: [PATCH 13/21] provide VS solution for building protoc plugins --- build.json | 18 +- templates/vsprojects/grpc.sln.template | 49 +---- .../grpc_cpp_plugin.vcxproj.template | 2 + .../grpc_csharp_plugin.vcxproj.template | 2 + .../grpc_objective_c_plugin.vcxproj.template | 2 + .../grpc_plugin_support.vcxproj.template | 2 + .../grpc_protoc_plugins.sln.template | 5 + .../grpc_python_plugin.vcxproj.template | 2 + .../grpc_ruby_plugin.vcxproj.template | 2 + templates/vsprojects/sln_defs.include | 50 +++++ templates/vsprojects/vcxproj_defs.include | 5 +- tools/buildgen/plugins/generate_vsprojects.py | 2 +- .../grpc_cpp_plugin/grpc_cpp_plugin.vcxproj | 169 +++++++++++++++++ .../grpc_csharp_plugin.vcxproj | 169 +++++++++++++++++ .../grpc_objective_c_plugin.vcxproj | 169 +++++++++++++++++ .../grpc_plugin_support.vcxproj | 179 ++++++++++++++++++ vsprojects/grpc_protoc_plugins.sln | 93 +++++++++ .../grpc_python_plugin.vcxproj | 169 +++++++++++++++++ .../grpc_ruby_plugin/grpc_ruby_plugin.vcxproj | 169 +++++++++++++++++ vsprojects/protoc.props | 13 ++ 20 files changed, 1217 insertions(+), 54 deletions(-) create mode 100644 templates/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj.template create mode 100644 templates/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj.template create mode 100644 templates/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj.template create mode 100644 templates/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj.template create mode 100644 templates/vsprojects/grpc_protoc_plugins.sln.template create mode 100644 templates/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj.template create mode 100644 templates/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj.template create mode 100644 templates/vsprojects/sln_defs.include create mode 100644 vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj create mode 100644 vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj create mode 100644 vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj create mode 100644 vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj create mode 100644 vsprojects/grpc_protoc_plugins.sln create mode 100644 vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj create mode 100644 vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj create mode 100644 vsprojects/protoc.props diff --git a/build.json b/build.json index b893692205c..1ad49adc3f9 100644 --- a/build.json +++ b/build.json @@ -589,7 +589,8 @@ "src/compiler/ruby_generator.cc" ], "deps": [], - "secure": "no" + "secure": "no", + "vs_project_guid": "{B6E81D84-2ACB-41B8-8781-493A944C7817}" }, { "name": "interop_client_helper", @@ -1995,7 +1996,8 @@ "deps": [ "grpc_plugin_support" ], - "secure": "no" + "secure": "no", + "vs_project_guid": "{7E51A25F-AC59-488F-906C-C60FAAE706AA}" }, { "name": "grpc_csharp_plugin", @@ -2007,7 +2009,8 @@ "deps": [ "grpc_plugin_support" ], - "secure": "no" + "secure": "no", + "vs_project_guid": "{3C813052-A49A-4662-B90A-1ADBEC7EE453}" }, { "name": "grpc_objective_c_plugin", @@ -2019,7 +2022,8 @@ "deps": [ "grpc_plugin_support" ], - "secure": "no" + "secure": "no", + "vs_project_guid": "{19564640-CEE6-4921-ABA5-676ED79A36F6}" }, { "name": "grpc_python_plugin", @@ -2031,7 +2035,8 @@ "deps": [ "grpc_plugin_support" ], - "secure": "no" + "secure": "no", + "vs_project_guid": "{DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}" }, { "name": "grpc_ruby_plugin", @@ -2043,7 +2048,8 @@ "deps": [ "grpc_plugin_support" ], - "secure": "no" + "secure": "no", + "vs_project_guid": "{069E9D05-B78B-4751-9252-D21EBAE7DE8E}" }, { "name": "interop_client", diff --git a/templates/vsprojects/grpc.sln.template b/templates/vsprojects/grpc.sln.template index 7465852e70b..70be6b4f7a3 100644 --- a/templates/vsprojects/grpc.sln.template +++ b/templates/vsprojects/grpc.sln.template @@ -1,48 +1,5 @@ -## Template for Visual Studio solution -## based on http://msdn.microsoft.com/en-us/library/bb165951(v=vs.90).aspx -## NOTE: tabs in this file are needed by Visual Studio to correctly interpret -## the file. - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 -MinimumVisualStudioVersion = 10.0.40219.1 +<%namespace file="sln_defs.include" import="gen_solution"/>\ <% -## Visual Studio uses GUIDs for project types -## http://msdn.microsoft.com/en-us/library/hb23x61k%28v=vs.80%29.aspx -cpp_proj_type = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" +solution_projects = [p for p in vsprojects if p.build != 'protoc'] %>\ -% for project in vsprojects: -Project("${cpp_proj_type}") = "${project.name}", "${project.name}\${project.name}.vcxproj", "${project.vs_project_guid}" - % if project.get('deps', None): - ProjectSection(ProjectDependencies) = postProject - % for dep in project.get('deps', []): - ${vsproject_dict[dep].vs_project_guid} = ${vsproject_dict[dep].vs_project_guid} - % endfor - EndProjectSection - % endif -EndProject -% endfor -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution -% for project in vsprojects: - ${project.vs_project_guid}.Debug|Win32.ActiveCfg = Debug|Win32 - ${project.vs_project_guid}.Debug|Win32.Build.0 = Debug|Win32 - ${project.vs_project_guid}.Debug|x64.ActiveCfg = Debug|x64 - ${project.vs_project_guid}.Debug|x64.Build.0 = Debug|x64 - ${project.vs_project_guid}.Release|Win32.ActiveCfg = Release|Win32 - ${project.vs_project_guid}.Release|Win32.Build.0 = Release|Win32 - ${project.vs_project_guid}.Release|x64.ActiveCfg = Release|x64 - ${project.vs_project_guid}.Release|x64.Build.0 = Release|x64 -% endfor - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +${gen_solution(solution_projects)} \ No newline at end of file diff --git a/templates/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj.template b/templates/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj.template new file mode 100644 index 00000000000..49ab1b73857 --- /dev/null +++ b/templates/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="../vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_cpp_plugin', targets, configuration_type='Application')} diff --git a/templates/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj.template b/templates/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj.template new file mode 100644 index 00000000000..9d94e27c3af --- /dev/null +++ b/templates/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="../vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_csharp_plugin', targets, configuration_type='Application')} diff --git a/templates/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj.template b/templates/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj.template new file mode 100644 index 00000000000..794c7310c55 --- /dev/null +++ b/templates/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="../vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_objective_c_plugin', targets, configuration_type='Application')} diff --git a/templates/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj.template b/templates/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj.template new file mode 100644 index 00000000000..409e88f2895 --- /dev/null +++ b/templates/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="../vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_plugin_support', libs)} diff --git a/templates/vsprojects/grpc_protoc_plugins.sln.template b/templates/vsprojects/grpc_protoc_plugins.sln.template new file mode 100644 index 00000000000..1c171f4f94e --- /dev/null +++ b/templates/vsprojects/grpc_protoc_plugins.sln.template @@ -0,0 +1,5 @@ +<%namespace file="sln_defs.include" import="gen_solution"/>\ +<% +solution_projects = [p for p in vsprojects if p.build == 'protoc'] +%>\ +${gen_solution(solution_projects)} \ No newline at end of file diff --git a/templates/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj.template b/templates/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj.template new file mode 100644 index 00000000000..977e015d6da --- /dev/null +++ b/templates/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="../vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_python_plugin', targets, configuration_type='Application')} diff --git a/templates/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj.template b/templates/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj.template new file mode 100644 index 00000000000..ecf42ae04ee --- /dev/null +++ b/templates/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj.template @@ -0,0 +1,2 @@ +<%namespace file="../vcxproj_defs.include" import="gen_project"/>\ +${gen_project('grpc_ruby_plugin', targets, configuration_type='Application')} diff --git a/templates/vsprojects/sln_defs.include b/templates/vsprojects/sln_defs.include new file mode 100644 index 00000000000..ee05d0fbde2 --- /dev/null +++ b/templates/vsprojects/sln_defs.include @@ -0,0 +1,50 @@ +<%def name="gen_solution(solution_projects)">\ +## Template for Visual Studio solution +## based on http://msdn.microsoft.com/en-us/library/bb165951(v=vs.90).aspx +## NOTE: tabs in this file are needed by Visual Studio to correctly interpret +## the file. + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +<% +## Visual Studio uses GUIDs for project types +## http://msdn.microsoft.com/en-us/library/hb23x61k%28v=vs.80%29.aspx +cpp_proj_type = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}" +%>\ +% for project in solution_projects: +Project("${cpp_proj_type}") = "${project.name}", "${project.name}\${project.name}.vcxproj", "${project.vs_project_guid}" + % if project.get('deps', None): + ProjectSection(ProjectDependencies) = postProject + % for dep in project.get('deps', []): + ${vsproject_dict[dep].vs_project_guid} = ${vsproject_dict[dep].vs_project_guid} + % endfor + EndProjectSection + % endif +EndProject +% endfor +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution +% for project in solution_projects: + ${project.vs_project_guid}.Debug|Win32.ActiveCfg = Debug|Win32 + ${project.vs_project_guid}.Debug|Win32.Build.0 = Debug|Win32 + ${project.vs_project_guid}.Debug|x64.ActiveCfg = Debug|x64 + ${project.vs_project_guid}.Debug|x64.Build.0 = Debug|x64 + ${project.vs_project_guid}.Release|Win32.ActiveCfg = Release|Win32 + ${project.vs_project_guid}.Release|Win32.Build.0 = Release|Win32 + ${project.vs_project_guid}.Release|x64.ActiveCfg = Release|x64 + ${project.vs_project_guid}.Release|x64.Build.0 = Release|x64 +% endfor + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal +\ \ No newline at end of file diff --git a/templates/vsprojects/vcxproj_defs.include b/templates/vsprojects/vcxproj_defs.include index 87412debda8..55ec37393fa 100644 --- a/templates/vsprojects/vcxproj_defs.include +++ b/templates/vsprojects/vcxproj_defs.include @@ -19,7 +19,10 @@ if not project_guid: project_guid = project.vs_project_guid if configuration_type == 'Application': - props.extend(['winsock', 'protobuf', 'zlib', 'openssl']) + if target.build == 'protoc': + props.extend(['protoc']) + else: + props.extend(['winsock', 'protobuf', 'zlib', 'openssl']) if target.language == 'c++': props.extend(['protobuf']) props.extend(['global']) diff --git a/tools/buildgen/plugins/generate_vsprojects.py b/tools/buildgen/plugins/generate_vsprojects.py index 09a5bdbcc86..150e72e0b26 100755 --- a/tools/buildgen/plugins/generate_vsprojects.py +++ b/tools/buildgen/plugins/generate_vsprojects.py @@ -70,7 +70,7 @@ def mako_plugin(dictionary): if project.get('vs_project_guid', None)] projects = [project for project in projects - if project['language'] != 'c++' or project['build'] == 'all'] + if project['language'] != 'c++' or project['build'] == 'all' or project['build'] == 'protoc'] project_dict = dict([(p['name'], p) for p in projects]) diff --git a/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj b/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj new file mode 100644 index 00000000000..d2669b44013 --- /dev/null +++ b/vsprojects/grpc_cpp_plugin/grpc_cpp_plugin.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {7E51A25F-AC59-488F-906C-C60FAAE706AA} + + + + v100 + + + v110 + + + v120 + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + grpc_cpp_plugin + + + grpc_cpp_plugin + + + grpc_cpp_plugin + + + grpc_cpp_plugin + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + + + + diff --git a/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj b/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj new file mode 100644 index 00000000000..10d1e968fcc --- /dev/null +++ b/vsprojects/grpc_csharp_plugin/grpc_csharp_plugin.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {3C813052-A49A-4662-B90A-1ADBEC7EE453} + + + + v100 + + + v110 + + + v120 + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + grpc_csharp_plugin + + + grpc_csharp_plugin + + + grpc_csharp_plugin + + + grpc_csharp_plugin + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + + + + diff --git a/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj b/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj new file mode 100644 index 00000000000..23affd158d6 --- /dev/null +++ b/vsprojects/grpc_objective_c_plugin/grpc_objective_c_plugin.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {19564640-CEE6-4921-ABA5-676ED79A36F6} + + + + v100 + + + v110 + + + v120 + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + grpc_objective_c_plugin + + + grpc_objective_c_plugin + + + grpc_objective_c_plugin + + + grpc_objective_c_plugin + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + + + + diff --git a/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj b/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj new file mode 100644 index 00000000000..c0188e56e70 --- /dev/null +++ b/vsprojects/grpc_plugin_support/grpc_plugin_support.vcxproj @@ -0,0 +1,179 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + v100 + + + v110 + + + v120 + + + StaticLibrary + true + Unicode + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + true + Unicode + + + StaticLibrary + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + grpc_plugin_support + + + grpc_plugin_support + + + grpc_plugin_support + + + grpc_plugin_support + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/vsprojects/grpc_protoc_plugins.sln b/vsprojects/grpc_protoc_plugins.sln new file mode 100644 index 00000000000..be3ccf9bbe1 --- /dev/null +++ b/vsprojects/grpc_protoc_plugins.sln @@ -0,0 +1,93 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.21005.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_plugin_support", "grpc_plugin_support\grpc_plugin_support.vcxproj", "{B6E81D84-2ACB-41B8-8781-493A944C7817}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_cpp_plugin", "grpc_cpp_plugin\grpc_cpp_plugin.vcxproj", "{7E51A25F-AC59-488F-906C-C60FAAE706AA}" + ProjectSection(ProjectDependencies) = postProject + {B6E81D84-2ACB-41B8-8781-493A944C7817} = {B6E81D84-2ACB-41B8-8781-493A944C7817} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_csharp_plugin", "grpc_csharp_plugin\grpc_csharp_plugin.vcxproj", "{3C813052-A49A-4662-B90A-1ADBEC7EE453}" + ProjectSection(ProjectDependencies) = postProject + {B6E81D84-2ACB-41B8-8781-493A944C7817} = {B6E81D84-2ACB-41B8-8781-493A944C7817} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_objective_c_plugin", "grpc_objective_c_plugin\grpc_objective_c_plugin.vcxproj", "{19564640-CEE6-4921-ABA5-676ED79A36F6}" + ProjectSection(ProjectDependencies) = postProject + {B6E81D84-2ACB-41B8-8781-493A944C7817} = {B6E81D84-2ACB-41B8-8781-493A944C7817} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_python_plugin", "grpc_python_plugin\grpc_python_plugin.vcxproj", "{DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}" + ProjectSection(ProjectDependencies) = postProject + {B6E81D84-2ACB-41B8-8781-493A944C7817} = {B6E81D84-2ACB-41B8-8781-493A944C7817} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_ruby_plugin", "grpc_ruby_plugin\grpc_ruby_plugin.vcxproj", "{069E9D05-B78B-4751-9252-D21EBAE7DE8E}" + ProjectSection(ProjectDependencies) = postProject + {B6E81D84-2ACB-41B8-8781-493A944C7817} = {B6E81D84-2ACB-41B8-8781-493A944C7817} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Debug|Win32.ActiveCfg = Debug|Win32 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Debug|Win32.Build.0 = Debug|Win32 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Debug|x64.ActiveCfg = Debug|x64 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Debug|x64.Build.0 = Debug|x64 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Release|Win32.ActiveCfg = Release|Win32 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Release|Win32.Build.0 = Release|Win32 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Release|x64.ActiveCfg = Release|x64 + {B6E81D84-2ACB-41B8-8781-493A944C7817}.Release|x64.Build.0 = Release|x64 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Debug|Win32.ActiveCfg = Debug|Win32 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Debug|Win32.Build.0 = Debug|Win32 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Debug|x64.ActiveCfg = Debug|x64 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Debug|x64.Build.0 = Debug|x64 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Release|Win32.ActiveCfg = Release|Win32 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Release|Win32.Build.0 = Release|Win32 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Release|x64.ActiveCfg = Release|x64 + {7E51A25F-AC59-488F-906C-C60FAAE706AA}.Release|x64.Build.0 = Release|x64 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Debug|Win32.ActiveCfg = Debug|Win32 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Debug|Win32.Build.0 = Debug|Win32 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Debug|x64.ActiveCfg = Debug|x64 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Debug|x64.Build.0 = Debug|x64 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Release|Win32.ActiveCfg = Release|Win32 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Release|Win32.Build.0 = Release|Win32 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Release|x64.ActiveCfg = Release|x64 + {3C813052-A49A-4662-B90A-1ADBEC7EE453}.Release|x64.Build.0 = Release|x64 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Debug|Win32.ActiveCfg = Debug|Win32 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Debug|Win32.Build.0 = Debug|Win32 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Debug|x64.ActiveCfg = Debug|x64 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Debug|x64.Build.0 = Debug|x64 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Release|Win32.ActiveCfg = Release|Win32 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Release|Win32.Build.0 = Release|Win32 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Release|x64.ActiveCfg = Release|x64 + {19564640-CEE6-4921-ABA5-676ED79A36F6}.Release|x64.Build.0 = Release|x64 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Debug|Win32.Build.0 = Debug|Win32 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Debug|x64.ActiveCfg = Debug|x64 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Debug|x64.Build.0 = Debug|x64 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Release|Win32.ActiveCfg = Release|Win32 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Release|Win32.Build.0 = Release|Win32 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Release|x64.ActiveCfg = Release|x64 + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2}.Release|x64.Build.0 = Release|x64 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Debug|Win32.ActiveCfg = Debug|Win32 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Debug|Win32.Build.0 = Debug|Win32 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Debug|x64.ActiveCfg = Debug|x64 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Debug|x64.Build.0 = Debug|x64 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Release|Win32.ActiveCfg = Release|Win32 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Release|Win32.Build.0 = Release|Win32 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Release|x64.ActiveCfg = Release|x64 + {069E9D05-B78B-4751-9252-D21EBAE7DE8E}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj b/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj new file mode 100644 index 00000000000..eadc0a070b5 --- /dev/null +++ b/vsprojects/grpc_python_plugin/grpc_python_plugin.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {DF52D501-A6CF-4E6F-BA38-6EBE2E8DAFB2} + + + + v100 + + + v110 + + + v120 + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + grpc_python_plugin + + + grpc_python_plugin + + + grpc_python_plugin + + + grpc_python_plugin + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + + + + diff --git a/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj b/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj new file mode 100644 index 00000000000..0655bc816a2 --- /dev/null +++ b/vsprojects/grpc_ruby_plugin/grpc_ruby_plugin.vcxproj @@ -0,0 +1,169 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {069E9D05-B78B-4751-9252-D21EBAE7DE8E} + + + + v100 + + + v110 + + + v120 + + + Application + true + Unicode + + + Application + true + Unicode + + + Application + false + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + grpc_ruby_plugin + + + grpc_ruby_plugin + + + grpc_ruby_plugin + + + grpc_ruby_plugin + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;_USE_32BIT_TIME_T;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + {B6E81D84-2ACB-41B8-8781-493A944C7817} + + + + + + + diff --git a/vsprojects/protoc.props b/vsprojects/protoc.props new file mode 100644 index 00000000000..6024022690f --- /dev/null +++ b/vsprojects/protoc.props @@ -0,0 +1,13 @@ + + + + + + + + libprotoc.lib;%(AdditionalDependencies) + $(ProjectDir)\..\..\third_party\protobuf\vsprojects\$(Configuration);%(AdditionalLibraryDirectories) + + + + \ No newline at end of file From 67a77aa72399d2cfb807f3c2a8ab7f2511e157db Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 27 May 2015 13:11:52 -0700 Subject: [PATCH 14/21] update readme --- vsprojects/README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vsprojects/README.md b/vsprojects/README.md index 355ef757245..14178daaa7e 100644 --- a/vsprojects/README.md +++ b/vsprojects/README.md @@ -31,4 +31,13 @@ Also, you can `make.bat` directly to build and run gRPC tests. ``` > REM Run from this directory. > make.bat alarm_test -``` \ No newline at end of file +``` + +# Building protoc plugins +For generating service stub code, gRPC relies on plugins for `protoc` (the protocol buffer compiler). The solution `grpc_protoc_plugins.sln` allows you to build +Windows .exe binaries of gRPC protoc plugins. + +1. Open solution `third_party\protobuf\vsprojects\protobuf.sln` +2. Accept the conversion to newer Visual Studio version and ignore errors about gtest. +3. Build libprotoc in Release mode. +4. Open solution `vsprojects\grpc_protoc_plugins.sln` and build it in Release mode. As a result, you should obtain a set of gRPC protoc plugin binaries (`grpc_cpp_plugin.exe`, `grpc_csharp_plugin.exe`, ...) From 7692159e90f2c49c3512cd2a89b3820d9e2090ba Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 27 May 2015 13:14:13 -0700 Subject: [PATCH 15/21] update gitignore --- vsprojects/.gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vsprojects/.gitignore b/vsprojects/.gitignore index dc63b1b31bd..d69021ef583 100644 --- a/vsprojects/.gitignore +++ b/vsprojects/.gitignore @@ -3,7 +3,7 @@ Release *.suo *.user test_bin -grpc.opensdf -grpc.sdf +*.opensdf +*.sdf third_party/*.user /packages From 5dcebd901529f6a2dd78d646aa504f43710db926 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 27 May 2015 15:30:59 -0700 Subject: [PATCH 16/21] make sure printers are properly flushed --- src/compiler/cpp_generator.cc | 221 ++++++++++++++------------ src/compiler/csharp_generator.cc | 56 ++++--- src/compiler/objective_c_generator.cc | 108 +++++++------ src/compiler/ruby_generator.cc | 87 +++++----- 4 files changed, 249 insertions(+), 223 deletions(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index acac1475f7c..b0d2b5d2298 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -86,23 +86,25 @@ grpc::string FilenameIdentifier(const grpc::string &filename) { grpc::string GetHeaderPrologue(const grpc::protobuf::FileDescriptor *file, const Parameters ¶ms) { grpc::string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - grpc::protobuf::io::Printer printer(&output_stream, '$'); - std::map vars; - - vars["filename"] = file->name(); - vars["filename_identifier"] = FilenameIdentifier(file->name()); - vars["filename_base"] = grpc_generator::StripProto(file->name()); - - printer.Print(vars, "// Generated by the gRPC protobuf plugin.\n"); - printer.Print(vars, "// If you make any local change, they will be lost.\n"); - printer.Print(vars, "// source: $filename$\n"); - printer.Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n"); - printer.Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n"); - printer.Print(vars, "\n"); - printer.Print(vars, "#include \"$filename_base$.pb.h\"\n"); - printer.Print(vars, "\n"); - + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + grpc::protobuf::io::Printer printer(&output_stream, '$'); + std::map vars; + + vars["filename"] = file->name(); + vars["filename_identifier"] = FilenameIdentifier(file->name()); + vars["filename_base"] = grpc_generator::StripProto(file->name()); + + printer.Print(vars, "// Generated by the gRPC protobuf plugin.\n"); + printer.Print(vars, "// If you make any local change, they will be lost.\n"); + printer.Print(vars, "// source: $filename$\n"); + printer.Print(vars, "#ifndef GRPC_$filename_identifier$__INCLUDED\n"); + printer.Print(vars, "#define GRPC_$filename_identifier$__INCLUDED\n"); + printer.Print(vars, "\n"); + printer.Print(vars, "#include \"$filename_base$.pb.h\"\n"); + printer.Print(vars, "\n"); + } return output; } @@ -626,100 +628,108 @@ void PrintHeaderService(grpc::protobuf::io::Printer *printer, grpc::string GetHeaderServices(const grpc::protobuf::FileDescriptor *file, const Parameters ¶ms) { grpc::string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - grpc::protobuf::io::Printer printer(&output_stream, '$'); - std::map vars; - - if (!params.services_namespace.empty()) { - vars["services_namespace"] = params.services_namespace; - printer.Print(vars, "\nnamespace $services_namespace$ {\n\n"); - } + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + grpc::protobuf::io::Printer printer(&output_stream, '$'); + std::map vars; + + if (!params.services_namespace.empty()) { + vars["services_namespace"] = params.services_namespace; + printer.Print(vars, "\nnamespace $services_namespace$ {\n\n"); + } - for (int i = 0; i < file->service_count(); ++i) { - PrintHeaderService(&printer, file->service(i), &vars); - printer.Print("\n"); - } + for (int i = 0; i < file->service_count(); ++i) { + PrintHeaderService(&printer, file->service(i), &vars); + printer.Print("\n"); + } - if (!params.services_namespace.empty()) { - printer.Print(vars, "} // namespace $services_namespace$\n\n"); + if (!params.services_namespace.empty()) { + printer.Print(vars, "} // namespace $services_namespace$\n\n"); + } } - return output; } grpc::string GetHeaderEpilogue(const grpc::protobuf::FileDescriptor *file, const Parameters ¶ms) { grpc::string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - grpc::protobuf::io::Printer printer(&output_stream, '$'); - std::map vars; - - vars["filename"] = file->name(); - vars["filename_identifier"] = FilenameIdentifier(file->name()); - - if (!file->package().empty()) { - std::vector parts = - grpc_generator::tokenize(file->package(), "."); - - for (auto part = parts.rbegin(); part != parts.rend(); part++) { - vars["part"] = *part; - printer.Print(vars, "} // namespace $part$\n"); + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + grpc::protobuf::io::Printer printer(&output_stream, '$'); + std::map vars; + + vars["filename"] = file->name(); + vars["filename_identifier"] = FilenameIdentifier(file->name()); + + if (!file->package().empty()) { + std::vector parts = + grpc_generator::tokenize(file->package(), "."); + + for (auto part = parts.rbegin(); part != parts.rend(); part++) { + vars["part"] = *part; + printer.Print(vars, "} // namespace $part$\n"); + } + printer.Print(vars, "\n"); } + printer.Print(vars, "\n"); + printer.Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n"); } - - printer.Print(vars, "\n"); - printer.Print(vars, "#endif // GRPC_$filename_identifier$__INCLUDED\n"); - return output; } grpc::string GetSourcePrologue(const grpc::protobuf::FileDescriptor *file, const Parameters ¶ms) { grpc::string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - grpc::protobuf::io::Printer printer(&output_stream, '$'); - std::map vars; - - vars["filename"] = file->name(); - vars["filename_base"] = grpc_generator::StripProto(file->name()); - - printer.Print(vars, "// Generated by the gRPC protobuf plugin.\n"); - printer.Print(vars, "// If you make any local change, they will be lost.\n"); - printer.Print(vars, "// source: $filename$\n\n"); - printer.Print(vars, "#include \"$filename_base$.pb.h\"\n"); - printer.Print(vars, "#include \"$filename_base$.grpc.pb.h\"\n"); - printer.Print(vars, "\n"); - + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + grpc::protobuf::io::Printer printer(&output_stream, '$'); + std::map vars; + + vars["filename"] = file->name(); + vars["filename_base"] = grpc_generator::StripProto(file->name()); + + printer.Print(vars, "// Generated by the gRPC protobuf plugin.\n"); + printer.Print(vars, "// If you make any local change, they will be lost.\n"); + printer.Print(vars, "// source: $filename$\n\n"); + printer.Print(vars, "#include \"$filename_base$.pb.h\"\n"); + printer.Print(vars, "#include \"$filename_base$.grpc.pb.h\"\n"); + printer.Print(vars, "\n"); + } return output; } grpc::string GetSourceIncludes(const grpc::protobuf::FileDescriptor *file, const Parameters ¶m) { grpc::string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - grpc::protobuf::io::Printer printer(&output_stream, '$'); - std::map vars; - - printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); - printer.Print(vars, "#include \n"); - - if (!file->package().empty()) { - std::vector parts = - grpc_generator::tokenize(file->package(), "."); - - for (auto part = parts.begin(); part != parts.end(); part++) { - vars["part"] = *part; - printer.Print(vars, "namespace $part$ {\n"); + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + grpc::protobuf::io::Printer printer(&output_stream, '$'); + std::map vars; + + printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); + printer.Print(vars, "#include \n"); + + if (!file->package().empty()) { + std::vector parts = + grpc_generator::tokenize(file->package(), "."); + + for (auto part = parts.begin(); part != parts.end(); part++) { + vars["part"] = *part; + printer.Print(vars, "namespace $part$ {\n"); + } } - } - - printer.Print(vars, "\n"); + printer.Print(vars, "\n"); + } return output; } @@ -1077,26 +1087,29 @@ void PrintSourceService(grpc::protobuf::io::Printer *printer, grpc::string GetSourceServices(const grpc::protobuf::FileDescriptor *file, const Parameters ¶ms) { grpc::string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - grpc::protobuf::io::Printer printer(&output_stream, '$'); - std::map vars; - // Package string is empty or ends with a dot. It is used to fully qualify - // method names. - vars["Package"] = file->package(); - if (!file->package().empty()) { - vars["Package"].append("."); - } - if (!params.services_namespace.empty()) { - vars["ns"] = params.services_namespace + "::"; - vars["prefix"] = params.services_namespace; - } else { - vars["ns"] = ""; - vars["prefix"] = ""; - } + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + grpc::protobuf::io::Printer printer(&output_stream, '$'); + std::map vars; + // Package string is empty or ends with a dot. It is used to fully qualify + // method names. + vars["Package"] = file->package(); + if (!file->package().empty()) { + vars["Package"].append("."); + } + if (!params.services_namespace.empty()) { + vars["ns"] = params.services_namespace + "::"; + vars["prefix"] = params.services_namespace; + } else { + vars["ns"] = ""; + vars["prefix"] = ""; + } - for (int i = 0; i < file->service_count(); ++i) { - PrintSourceService(&printer, file->service(i), &vars); - printer.Print("\n"); + for (int i = 0; i < file->service_count(); ++i) { + PrintSourceService(&printer, file->service(i), &vars); + printer.Print("\n"); + } } return output; } diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 5dd078b303b..ccb0b688b6b 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -474,35 +474,39 @@ void GenerateService(Printer* out, const ServiceDescriptor *service) { grpc::string GetServices(const FileDescriptor *file) { grpc::string output; - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); + { + // Scope the output stream so it closes and finalizes output to the string. - // Don't write out any output if there no services, to avoid empty service - // files being generated for proto files that don't declare any. - if (file->service_count() == 0) { - return output; - } + StringOutputStream output_stream(&output); + Printer out(&output_stream, '$'); + + // Don't write out any output if there no services, to avoid empty service + // files being generated for proto files that don't declare any. + if (file->service_count() == 0) { + return output; + } - // Write out a file header. - out.Print("// Generated by the protocol buffer compiler. DO NOT EDIT!\n"); - out.Print("// source: $filename$\n", "filename", file->name()); - out.Print("#region Designer generated code\n"); - out.Print("\n"); - out.Print("using System;\n"); - out.Print("using System.Threading;\n"); - out.Print("using System.Threading.Tasks;\n"); - out.Print("using Grpc.Core;\n"); - // TODO(jtattermusch): add using for protobuf message classes - out.Print("\n"); - - out.Print("namespace $namespace$ {\n", "namespace", GetFileNamespace(file)); - out.Indent(); - for (int i = 0; i < file->service_count(); i++) { - GenerateService(&out, file->service(i)); + // Write out a file header. + out.Print("// Generated by the protocol buffer compiler. DO NOT EDIT!\n"); + out.Print("// source: $filename$\n", "filename", file->name()); + out.Print("#region Designer generated code\n"); + out.Print("\n"); + out.Print("using System;\n"); + out.Print("using System.Threading;\n"); + out.Print("using System.Threading.Tasks;\n"); + out.Print("using Grpc.Core;\n"); + // TODO(jtattermusch): add using for protobuf message classes + out.Print("\n"); + + out.Print("namespace $namespace$ {\n", "namespace", GetFileNamespace(file)); + out.Indent(); + for (int i = 0; i < file->service_count(); i++) { + GenerateService(&out, file->service(i)); + } + out.Outdent(); + out.Print("}\n"); + out.Print("#endregion\n"); } - out.Outdent(); - out.Print("}\n"); - out.Print("#endregion\n"); return output; } diff --git a/src/compiler/objective_c_generator.cc b/src/compiler/objective_c_generator.cc index 8f35302beee..1bf0254f5b8 100644 --- a/src/compiler/objective_c_generator.cc +++ b/src/compiler/objective_c_generator.cc @@ -176,65 +176,71 @@ void PrintMethodImplementations(Printer *printer, string GetHeader(const ServiceDescriptor *service, const string prefix) { string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - Printer printer(&output_stream, '$'); + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + Printer printer(&output_stream, '$'); - printer.Print("@protocol GRXWriteable;\n"); - printer.Print("@protocol GRXWriter;\n\n"); - - map vars = {{"service_name", service->name()}, - {"prefix", prefix}}; - printer.Print(vars, "@protocol $prefix$$service_name$ \n\n"); - - for (int i = 0; i < service->method_count(); i++) { - PrintMethodDeclarations(&printer, service->method(i), vars); + printer.Print("@protocol GRXWriteable;\n"); + printer.Print("@protocol GRXWriter;\n\n"); + + map vars = {{"service_name", service->name()}, + {"prefix", prefix}}; + printer.Print(vars, "@protocol $prefix$$service_name$ \n\n"); + + for (int i = 0; i < service->method_count(); i++) { + PrintMethodDeclarations(&printer, service->method(i), vars); + } + printer.Print("@end\n\n"); + + printer.Print("// Basic service implementation, over gRPC, that only does" + " marshalling and parsing.\n"); + printer.Print(vars, "@interface $prefix$$service_name$ :" + " ProtoService<$prefix$$service_name$>\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host" + " NS_DESIGNATED_INITIALIZER;\n"); + printer.Print("@end\n"); } - printer.Print("@end\n\n"); - - printer.Print("// Basic service implementation, over gRPC, that only does" - " marshalling and parsing.\n"); - printer.Print(vars, "@interface $prefix$$service_name$ :" - " ProtoService<$prefix$$service_name$>\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host" - " NS_DESIGNATED_INITIALIZER;\n"); - printer.Print("@end\n"); return output; } string GetSource(const ServiceDescriptor *service, const string prefix) { string output; - grpc::protobuf::io::StringOutputStream output_stream(&output); - Printer printer(&output_stream, '$'); - - map vars = {{"service_name", service->name()}, - {"package", service->file()->package()}, - {"prefix", prefix}}; - - printer.Print(vars, - "static NSString *const kPackageName = @\"$package$\";\n"); - printer.Print(vars, - "static NSString *const kServiceName = @\"$service_name$\";\n\n"); - - printer.Print(vars, "@implementation $prefix$$service_name$\n\n"); - - printer.Print("// Designated initializer\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host {\n"); - printer.Print(" return (self = [super initWithHost:host" - " packageName:kPackageName serviceName:kServiceName]);\n"); - printer.Print("}\n\n"); - printer.Print("// Override superclass initializer to disallow different" - " package and service names.\n"); - printer.Print("- (instancetype)initWithHost:(NSString *)host\n"); - printer.Print(" packageName:(NSString *)packageName\n"); - printer.Print(" serviceName:(NSString *)serviceName {\n"); - printer.Print(" return [self initWithHost:host];\n"); - printer.Print("}\n\n\n"); - - for (int i = 0; i < service->method_count(); i++) { - PrintMethodImplementations(&printer, service->method(i), vars); - } + { + // Scope the output stream so it closes and finalizes output to the string. + grpc::protobuf::io::StringOutputStream output_stream(&output); + Printer printer(&output_stream, '$'); + + map vars = {{"service_name", service->name()}, + {"package", service->file()->package()}, + {"prefix", prefix}}; - printer.Print("@end\n"); + printer.Print(vars, + "static NSString *const kPackageName = @\"$package$\";\n"); + printer.Print(vars, + "static NSString *const kServiceName = @\"$service_name$\";\n\n"); + + printer.Print(vars, "@implementation $prefix$$service_name$\n\n"); + + printer.Print("// Designated initializer\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host {\n"); + printer.Print(" return (self = [super initWithHost:host" + " packageName:kPackageName serviceName:kServiceName]);\n"); + printer.Print("}\n\n"); + printer.Print("// Override superclass initializer to disallow different" + " package and service names.\n"); + printer.Print("- (instancetype)initWithHost:(NSString *)host\n"); + printer.Print(" packageName:(NSString *)packageName\n"); + printer.Print(" serviceName:(NSString *)serviceName {\n"); + printer.Print(" return [self initWithHost:host];\n"); + printer.Print("}\n\n\n"); + + for (int i = 0; i < service->method_count(); i++) { + PrintMethodImplementations(&printer, service->method(i), vars); + } + + printer.Print("@end\n"); + } return output; } diff --git a/src/compiler/ruby_generator.cc b/src/compiler/ruby_generator.cc index a0bb92848b8..299137519f8 100644 --- a/src/compiler/ruby_generator.cc +++ b/src/compiler/ruby_generator.cc @@ -119,49 +119,52 @@ void PrintService(const ServiceDescriptor *service, const grpc::string &package, grpc::string GetServices(const FileDescriptor *file) { grpc::string output; - StringOutputStream output_stream(&output); - Printer out(&output_stream, '$'); - - // Don't write out any output if there no services, to avoid empty service - // files being generated for proto files that don't declare any. - if (file->service_count() == 0) { - return output; - } - - // Write out a file header. - std::map header_comment_vars = ListToDict( - {"file.name", file->name(), "file.package", file->package(), }); - out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n"); - out.Print(header_comment_vars, - "# Source: $file.name$ for package '$file.package$'\n"); - - out.Print("\n"); - out.Print("require 'grpc'\n"); - // Write out require statemment to import the separately generated file - // that defines the messages used by the service. This is generated by the - // main ruby plugin. - std::map dep_vars = - ListToDict({"dep.name", MessagesRequireName(file), }); - out.Print(dep_vars, "require '$dep.name$'\n"); - - // Write out services within the modules - out.Print("\n"); - std::vector modules = Split(file->package(), '.'); - for (size_t i = 0; i < modules.size(); ++i) { - std::map module_vars = - ListToDict({"module.name", CapitalizeFirst(modules[i]), }); - out.Print(module_vars, "module $module.name$\n"); - out.Indent(); + { + // Scope the output stream so it closes and finalizes output to the string. + + StringOutputStream output_stream(&output); + Printer out(&output_stream, '$'); + + // Don't write out any output if there no services, to avoid empty service + // files being generated for proto files that don't declare any. + if (file->service_count() == 0) { + return output; + } + + // Write out a file header. + std::map header_comment_vars = ListToDict( + {"file.name", file->name(), "file.package", file->package(), }); + out.Print("# Generated by the protocol buffer compiler. DO NOT EDIT!\n"); + out.Print(header_comment_vars, + "# Source: $file.name$ for package '$file.package$'\n"); + + out.Print("\n"); + out.Print("require 'grpc'\n"); + // Write out require statemment to import the separately generated file + // that defines the messages used by the service. This is generated by the + // main ruby plugin. + std::map dep_vars = + ListToDict({"dep.name", MessagesRequireName(file), }); + out.Print(dep_vars, "require '$dep.name$'\n"); + + // Write out services within the modules + out.Print("\n"); + std::vector modules = Split(file->package(), '.'); + for (size_t i = 0; i < modules.size(); ++i) { + std::map module_vars = + ListToDict({"module.name", CapitalizeFirst(modules[i]), }); + out.Print(module_vars, "module $module.name$\n"); + out.Indent(); + } + for (int i = 0; i < file->service_count(); ++i) { + auto service = file->service(i); + PrintService(service, file->package(), &out); + } + for (size_t i = 0; i < modules.size(); ++i) { + out.Outdent(); + out.Print("end\n"); + } } - for (int i = 0; i < file->service_count(); ++i) { - auto service = file->service(i); - PrintService(service, file->package(), &out); - } - for (size_t i = 0; i < modules.size(); ++i) { - out.Outdent(); - out.Print("end\n"); - } - return output; } From 241563b00301c68e306c4c1662149f131b22a15c Mon Sep 17 00:00:00 2001 From: Donna Dionne Date: Wed, 27 May 2015 15:57:18 -0700 Subject: [PATCH 17/21] Adding 2 helper build scripts to allow docker images to be built from local repositories. Framework is already set up in private_build_and_test.sh; helper build script is needed for each langauge. --- tools/dockerfile/grpc_csharp_mono/build.sh | 10 ++++++++++ tools/dockerfile/grpc_php/build.sh | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 tools/dockerfile/grpc_csharp_mono/build.sh create mode 100755 tools/dockerfile/grpc_php/build.sh diff --git a/tools/dockerfile/grpc_csharp_mono/build.sh b/tools/dockerfile/grpc_csharp_mono/build.sh new file mode 100755 index 00000000000..a7737d752e6 --- /dev/null +++ b/tools/dockerfile/grpc_csharp_mono/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +cp -R /var/local/git-clone/grpc /var/local/git + +make install_grpc_csharp_ext -j12 -C /var/local/git/grpc + +cd /var/local/git/grpc/src/csharp && mono /var/local/NuGet.exe restore Grpc.sln + +cd /var/local/git/grpc/src/csharp && xbuild Grpc.sln + diff --git a/tools/dockerfile/grpc_php/build.sh b/tools/dockerfile/grpc_php/build.sh new file mode 100755 index 00000000000..fbbc61d5fa4 --- /dev/null +++ b/tools/dockerfile/grpc_php/build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +cp -R /var/local/git-clone/grpc /var/local/git + +make clean -C /var/local/git/grpc + +make install_c -j12 -C /var/local/git/grpc + +cd /var/local/git/grpc/src/php/ext/grpc && git pull && phpize + +cd /var/local/git/grpc/src/php/ext/grpc \ + && ./configure \ + && make + +cd /var/local/git/grpc/src/php && composer install + +cd /var/local/git/grpc/src/php && protoc-gen-php -i tests/interop/ -o tests/interop/ tests/interop/test.proto + From 7a1b41523792465530d4a8bc4bfebb71c3d67e08 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 27 May 2015 16:41:55 -0700 Subject: [PATCH 18/21] Re-enable some tests --- Makefile | 16 ++++++++-------- build.json | 4 ---- tools/run_tests/tests.json | 8 ++++---- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 5f539ff89a1..cdd675bce42 100644 --- a/Makefile +++ b/Makefile @@ -1183,6 +1183,14 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/bin_encoder_test || ( echo test bin_encoder_test failed ; exit 1 ) $(E) "[RUN] Testing census_hash_table_test" $(Q) $(BINDIR)/$(CONFIG)/census_hash_table_test || ( echo test census_hash_table_test failed ; exit 1 ) + $(E) "[RUN] Testing census_statistics_multiple_writers_test" + $(Q) $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_test || ( echo test census_statistics_multiple_writers_test failed ; exit 1 ) + $(E) "[RUN] Testing census_statistics_performance_test" + $(Q) $(BINDIR)/$(CONFIG)/census_statistics_performance_test || ( echo test census_statistics_performance_test failed ; exit 1 ) + $(E) "[RUN] Testing census_statistics_quick_test" + $(Q) $(BINDIR)/$(CONFIG)/census_statistics_quick_test || ( echo test census_statistics_quick_test failed ; exit 1 ) + $(E) "[RUN] Testing census_statistics_small_log_test" + $(Q) $(BINDIR)/$(CONFIG)/census_statistics_small_log_test || ( echo test census_statistics_small_log_test failed ; exit 1 ) $(E) "[RUN] Testing census_stub_test" $(Q) $(BINDIR)/$(CONFIG)/census_stub_test || ( echo test census_stub_test failed ; exit 1 ) $(E) "[RUN] Testing census_window_stats_test" @@ -2002,14 +2010,6 @@ test_c: buildtests_c flaky_test_c: buildtests_c $(E) "[RUN] Testing census_statistics_multiple_writers_circular_buffer_test" $(Q) $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_circular_buffer_test || ( echo test census_statistics_multiple_writers_circular_buffer_test failed ; exit 1 ) - $(E) "[RUN] Testing census_statistics_multiple_writers_test" - $(Q) $(BINDIR)/$(CONFIG)/census_statistics_multiple_writers_test || ( echo test census_statistics_multiple_writers_test failed ; exit 1 ) - $(E) "[RUN] Testing census_statistics_performance_test" - $(Q) $(BINDIR)/$(CONFIG)/census_statistics_performance_test || ( echo test census_statistics_performance_test failed ; exit 1 ) - $(E) "[RUN] Testing census_statistics_quick_test" - $(Q) $(BINDIR)/$(CONFIG)/census_statistics_quick_test || ( echo test census_statistics_quick_test failed ; exit 1 ) - $(E) "[RUN] Testing census_statistics_small_log_test" - $(Q) $(BINDIR)/$(CONFIG)/census_statistics_small_log_test || ( echo test census_statistics_small_log_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_fake_security_cancel_after_accept_test" $(Q) $(BINDIR)/$(CONFIG)/chttp2_fake_security_cancel_after_accept_test || ( echo test chttp2_fake_security_cancel_after_accept_test failed ; exit 1 ) $(E) "[RUN] Testing chttp2_fake_security_invoke_large_request_test" diff --git a/build.json b/build.json index b893692205c..b253b35fcd4 100644 --- a/build.json +++ b/build.json @@ -820,7 +820,6 @@ }, { "name": "census_statistics_multiple_writers_test", - "flaky": true, "build": "test", "language": "c", "src": [ @@ -835,7 +834,6 @@ }, { "name": "census_statistics_performance_test", - "flaky": true, "build": "test", "language": "c", "src": [ @@ -850,7 +848,6 @@ }, { "name": "census_statistics_quick_test", - "flaky": true, "build": "test", "language": "c", "src": [ @@ -865,7 +862,6 @@ }, { "name": "census_statistics_small_log_test", - "flaky": true, "build": "test", "language": "c", "src": [ diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index cd94454d42a..c34f0f2036d 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -65,7 +65,7 @@ ] }, { - "flaky": true, + "flaky": false, "language": "c", "name": "census_statistics_multiple_writers_test", "platforms": [ @@ -74,7 +74,7 @@ ] }, { - "flaky": true, + "flaky": false, "language": "c", "name": "census_statistics_performance_test", "platforms": [ @@ -83,7 +83,7 @@ ] }, { - "flaky": true, + "flaky": false, "language": "c", "name": "census_statistics_quick_test", "platforms": [ @@ -92,7 +92,7 @@ ] }, { - "flaky": true, + "flaky": false, "language": "c", "name": "census_statistics_small_log_test", "platforms": [ From a4ad39176f5ae8bd2657513a6bab16b66841be52 Mon Sep 17 00:00:00 2001 From: Stanley Cheung Date: Wed, 27 May 2015 17:45:53 -0700 Subject: [PATCH 19/21] fix php generated code test server port --- src/php/bin/run_gen_code_test.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/php/bin/run_gen_code_test.sh b/src/php/bin/run_gen_code_test.sh index 79abbe6cf8c..4882a2b846b 100755 --- a/src/php/bin/run_gen_code_test.sh +++ b/src/php/bin/run_gen_code_test.sh @@ -29,9 +29,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cd $(dirname $0) -GRPC_TEST_HOST=localhost:7070 php -d extension_dir=../ext/grpc/modules/ \ +GRPC_TEST_HOST=localhost:50051 php -d extension_dir=../ext/grpc/modules/ \ -d extension=grpc.so /usr/local/bin/phpunit -v --debug --strict \ ../tests/generated_code/GeneratedCodeTest.php -GRPC_TEST_HOST=localhost:7070 php -d extension_dir=../ext/grpc/modules/ \ +GRPC_TEST_HOST=localhost:50051 php -d extension_dir=../ext/grpc/modules/ \ -d extension=grpc.so /usr/local/bin/phpunit -v --debug --strict \ ../tests/generated_code/GeneratedCodeWithCallbackTest.php From dbf8fdc07396e466ad53bd4c54430660212b585c Mon Sep 17 00:00:00 2001 From: Yang Gao Date: Thu, 28 May 2015 00:52:31 -0700 Subject: [PATCH 20/21] Unref the slices if no write will happen. --- src/core/channel/client_channel.c | 1 + src/core/surface/lame_client.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/core/channel/client_channel.c b/src/core/channel/client_channel.c index 78f8d06d89f..42e242ae81b 100644 --- a/src/core/channel/client_channel.c +++ b/src/core/channel/client_channel.c @@ -144,6 +144,7 @@ static void handle_op_after_cancellation(grpc_call_element *elem, call_data *calld = elem->call_data; channel_data *chand = elem->channel_data; if (op->send_ops) { + grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops); op->on_done_send(op->send_user_data, 0); } if (op->recv_ops) { diff --git a/src/core/surface/lame_client.c b/src/core/surface/lame_client.c index 3186292a02b..a3b0b2672b6 100644 --- a/src/core/surface/lame_client.c +++ b/src/core/surface/lame_client.c @@ -55,6 +55,7 @@ static void lame_start_transport_op(grpc_call_element *elem, channel_data *chand = elem->channel_data; GRPC_CALL_LOG_OP(GPR_INFO, elem, op); if (op->send_ops) { + grpc_stream_ops_unref_owned_objects(op->send_ops->ops, op->send_ops->nops); op->on_done_send(op->send_user_data, 0); } if (op->recv_ops) { From baac94033183af25ca08b6f71e995d19a48a1111 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Thu, 28 May 2015 07:39:31 -0700 Subject: [PATCH 21/21] Add comment --- src/core/iomgr/pollset_posix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index a38517908da..826c792990e 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -420,6 +420,8 @@ static int unary_poll_pollset_maybe_work(grpc_pollset *pollset, pfd[1].events = grpc_fd_begin_poll(fd, pollset, POLLIN, POLLOUT, &fd_watcher); + /* poll fd count (argument 2) is shortened by one if we have no events + to poll on - such that it only includes the kicker */ r = poll(pfd, GPR_ARRAY_SIZE(pfd) - (pfd[1].events == 0), timeout); GRPC_TIMER_MARK(GRPC_PTAG_POLL_FINISHED, r);