aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/build/check_epollexclusive.c38
-rw-r--r--test/core/end2end/fixtures/http_proxy_fixture.c2
-rw-r--r--test/core/end2end/fuzzers/api_fuzzer.c4
-rw-r--r--test/core/http/httpcli_test.c2
-rw-r--r--test/core/http/httpscli_test.c2
-rw-r--r--test/core/iomgr/BUILD4
-rw-r--r--test/core/iomgr/endpoint_pair_test.c2
-rw-r--r--test/core/iomgr/ev_epollsig_linux_test.c (renamed from test/core/iomgr/ev_epoll_linux_test.c)8
-rw-r--r--test/core/iomgr/fd_posix_test.c2
-rw-r--r--test/core/iomgr/pollset_set_test.c6
-rw-r--r--test/core/iomgr/resolve_address_posix_test.c2
-rw-r--r--test/core/iomgr/resolve_address_test.c2
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c2
-rw-r--r--test/core/iomgr/tcp_client_uv_test.c2
-rw-r--r--test/core/iomgr/tcp_posix_test.c2
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c2
-rw-r--r--test/core/iomgr/tcp_server_uv_test.c2
-rw-r--r--test/core/iomgr/timer_list_test.c13
-rw-r--r--test/core/iomgr/udp_server_test.c2
-rw-r--r--test/core/security/secure_endpoint_test.c2
-rw-r--r--test/core/surface/concurrent_connectivity_test.c2
-rw-r--r--test/core/transport/connectivity_state_test.c2
-rw-r--r--test/core/util/port_server_client.c8
-rw-r--r--test/core/util/test_tcp_server.c9
-rw-r--r--test/cpp/microbenchmarks/bm_cq_multiple_threads.cc4
-rw-r--r--test/cpp/microbenchmarks/bm_pollset.cc36
-rw-r--r--test/cpp/qps/client_async.cc48
27 files changed, 138 insertions, 72 deletions
diff --git a/test/build/check_epollexclusive.c b/test/build/check_epollexclusive.c
new file mode 100644
index 0000000000..fb512c3ae1
--- /dev/null
+++ b/test/build/check_epollexclusive.c
@@ -0,0 +1,38 @@
+/*
+ *
+ * Copyright 2017, 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 "src/core/lib/iomgr/is_epollexclusive_available.h"
+
+int main(int argc, char **argv) {
+ return grpc_is_epollexclusive_available() ? 0 : 1;
+}
diff --git a/test/core/end2end/fixtures/http_proxy_fixture.c b/test/core/end2end/fixtures/http_proxy_fixture.c
index f0d09487c6..4170a59eaf 100644
--- a/test/core/end2end/fixtures/http_proxy_fixture.c
+++ b/test/core/end2end/fixtures/http_proxy_fixture.c
@@ -488,7 +488,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(void) {
static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
grpc_pollset* pollset = arg;
- grpc_pollset_destroy(pollset);
+ grpc_pollset_destroy(exec_ctx, pollset);
gpr_free(pollset);
}
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c
index 88a0e301da..b33b43dac5 100644
--- a/test/core/end2end/fuzzers/api_fuzzer.c
+++ b/test/core/end2end/fuzzers/api_fuzzer.c
@@ -44,6 +44,7 @@
#include "src/core/lib/iomgr/resolve_address.h"
#include "src/core/lib/iomgr/tcp_client.h"
#include "src/core/lib/iomgr/timer.h"
+#include "src/core/lib/iomgr/timer_manager.h"
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/surface/server.h"
#include "src/core/lib/transport/metadata.h"
@@ -722,6 +723,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
grpc_tcp_client_connect_impl = my_tcp_client_connect;
gpr_now_impl = now_impl;
grpc_init();
+ grpc_timer_manager_set_threading(false);
grpc_resolve_address = my_resolve_address;
GPR_ASSERT(g_channel == NULL);
@@ -769,6 +771,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
g_now = gpr_time_add(g_now, gpr_time_from_seconds(1, GPR_TIMESPAN));
}
+ grpc_timer_manager_tick();
+
switch (next_byte(&inp)) {
// terminate on bad bytes
default:
diff --git a/test/core/http/httpcli_test.c b/test/core/http/httpcli_test.c
index d3b45c4505..21135ddf6b 100644
--- a/test/core/http/httpcli_test.c
+++ b/test/core/http/httpcli_test.c
@@ -155,7 +155,7 @@ static void test_post(int port) {
}
static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
- grpc_pollset_destroy(grpc_polling_entity_pollset(p));
+ grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(p));
}
int main(int argc, char **argv) {
diff --git a/test/core/http/httpscli_test.c b/test/core/http/httpscli_test.c
index acc94091f4..73eaae87d7 100644
--- a/test/core/http/httpscli_test.c
+++ b/test/core/http/httpscli_test.c
@@ -157,7 +157,7 @@ static void test_post(int port) {
}
static void destroy_pops(grpc_exec_ctx *exec_ctx, void *p, grpc_error *error) {
- grpc_pollset_destroy(grpc_polling_entity_pollset(p));
+ grpc_pollset_destroy(exec_ctx, grpc_polling_entity_pollset(p));
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/BUILD b/test/core/iomgr/BUILD
index 0cf93e73f5..808faf57c9 100644
--- a/test/core/iomgr/BUILD
+++ b/test/core/iomgr/BUILD
@@ -55,8 +55,8 @@ cc_test(
)
cc_test(
- name = "ev_epoll_linux_test",
- srcs = ["ev_epoll_linux_test.c"],
+ name = "ev_epollsig_linux_test",
+ srcs = ["ev_epollsig_linux_test.c"],
deps = ["//:grpc", "//test/core/util:grpc_test_util", "//:gpr", "//test/core/util:gpr_test_util"],
copts = ['-std=c99']
)
diff --git a/test/core/iomgr/endpoint_pair_test.c b/test/core/iomgr/endpoint_pair_test.c
index c8a60776b9..4561c3846e 100644
--- a/test/core/iomgr/endpoint_pair_test.c
+++ b/test/core/iomgr/endpoint_pair_test.c
@@ -70,7 +70,7 @@ static grpc_endpoint_test_config configs[] = {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/ev_epoll_linux_test.c b/test/core/iomgr/ev_epollsig_linux_test.c
index 0856023b14..efc8ed36be 100644
--- a/test/core/iomgr/ev_epoll_linux_test.c
+++ b/test/core/iomgr/ev_epollsig_linux_test.c
@@ -34,7 +34,7 @@
/* This test only relevant on linux systems where epoll() is available */
#ifdef GRPC_LINUX_EPOLL
-#include "src/core/lib/iomgr/ev_epoll_linux.h"
+#include "src/core/lib/iomgr/ev_epollsig_linux.h"
#include "src/core/lib/iomgr/ev_posix.h"
#include <errno.h>
@@ -113,7 +113,7 @@ static void test_pollset_init(test_pollset *pollsets, int num_pollsets) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
static void test_pollset_cleanup(grpc_exec_ctx *exec_ctx,
@@ -405,13 +405,13 @@ int main(int argc, char **argv) {
grpc_iomgr_init();
poll_strategy = grpc_get_poll_strategy_name();
- if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) {
+ if (poll_strategy != NULL && strcmp(poll_strategy, "epollsig") == 0) {
test_add_fd_to_pollset();
test_pollset_queue_merge_items();
test_threading();
} else {
gpr_log(GPR_INFO,
- "Skipping the test. The test is only relevant for 'epoll' "
+ "Skipping the test. The test is only relevant for 'epollsig' "
"strategy. and the current strategy is: '%s'",
poll_strategy);
}
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index 81d2692a08..d6cee8e43a 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -535,7 +535,7 @@ static void test_grpc_fd_change(void) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/pollset_set_test.c b/test/core/iomgr/pollset_set_test.c
index 3a9d459579..9755a7e552 100644
--- a/test/core/iomgr/pollset_set_test.c
+++ b/test/core/iomgr/pollset_set_test.c
@@ -86,7 +86,7 @@ static void init_test_pollsets(test_pollset *pollsets, const int num_pollsets) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
static void cleanup_test_pollsets(grpc_exec_ctx *exec_ctx,
@@ -449,7 +449,9 @@ int main(int argc, char **argv) {
grpc_test_init(argc, argv);
grpc_iomgr_init();
- if (poll_strategy != NULL && strcmp(poll_strategy, "epoll") == 0) {
+ if (poll_strategy != NULL &&
+ (strcmp(poll_strategy, "epoll") == 0 ||
+ strcmp(poll_strategy, "epoll-threadpool") == 0)) {
pollset_set_test_basic();
pollset_set_test_dup_fds();
pollset_set_test_empty_pollset();
diff --git a/test/core/iomgr/resolve_address_posix_test.c b/test/core/iomgr/resolve_address_posix_test.c
index fa88aca431..7fba0b92be 100644
--- a/test/core/iomgr/resolve_address_posix_test.c
+++ b/test/core/iomgr/resolve_address_posix_test.c
@@ -81,7 +81,7 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(args->pollset);
+ grpc_pollset_destroy(exec_ctx, args->pollset);
gpr_free(args->pollset);
}
diff --git a/test/core/iomgr/resolve_address_test.c b/test/core/iomgr/resolve_address_test.c
index ea79adc090..0425c3b3f5 100644
--- a/test/core/iomgr/resolve_address_test.c
+++ b/test/core/iomgr/resolve_address_test.c
@@ -76,7 +76,7 @@ void args_finish(grpc_exec_ctx *exec_ctx, args_struct *args) {
grpc_pollset_shutdown(exec_ctx, args->pollset, &do_nothing_cb);
// exec_ctx needs to be flushed before calling grpc_pollset_destroy()
grpc_exec_ctx_flush(exec_ctx);
- grpc_pollset_destroy(args->pollset);
+ grpc_pollset_destroy(exec_ctx, args->pollset);
gpr_free(args->pollset);
}
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 2fae6774e8..6e1bb43eb5 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -197,7 +197,7 @@ void test_fails(void) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/tcp_client_uv_test.c b/test/core/iomgr/tcp_client_uv_test.c
index 92fc393422..3a8458df86 100644
--- a/test/core/iomgr/tcp_client_uv_test.c
+++ b/test/core/iomgr/tcp_client_uv_test.c
@@ -194,7 +194,7 @@ void test_fails(void) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 2c53a003d2..a1c54e19c1 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -562,7 +562,7 @@ static grpc_endpoint_test_config configs[] = {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index 112743b95b..88aead1dd0 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -444,7 +444,7 @@ static void test_connect(size_t num_connects,
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/tcp_server_uv_test.c b/test/core/iomgr/tcp_server_uv_test.c
index 1e039585c1..945b84a355 100644
--- a/test/core/iomgr/tcp_server_uv_test.c
+++ b/test/core/iomgr/tcp_server_uv_test.c
@@ -306,7 +306,7 @@ static void test_connect(unsigned n) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/timer_list_test.c b/test/core/iomgr/timer_list_test.c
index 46e41dd449..88a9f6b855 100644
--- a/test/core/iomgr/timer_list_test.c
+++ b/test/core/iomgr/timer_list_test.c
@@ -41,12 +41,13 @@
#include <string.h>
#include <grpc/support/log.h>
+#include "src/core/lib/debug/trace.h"
#include "test/core/util/test_config.h"
#define MAX_CB 30
-extern int grpc_timer_trace;
-extern int grpc_timer_check_trace;
+extern grpc_tracer_flag grpc_timer_trace;
+extern grpc_tracer_flag grpc_timer_check_trace;
static int cb_called[MAX_CB][2];
@@ -63,8 +64,8 @@ static void add_test(void) {
gpr_log(GPR_INFO, "add_test");
grpc_timer_list_init(start);
- grpc_timer_trace = 1;
- grpc_timer_check_trace = 1;
+ grpc_timer_trace.value = 1;
+ grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
/* 10 ms timers. will expire in the current epoch */
@@ -138,8 +139,8 @@ void destruction_test(void) {
gpr_log(GPR_INFO, "destruction_test");
grpc_timer_list_init(gpr_time_0(GPR_CLOCK_REALTIME));
- grpc_timer_trace = 1;
- grpc_timer_check_trace = 1;
+ grpc_timer_trace.value = 1;
+ grpc_timer_check_trace.value = 1;
memset(cb_called, 0, sizeof(cb_called));
grpc_timer_init(
diff --git a/test/core/iomgr/udp_server_test.c b/test/core/iomgr/udp_server_test.c
index 1f1696a7a7..ee78d6b4ad 100644
--- a/test/core/iomgr/udp_server_test.c
+++ b/test/core/iomgr/udp_server_test.c
@@ -307,7 +307,7 @@ static void test_receive(int number_of_clients) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c
index 71d8057ac3..cd6ff2ceac 100644
--- a/test/core/security/secure_endpoint_test.c
+++ b/test/core/security/secure_endpoint_test.c
@@ -185,7 +185,7 @@ static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) {
static void destroy_pollset(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
- grpc_pollset_destroy(p);
+ grpc_pollset_destroy(exec_ctx, p);
}
int main(int argc, char **argv) {
diff --git a/test/core/surface/concurrent_connectivity_test.c b/test/core/surface/concurrent_connectivity_test.c
index d6841ea1f8..f0e3394b2e 100644
--- a/test/core/surface/concurrent_connectivity_test.c
+++ b/test/core/surface/concurrent_connectivity_test.c
@@ -162,7 +162,7 @@ void bad_server_thread(void *vargs) {
static void done_pollset_shutdown(grpc_exec_ctx *exec_ctx, void *pollset,
grpc_error *error) {
- grpc_pollset_destroy(pollset);
+ grpc_pollset_destroy(exec_ctx, pollset);
gpr_free(pollset);
}
diff --git a/test/core/transport/connectivity_state_test.c b/test/core/transport/connectivity_state_test.c
index 8314a5f619..96db59ba2d 100644
--- a/test/core/transport/connectivity_state_test.c
+++ b/test/core/transport/connectivity_state_test.c
@@ -151,7 +151,7 @@ static void test_subscribe_with_failure_then_destroy(void) {
int main(int argc, char **argv) {
grpc_test_init(argc, argv);
- grpc_connectivity_state_trace = 1;
+ grpc_connectivity_state_trace.value = 1;
test_connectivity_state_name();
test_check();
test_subscribe_then_unsubscribe();
diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c
index 254c3a6b61..6ef0acfc29 100644
--- a/test/core/util/port_server_client.c
+++ b/test/core/util/port_server_client.c
@@ -58,9 +58,8 @@ typedef struct freereq {
static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
grpc_pollset *pollset = grpc_polling_entity_pollset(p);
- grpc_pollset_destroy(pollset);
+ grpc_pollset_destroy(exec_ctx, pollset);
gpr_free(pollset);
- grpc_shutdown();
}
static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
@@ -122,12 +121,13 @@ void grpc_free_port_using_server(int port) {
gpr_mu_unlock(pr.mu);
grpc_httpcli_context_destroy(&exec_ctx, &context);
- grpc_exec_ctx_finish(&exec_ctx);
grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
grpc_exec_ctx_finish(&exec_ctx);
gpr_free(path);
grpc_http_response_destroy(&rsp);
+
+ grpc_shutdown();
}
typedef struct portreq {
@@ -239,7 +239,6 @@ int grpc_pick_port_using_server(void) {
grpc_closure_create(got_port_from_server, &pr, grpc_schedule_on_exec_ctx),
&pr.response);
grpc_resource_quota_unref_internal(&exec_ctx, resource_quota);
- grpc_exec_ctx_finish(&exec_ctx);
gpr_mu_lock(pr.mu);
while (pr.port == -1) {
grpc_pollset_worker *worker = NULL;
@@ -258,6 +257,7 @@ int grpc_pick_port_using_server(void) {
grpc_pollset_shutdown(&exec_ctx, grpc_polling_entity_pollset(&pr.pops),
shutdown_closure);
grpc_exec_ctx_finish(&exec_ctx);
+ grpc_shutdown();
return pr.port;
}
diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c
index 496e579bc3..1908698009 100644
--- a/test/core/util/test_tcp_server.c
+++ b/test/core/util/test_tcp_server.c
@@ -106,6 +106,10 @@ void test_tcp_server_poll(test_tcp_server *server, int seconds) {
}
static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {}
+static void finish_pollset(grpc_exec_ctx *exec_ctx, void *arg,
+ grpc_error *error) {
+ grpc_pollset_destroy(exec_ctx, arg);
+}
void test_tcp_server_destroy(test_tcp_server *server) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
@@ -120,9 +124,10 @@ void test_tcp_server_destroy(test_tcp_server *server) {
gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), shutdown_deadline) < 0) {
test_tcp_server_poll(server, 1);
}
- grpc_pollset_shutdown(&exec_ctx, server->pollset, &do_nothing_cb);
+ grpc_pollset_shutdown(&exec_ctx, server->pollset,
+ grpc_closure_create(finish_pollset, server->pollset,
+ grpc_schedule_on_exec_ctx));
grpc_exec_ctx_finish(&exec_ctx);
- grpc_pollset_destroy(server->pollset);
gpr_free(server->pollset);
grpc_shutdown();
}
diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
index 9d7f65d292..0d267da723 100644
--- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
+++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
@@ -67,7 +67,9 @@ static void pollset_init(grpc_pollset* ps, gpr_mu** mu) {
*mu = &ps->mu;
}
-static void pollset_destroy(grpc_pollset* ps) { gpr_mu_destroy(&ps->mu); }
+static void pollset_destroy(grpc_exec_ctx* exec_ctx, grpc_pollset* ps) {
+ gpr_mu_destroy(&ps->mu);
+}
static grpc_error* pollset_kick(grpc_pollset* p, grpc_pollset_worker* worker) {
return GRPC_ERROR_NONE;
diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc
index 0f3d3cef66..f5e8d13881 100644
--- a/test/cpp/microbenchmarks/bm_pollset.cc
+++ b/test/cpp/microbenchmarks/bm_pollset.cc
@@ -59,7 +59,7 @@ extern "C" {
auto& force_library_initialization = Library::get();
static void shutdown_ps(grpc_exec_ctx* exec_ctx, void* ps, grpc_error* error) {
- grpc_pollset_destroy(static_cast<grpc_pollset*>(ps));
+ grpc_pollset_destroy(exec_ctx, static_cast<grpc_pollset*>(ps));
}
static void BM_CreateDestroyPollset(benchmark::State& state) {
@@ -136,8 +136,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC);
gpr_mu_lock(mu);
while (state.KeepRunning()) {
- grpc_pollset_worker* worker;
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, &worker, now, deadline));
+ GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline));
}
grpc_closure shutdown_ps_closure;
grpc_closure_init(&shutdown_ps_closure, shutdown_ps, ps,
@@ -150,6 +149,34 @@ static void BM_PollEmptyPollset(benchmark::State& state) {
}
BENCHMARK(BM_PollEmptyPollset);
+static void BM_PollAddFd(benchmark::State& state) {
+ TrackCounters track_counters;
+ size_t ps_sz = grpc_pollset_size();
+ grpc_pollset* ps = static_cast<grpc_pollset*>(gpr_zalloc(ps_sz));
+ gpr_mu* mu;
+ grpc_pollset_init(ps, &mu);
+ grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
+ grpc_wakeup_fd wakeup_fd;
+ GPR_ASSERT(
+ GRPC_LOG_IF_ERROR("wakeup_fd_init", grpc_wakeup_fd_init(&wakeup_fd)));
+ grpc_fd* fd = grpc_fd_create(wakeup_fd.read_fd, "xxx");
+ while (state.KeepRunning()) {
+ grpc_pollset_add_fd(&exec_ctx, ps, fd);
+ grpc_exec_ctx_flush(&exec_ctx);
+ }
+ grpc_fd_orphan(&exec_ctx, fd, NULL, NULL, "xxx");
+ grpc_closure shutdown_ps_closure;
+ grpc_closure_init(&shutdown_ps_closure, shutdown_ps, ps,
+ grpc_schedule_on_exec_ctx);
+ gpr_mu_lock(mu);
+ grpc_pollset_shutdown(&exec_ctx, ps, &shutdown_ps_closure);
+ gpr_mu_unlock(mu);
+ grpc_exec_ctx_finish(&exec_ctx);
+ gpr_free(ps);
+ track_counters.Finish(state);
+}
+BENCHMARK(BM_PollAddFd);
+
class Closure : public grpc_closure {
public:
virtual ~Closure() {}
@@ -233,8 +260,7 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) {
grpc_fd_notify_on_read(&exec_ctx, wakeup, continue_closure);
gpr_mu_lock(mu);
while (!done) {
- grpc_pollset_worker* worker;
- GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, &worker, now, deadline));
+ GRPC_ERROR_UNREF(grpc_pollset_work(&exec_ctx, ps, NULL, now, deadline));
}
grpc_fd_orphan(&exec_ctx, wakeup, NULL, NULL, "done");
wakeup_fd.read_fd = 0;
diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc
index 01856f714a..82c3356f02 100644
--- a/test/cpp/qps/client_async.cc
+++ b/test/cpp/qps/client_async.cc
@@ -238,39 +238,27 @@ class AsyncClient : public ClientImpl<StubType, RequestType> {
void* got_tag;
bool ok;
- switch (cli_cqs_[thread_idx]->AsyncNext(
- &got_tag, &ok,
- std::chrono::system_clock::now() + std::chrono::milliseconds(10))) {
- case CompletionQueue::GOT_EVENT: {
- // Got a regular event, so process it
- ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
- // Proceed while holding a lock to make sure that
- // this thread isn't supposed to shut down
- std::lock_guard<std::mutex> l(shutdown_state_[thread_idx]->mutex);
- if (shutdown_state_[thread_idx]->shutdown) {
- delete ctx;
- return true;
- } else if (!ctx->RunNextState(ok, entry)) {
- // The RPC and callback are done, so clone the ctx
- // and kickstart the new one
- ctx->StartNewClone(cli_cqs_[thread_idx].get());
- // delete the old version
- delete ctx;
- }
+ if (cli_cqs_[thread_idx]->Next(&got_tag, &ok)) {
+ // Got a regular event, so process it
+ ClientRpcContext* ctx = ClientRpcContext::detag(got_tag);
+ // Proceed while holding a lock to make sure that
+ // this thread isn't supposed to shut down
+ std::lock_guard<std::mutex> l(shutdown_state_[thread_idx]->mutex);
+ if (shutdown_state_[thread_idx]->shutdown) {
+ delete ctx;
return true;
+ } else if (!ctx->RunNextState(ok, entry)) {
+ // The RPC and callback are done, so clone the ctx
+ // and kickstart the new one
+ ctx->StartNewClone(cli_cqs_[thread_idx].get());
+ // delete the old version
+ delete ctx;
}
- case CompletionQueue::TIMEOUT: {
- std::lock_guard<std::mutex> l(shutdown_state_[thread_idx]->mutex);
- if (shutdown_state_[thread_idx]->shutdown) {
- return true;
- }
- return true;
- }
- case CompletionQueue::SHUTDOWN: // queue is shutting down, so we must be
- // done
- return true;
+ return true;
+ } else {
+ // queue is shutting down, so we must be done
+ return true;
}
- GPR_UNREACHABLE_CODE(return true);
}
std::vector<std::unique_ptr<CompletionQueue>> cli_cqs_;