[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_AS… (#36267)

[grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT
Replacing GPR_ASSERT with absl CHECK

Will not be replacing CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only a few - which fit into single - line regex will be changed. This would be small in number just to reduce the load later.

Replacing CHECK with CHECK_EQ , CHECK_NE etc could be done using Cider-V once these changes are submitted if we want to clean up later. Given that we have 5000+ instances of GPR_ASSERT to edit, Doing it manually is too much work for both the author and reviewer.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes #36267

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36267 from tanvi-jagtap:tjagtap_grpc_assert_02 3aed626101
PiperOrigin-RevId: 623469007
pull/36157/merge
Tanvi Jagtap 8 months ago committed by Copybara-Service
parent dec487cefd
commit 3e0eeed4fa
  1. 1
      CMakeLists.txt
  2. 1
      build_autogenerated.yaml
  3. 40
      test/cpp/microbenchmarks/BUILD
  4. 8
      test/cpp/microbenchmarks/bm_basic_work_queue.cc
  5. 10
      test/cpp/microbenchmarks/bm_byte_buffer.cc
  6. 7
      test/cpp/microbenchmarks/bm_chttp2_hpack.cc
  7. 8
      test/cpp/microbenchmarks/bm_chttp2_transport.cc
  8. 22
      test/cpp/microbenchmarks/bm_cq.cc
  9. 11
      test/cpp/microbenchmarks/bm_cq_multiple_threads.cc
  10. 3
      test/cpp/microbenchmarks/bm_event_engine_run.cc
  11. 3
      test/cpp/microbenchmarks/bm_thread_pool.cc
  12. 6
      test/cpp/microbenchmarks/callback_streaming_ping_pong.h
  13. 4
      test/cpp/microbenchmarks/callback_test_service.cc
  14. 4
      test/cpp/microbenchmarks/callback_unary_ping_pong.h
  15. 11
      test/cpp/microbenchmarks/fullstack_fixtures.h
  16. 62
      test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h
  17. 32
      test/cpp/microbenchmarks/fullstack_streaming_pump.h
  18. 16
      test/cpp/microbenchmarks/fullstack_unary_ping_pong.h
  19. 6
      test/cpp/microbenchmarks/helpers.cc

1
CMakeLists.txt generated

@ -4021,6 +4021,7 @@ target_include_directories(benchmark_helpers
) )
target_link_libraries(benchmark_helpers target_link_libraries(benchmark_helpers
${_gRPC_ALLTARGETS_LIBRARIES} ${_gRPC_ALLTARGETS_LIBRARIES}
absl::check
${_gRPC_BENCHMARK_LIBRARIES} ${_gRPC_BENCHMARK_LIBRARIES}
grpc++_unsecure grpc++_unsecure
grpc_test_util_unsecure grpc_test_util_unsecure

@ -3620,6 +3620,7 @@ libs:
- test/core/util/tracer_util.cc - test/core/util/tracer_util.cc
- test/cpp/microbenchmarks/helpers.cc - test/cpp/microbenchmarks/helpers.cc
deps: deps:
- absl/log:check
- benchmark - benchmark
- grpc++_unsecure - grpc++_unsecure
- grpc_test_util_unsecure - grpc_test_util_unsecure

@ -74,6 +74,7 @@ grpc_cc_test(
srcs = ["bm_event_engine_run.cc"], srcs = ["bm_event_engine_run.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [ external_deps = [
"absl/log:check",
"absl/debugging:leak_check", "absl/debugging:leak_check",
"benchmark", "benchmark",
], ],
@ -90,6 +91,7 @@ grpc_cc_test(
srcs = ["bm_thread_pool.cc"], srcs = ["bm_thread_pool.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [ external_deps = [
"absl/log:check",
"benchmark", "benchmark",
], ],
uses_event_engine = False, uses_event_engine = False,
@ -110,6 +112,7 @@ grpc_cc_library(
"helpers.h", "helpers.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"benchmark", "benchmark",
], ],
deps = [ deps = [
@ -132,6 +135,7 @@ grpc_cc_library(
"helpers.h", "helpers.h",
], ],
external_deps = [ external_deps = [
"absl/log:check",
"benchmark", "benchmark",
], ],
deps = [ deps = [
@ -204,6 +208,9 @@ grpc_cc_test(
name = "bm_byte_buffer", name = "bm_byte_buffer",
srcs = ["bm_byte_buffer.cc"], srcs = ["bm_byte_buffer.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [
"absl/log:check",
],
tags = [ tags = [
"no_mac", "no_mac",
"no_windows", "no_windows",
@ -230,6 +237,9 @@ grpc_cc_test(
name = "bm_cq", name = "bm_cq",
srcs = ["bm_cq.cc"], srcs = ["bm_cq.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [
"absl/log:check",
],
tags = [ tags = [
"no_mac", "no_mac",
"no_windows", "no_windows",
@ -241,6 +251,9 @@ grpc_cc_test(
name = "bm_cq_multiple_threads", name = "bm_cq_multiple_threads",
srcs = ["bm_cq_multiple_threads.cc"], srcs = ["bm_cq_multiple_threads.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [
"absl/log:check",
],
tags = [ tags = [
"no_mac", "no_mac",
"no_windows", "no_windows",
@ -256,6 +269,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"fullstack_streaming_ping_pong.h", "fullstack_streaming_ping_pong.h",
], ],
external_deps = [
"absl/log:check",
],
tags = [ tags = [
"no_mac", "no_mac",
"no_windows", "no_windows",
@ -284,6 +300,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"fullstack_streaming_pump.h", "fullstack_streaming_pump.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [":helpers"], deps = [":helpers"],
) )
@ -306,6 +325,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"fullstack_unary_ping_pong.h", "fullstack_unary_ping_pong.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [":helpers_secure"], deps = [":helpers_secure"],
) )
@ -344,6 +366,9 @@ grpc_cc_test(
name = "bm_chttp2_hpack", name = "bm_chttp2_hpack",
srcs = ["bm_chttp2_hpack.cc"], srcs = ["bm_chttp2_hpack.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [
"absl/log:check",
],
tags = [ tags = [
"no_mac", "no_mac",
"no_windows", "no_windows",
@ -360,6 +385,9 @@ grpc_cc_test(
name = "bm_chttp2_transport", name = "bm_chttp2_transport",
srcs = ["bm_chttp2_transport.cc"], srcs = ["bm_chttp2_transport.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = [
"absl/log:check",
],
tags = [ tags = [
"no_mac", "no_mac",
"no_windows", "no_windows",
@ -390,6 +418,7 @@ grpc_cc_library(
srcs = ["callback_test_service.cc"], srcs = ["callback_test_service.cc"],
hdrs = ["callback_test_service.h"], hdrs = ["callback_test_service.h"],
external_deps = [ external_deps = [
"absl/log:check",
"benchmark", "benchmark",
], ],
deps = [ deps = [
@ -405,6 +434,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"callback_unary_ping_pong.h", "callback_unary_ping_pong.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [ deps = [
":bm_callback_test_service_impl", ":bm_callback_test_service_impl",
":helpers", ":helpers",
@ -433,6 +465,9 @@ grpc_cc_library(
hdrs = [ hdrs = [
"callback_streaming_ping_pong.h", "callback_streaming_ping_pong.h",
], ],
external_deps = [
"absl/log:check",
],
deps = [ deps = [
":bm_callback_test_service_impl", ":bm_callback_test_service_impl",
":helpers", ":helpers",
@ -460,7 +495,10 @@ grpc_cc_test(
name = "bm_basic_work_queue", name = "bm_basic_work_queue",
srcs = ["bm_basic_work_queue.cc"], srcs = ["bm_basic_work_queue.cc"],
args = grpc_benchmark_args(), args = grpc_benchmark_args(),
external_deps = ["benchmark"], external_deps = [
"absl/log:check",
"benchmark",
],
tags = [ tags = [
"manual", "manual",
"no_windows", "no_windows",

@ -15,6 +15,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
@ -68,7 +70,7 @@ void BM_MultithreadedWorkQueuePopOldest(benchmark::State& state) {
benchmark::Counter(element_count * state.iterations() / pop_attempts, benchmark::Counter(element_count * state.iterations() / pop_attempts,
benchmark::Counter::kAvgThreads); benchmark::Counter::kAvgThreads);
if (state.thread_index() == 0) { if (state.thread_index() == 0) {
GPR_ASSERT(globalWorkQueue.Empty()); CHECK(globalWorkQueue.Empty());
} }
} }
BENCHMARK(BM_MultithreadedWorkQueuePopOldest) BENCHMARK(BM_MultithreadedWorkQueuePopOldest)
@ -93,7 +95,7 @@ void BM_MultithreadedWorkQueuePopMostRecent(benchmark::State& state) {
benchmark::Counter(element_count * state.iterations() / pop_attempts, benchmark::Counter(element_count * state.iterations() / pop_attempts,
benchmark::Counter::kAvgThreads); benchmark::Counter::kAvgThreads);
if (state.thread_index() == 0) { if (state.thread_index() == 0) {
GPR_ASSERT(globalWorkQueue.Empty()); CHECK(globalWorkQueue.Empty());
} }
} }
BENCHMARK(BM_MultithreadedWorkQueuePopMostRecent) BENCHMARK(BM_MultithreadedWorkQueuePopMostRecent)
@ -111,7 +113,7 @@ void BM_MultithreadedStdDequeLIFO(benchmark::State& state) {
grpc_core::MutexLock lock(&globalMu); grpc_core::MutexLock lock(&globalMu);
EventEngine::Closure* popped = globalDeque.back(); EventEngine::Closure* popped = globalDeque.back();
globalDeque.pop_back(); globalDeque.pop_back();
GPR_ASSERT(popped != nullptr); CHECK_NE(popped, nullptr);
} }
} }
state.counters["added"] = element_count * state.iterations(); state.counters["added"] = element_count * state.iterations();

@ -22,6 +22,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include <grpc/byte_buffer.h> #include <grpc/byte_buffer.h>
#include <grpc/byte_buffer_reader.h> #include <grpc/byte_buffer_reader.h>
#include <grpc/slice.h> #include <grpc/slice.h>
@ -62,12 +64,12 @@ static void BM_ByteBufferReader_Next(benchmark::State& state) {
} }
grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(slices.data(), num_slices); grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(slices.data(), num_slices);
grpc_byte_buffer_reader reader; grpc_byte_buffer_reader reader;
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); CHECK(grpc_byte_buffer_reader_init(&reader, bb));
for (auto _ : state) { for (auto _ : state) {
grpc_slice* slice; grpc_slice* slice;
if (GPR_UNLIKELY(!grpc_byte_buffer_reader_peek(&reader, &slice))) { if (GPR_UNLIKELY(!grpc_byte_buffer_reader_peek(&reader, &slice))) {
grpc_byte_buffer_reader_destroy(&reader); grpc_byte_buffer_reader_destroy(&reader);
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); CHECK(grpc_byte_buffer_reader_init(&reader, bb));
continue; continue;
} }
} }
@ -90,12 +92,12 @@ static void BM_ByteBufferReader_Peek(benchmark::State& state) {
} }
grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(slices.data(), num_slices); grpc_byte_buffer* bb = grpc_raw_byte_buffer_create(slices.data(), num_slices);
grpc_byte_buffer_reader reader; grpc_byte_buffer_reader reader;
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); CHECK(grpc_byte_buffer_reader_init(&reader, bb));
for (auto _ : state) { for (auto _ : state) {
grpc_slice* slice; grpc_slice* slice;
if (GPR_UNLIKELY(!grpc_byte_buffer_reader_peek(&reader, &slice))) { if (GPR_UNLIKELY(!grpc_byte_buffer_reader_peek(&reader, &slice))) {
grpc_byte_buffer_reader_destroy(&reader); grpc_byte_buffer_reader_destroy(&reader);
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); CHECK(grpc_byte_buffer_reader_init(&reader, bb));
continue; continue;
} }
} }

@ -25,6 +25,7 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "absl/random/random.h" #include "absl/random/random.h"
#include <grpc/slice.h> #include <grpc/slice.h>
@ -364,7 +365,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) {
auto error = auto error =
p.Parse(slices[i], i == slices.size() - 1, absl::BitGenRef(bitgen), p.Parse(slices[i], i == slices.size() - 1, absl::BitGenRef(bitgen),
/*call_tracer=*/nullptr); /*call_tracer=*/nullptr);
GPR_ASSERT(error.ok()); CHECK(error.ok());
} }
}; };
parse_vec(init_slices); parse_vec(init_slices);
@ -443,8 +444,8 @@ class FromEncoderFixture {
i++; i++;
} }
// Remove the HTTP header. // Remove the HTTP header.
GPR_ASSERT(!out.empty()); CHECK(!out.empty());
GPR_ASSERT(GRPC_SLICE_LENGTH(out[0]) > 9); CHECK(GRPC_SLICE_LENGTH(out[0]) > 9);
out[0] = grpc_slice_sub_no_ref(out[0], 9, GRPC_SLICE_LENGTH(out[0])); out[0] = grpc_slice_sub_no_ref(out[0], 9, GRPC_SLICE_LENGTH(out[0]));
return out; return out;
} }

@ -26,6 +26,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpc/support/string_util.h> #include <grpc/support/string_util.h>
@ -64,7 +66,7 @@ class PhonyEndpoint : public grpc_endpoint {
void PushInput(grpc_slice slice) { void PushInput(grpc_slice slice) {
if (read_cb_ == nullptr) { if (read_cb_ == nullptr) {
GPR_ASSERT(!have_slice_); CHECK(!have_slice_);
buffered_slice_ = slice; buffered_slice_ = slice;
have_slice_ = true; have_slice_ = true;
return; return;
@ -81,7 +83,7 @@ class PhonyEndpoint : public grpc_endpoint {
grpc_slice buffered_slice_; grpc_slice buffered_slice_;
void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) { void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) {
GPR_ASSERT(read_cb_ == nullptr); CHECK_EQ(read_cb_, nullptr);
if (have_slice_) { if (have_slice_) {
have_slice_ = false; have_slice_ = false;
grpc_slice_buffer_add(slices, buffered_slice_); grpc_slice_buffer_add(slices, buffered_slice_);
@ -393,7 +395,7 @@ static void BM_TransportEmptyOp(benchmark::State& state) {
gpr_event_init(stream_cancel_done); gpr_event_init(stream_cancel_done);
std::unique_ptr<TestClosure> stream_cancel_closure = std::unique_ptr<TestClosure> stream_cancel_closure =
MakeTestClosure([&](grpc_error_handle error) { MakeTestClosure([&](grpc_error_handle error) {
GPR_ASSERT(error.ok()); CHECK(error.ok());
gpr_event_set(stream_cancel_done, reinterpret_cast<void*>(1)); gpr_event_set(stream_cancel_done, reinterpret_cast<void*>(1));
}); });
op.on_complete = stream_cancel_closure.get(); op.on_complete = stream_cancel_closure.get();

@ -21,6 +21,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
#include <grpcpp/completion_queue.h> #include <grpcpp/completion_queue.h>
@ -85,7 +87,7 @@ static void BM_Pass1Cpp(benchmark::State& state) {
grpc_cq_completion completion; grpc_cq_completion completion;
PhonyTag phony_tag; PhonyTag phony_tag;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(c_cq, &phony_tag)); CHECK(grpc_cq_begin_op(c_cq, &phony_tag));
grpc_cq_end_op(c_cq, &phony_tag, absl::OkStatus(), grpc_cq_end_op(c_cq, &phony_tag, absl::OkStatus(),
DoneWithCompletionOnStack, nullptr, &completion); DoneWithCompletionOnStack, nullptr, &completion);
@ -103,7 +105,7 @@ static void BM_Pass1Core(benchmark::State& state) {
for (auto _ : state) { for (auto _ : state) {
grpc_cq_completion completion; grpc_cq_completion completion;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); CHECK(grpc_cq_begin_op(cq, nullptr));
grpc_cq_end_op(cq, nullptr, absl::OkStatus(), DoneWithCompletionOnStack, grpc_cq_end_op(cq, nullptr, absl::OkStatus(), DoneWithCompletionOnStack,
nullptr, &completion); nullptr, &completion);
@ -120,7 +122,7 @@ static void BM_Pluck1Core(benchmark::State& state) {
for (auto _ : state) { for (auto _ : state) {
grpc_cq_completion completion; grpc_cq_completion completion;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); CHECK(grpc_cq_begin_op(cq, nullptr));
grpc_cq_end_op(cq, nullptr, absl::OkStatus(), DoneWithCompletionOnStack, grpc_cq_end_op(cq, nullptr, absl::OkStatus(), DoneWithCompletionOnStack,
nullptr, &completion); nullptr, &completion);
@ -160,7 +162,7 @@ class TagCallback : public grpc_completion_queue_functor {
~TagCallback() {} ~TagCallback() {}
static void Run(grpc_completion_queue_functor* cb, int ok) { static void Run(grpc_completion_queue_functor* cb, int ok) {
gpr_mu_lock(&mu); gpr_mu_lock(&mu);
GPR_ASSERT(static_cast<bool>(ok)); CHECK(static_cast<bool>(ok));
*static_cast<TagCallback*>(cb)->iter_ += 1; *static_cast<TagCallback*>(cb)->iter_ += 1;
gpr_cv_signal(&cv); gpr_cv_signal(&cv);
gpr_mu_unlock(&mu); gpr_mu_unlock(&mu);
@ -216,7 +218,7 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_cq_completion completion; grpc_cq_completion completion;
GPR_ASSERT(grpc_cq_begin_op(cc, &tag_cb)); CHECK(grpc_cq_begin_op(cc, &tag_cb));
grpc_cq_end_op(cc, &tag_cb, absl::OkStatus(), DoneWithCompletionOnStack, grpc_cq_end_op(cc, &tag_cb, absl::OkStatus(), DoneWithCompletionOnStack,
nullptr, &completion); nullptr, &completion);
} }
@ -237,8 +239,8 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) {
} }
gpr_mu_unlock(&shutdown_mu); gpr_mu_unlock(&shutdown_mu);
GPR_ASSERT(got_shutdown); CHECK(got_shutdown);
GPR_ASSERT(iteration == static_cast<int>(state.iterations())); CHECK(iteration == static_cast<int>(state.iterations()));
gpr_cv_destroy(&cv); gpr_cv_destroy(&cv);
gpr_mu_destroy(&mu); gpr_mu_destroy(&mu);
gpr_cv_destroy(&shutdown_cv); gpr_cv_destroy(&shutdown_cv);
@ -259,7 +261,7 @@ static void BM_Callback_CQ_Pass1CoreHeapCompletion(benchmark::State& state) {
grpc_core::ApplicationCallbackExecCtx callback_exec_ctx; grpc_core::ApplicationCallbackExecCtx callback_exec_ctx;
grpc_core::ExecCtx exec_ctx; grpc_core::ExecCtx exec_ctx;
grpc_cq_completion* completion = new grpc_cq_completion; grpc_cq_completion* completion = new grpc_cq_completion;
GPR_ASSERT(grpc_cq_begin_op(cc, &tag_cb)); CHECK(grpc_cq_begin_op(cc, &tag_cb));
grpc_cq_end_op(cc, &tag_cb, absl::OkStatus(), DoneWithCompletionOnHeap, grpc_cq_end_op(cc, &tag_cb, absl::OkStatus(), DoneWithCompletionOnHeap,
nullptr, completion); nullptr, completion);
} }
@ -280,8 +282,8 @@ static void BM_Callback_CQ_Pass1CoreHeapCompletion(benchmark::State& state) {
} }
gpr_mu_unlock(&shutdown_mu); gpr_mu_unlock(&shutdown_mu);
GPR_ASSERT(got_shutdown); CHECK(got_shutdown);
GPR_ASSERT(iteration == static_cast<int>(state.iterations())); CHECK(iteration == static_cast<int>(state.iterations()));
gpr_cv_destroy(&cv); gpr_cv_destroy(&cv);
gpr_mu_destroy(&mu); gpr_mu_destroy(&mu);
gpr_cv_destroy(&shutdown_cv); gpr_cv_destroy(&shutdown_cv);

@ -22,6 +22,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/alloc.h> #include <grpc/support/alloc.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -82,7 +84,7 @@ static grpc_error_handle pollset_work(grpc_pollset* ps,
gpr_mu_unlock(&ps->mu); gpr_mu_unlock(&ps->mu);
void* tag = reinterpret_cast<void*>(10); // Some random number void* tag = reinterpret_cast<void*>(10); // Some random number
GPR_ASSERT(grpc_cq_begin_op(g_cq, tag)); CHECK(grpc_cq_begin_op(g_cq, tag));
grpc_cq_end_op( grpc_cq_end_op(
g_cq, tag, absl::OkStatus(), cq_done_cb, nullptr, g_cq, tag, absl::OkStatus(), cq_done_cb, nullptr,
static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion)))); static_cast<grpc_cq_completion*>(gpr_malloc(sizeof(grpc_cq_completion))));
@ -117,9 +119,8 @@ static grpc_event_engine_vtable make_engine_vtable(const char* name) {
static void setup() { static void setup() {
grpc_init(); grpc_init();
GPR_ASSERT(strcmp(grpc_get_poll_strategy_name(), "none") == 0 || CHECK(strcmp(grpc_get_poll_strategy_name(), "none") == 0 ||
strcmp(grpc_get_poll_strategy_name(), "bm_cq_multiple_threads") == strcmp(grpc_get_poll_strategy_name(), "bm_cq_multiple_threads") == 0);
0);
g_cq = grpc_completion_queue_create_for_next(nullptr); g_cq = grpc_completion_queue_create_for_next(nullptr);
} }
@ -176,7 +177,7 @@ static void BM_Cq_Throughput(benchmark::State& state) {
gpr_mu_unlock(&g_mu); gpr_mu_unlock(&g_mu);
for (auto _ : state) { for (auto _ : state) {
GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type == CHECK(grpc_completion_queue_next(g_cq, deadline, nullptr).type ==
GRPC_OP_COMPLETE); GRPC_OP_COMPLETE);
} }

@ -21,6 +21,7 @@
#include "absl/debugging/leak_check.h" #include "absl/debugging/leak_check.h"
#include "absl/functional/any_invocable.h" #include "absl/functional/any_invocable.h"
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/event_engine/event_engine.h> #include <grpc/event_engine/event_engine.h>
@ -160,7 +161,7 @@ FanoutParameters GetFanoutParameters(benchmark::State& state) {
(1 - std::pow(params.fanout, params.depth + 1)) / (1 - params.fanout); (1 - std::pow(params.fanout, params.depth + 1)) / (1 - params.fanout);
} }
// sanity checking // sanity checking
GPR_ASSERT(params.limit >= params.fanout * params.depth); CHECK(params.limit >= params.fanout * params.depth);
return params; return params;
} }

@ -19,6 +19,7 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "absl/strings/str_format.h" #include "absl/strings/str_format.h"
#include <grpc/support/cpu.h> #include <grpc/support/cpu.h>
@ -135,7 +136,7 @@ FanoutParameters GetFanoutParameters(benchmark::State& state) {
(1 - std::pow(params.fanout, params.depth + 1)) / (1 - params.fanout); (1 - std::pow(params.fanout, params.depth + 1)) / (1 - params.fanout);
} }
// sanity checking // sanity checking
GPR_ASSERT(params.limit >= params.fanout * params.depth); CHECK(params.limit >= params.fanout * params.depth);
return params; return params;
} }

@ -23,6 +23,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/callback_test_service.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
@ -68,8 +70,8 @@ class BidiClient : public grpc::ClientBidiReactor<EchoRequest, EchoResponse> {
} }
void OnDone(const Status& s) override { void OnDone(const Status& s) override {
GPR_ASSERT(s.ok()); CHECK(s.ok());
GPR_ASSERT(writes_complete_ == msgs_to_send_); CHECK_EQ(writes_complete_, msgs_to_send_);
if (state_->KeepRunning()) { if (state_->KeepRunning()) {
writes_complete_ = 0; writes_complete_ = 0;
StartNewRpc(); StartNewRpc();

@ -18,6 +18,8 @@
#include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/callback_test_service.h"
#include "absl/log/check.h"
namespace grpc { namespace grpc {
namespace testing { namespace testing {
namespace { namespace {
@ -71,7 +73,7 @@ CallbackStreamingTestService::BidiStream(CallbackServerContext* context) {
StartRead(&request_); StartRead(&request_);
} }
void OnDone() override { void OnDone() override {
GPR_ASSERT(finished_); CHECK(finished_);
delete this; delete this;
} }
void OnCancel() override {} void OnCancel() override {}

@ -25,6 +25,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/callback_test_service.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
@ -46,7 +48,7 @@ inline void SendCallbackUnaryPingPong(
stub_->async()->Echo( stub_->async()->Echo(
cli_ctx, request, response, cli_ctx, request, response,
[state, cli_ctx, request, response, stub_, done, mu, cv](Status s) { [state, cli_ctx, request, response, stub_, done, mu, cv](Status s) {
GPR_ASSERT(s.ok()); CHECK(s.ok());
if (state->KeepRunning()) { if (state->KeepRunning()) {
cli_ctx->~ClientContext(); cli_ctx->~ClientContext();
new (cli_ctx) ClientContext(); new (cli_ctx) ClientContext();

@ -19,6 +19,8 @@
#ifndef GRPC_TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H #ifndef GRPC_TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H
#define GRPC_TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H #define GRPC_TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H
#include "absl/log/check.h"
#include <grpc/grpc.h> #include <grpc/grpc.h>
#include <grpc/support/atm.h> #include <grpc/support/atm.h>
#include <grpc/support/log.h> #include <grpc/support/log.h>
@ -183,10 +185,9 @@ class EndpointPairFixture : public BaseFixture {
grpc_endpoint_add_to_pollset(endpoints.server, pollset); grpc_endpoint_add_to_pollset(endpoints.server, pollset);
} }
GPR_ASSERT(GRPC_LOG_IF_ERROR( CHECK(GRPC_LOG_IF_ERROR("SetupTransport", core_server->SetupTransport(
"SetupTransport", server_transport_, nullptr,
core_server->SetupTransport(server_transport_, nullptr, server_args, server_args, nullptr)));
nullptr)));
grpc_chttp2_transport_start_reading(server_transport_, nullptr, nullptr, grpc_chttp2_transport_start_reading(server_transport_, nullptr, nullptr,
nullptr); nullptr);
} }
@ -207,7 +208,7 @@ class EndpointPairFixture : public BaseFixture {
} }
client_transport_ = client_transport_ =
grpc_create_chttp2_transport(c_args, endpoints.client, true); grpc_create_chttp2_transport(c_args, endpoints.client, true);
GPR_ASSERT(client_transport_); CHECK(client_transport_);
grpc_channel* channel = grpc_channel* channel =
grpc_core::ChannelCreate("target", c_args, GRPC_CLIENT_DIRECT_CHANNEL, grpc_core::ChannelCreate("target", c_args, GRPC_CLIENT_DIRECT_CHANNEL,
client_transport_) client_transport_)

@ -25,6 +25,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
#include "test/cpp/microbenchmarks/fullstack_fixtures.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h"
@ -82,10 +84,10 @@ static void BM_StreamingPingPong(benchmark::State& state) {
bool ok; bool ok;
int need_tags = (1 << 0) | (1 << 1); int need_tags = (1 << 0) | (1 << 1);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
@ -98,8 +100,8 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3); need_tags = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
// If server recv is complete, start the server send operation // If server recv is complete, start the server send operation
@ -107,7 +109,7 @@ static void BM_StreamingPingPong(benchmark::State& state) {
response_rw.Write(send_response, tag(3)); response_rw.Write(send_response, tag(3));
} }
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
@ -122,13 +124,13 @@ static void BM_StreamingPingPong(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2); need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
GPR_ASSERT(recv_status.ok()); CHECK(recv_status.ok());
} }
} }
@ -173,10 +175,10 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
bool ok; bool ok;
int need_tags = (1 << 0) | (1 << 1); int need_tags = (1 << 0) | (1 << 1);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
@ -187,8 +189,8 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3); need_tags = (1 << 0) | (1 << 1) | (1 << 2) | (1 << 3);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
// If server recv is complete, start the server send operation // If server recv is complete, start the server send operation
@ -196,7 +198,7 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
response_rw.Write(send_response, tag(3)); response_rw.Write(send_response, tag(3));
} }
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
} }
@ -208,13 +210,13 @@ static void BM_StreamingPingPongMsgs(benchmark::State& state) {
need_tags = (1 << 0) | (1 << 1) | (1 << 2); need_tags = (1 << 0) | (1 << 1) | (1 << 2);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
GPR_ASSERT(recv_status.ok()); CHECK(recv_status.ok());
} }
fixture.reset(); fixture.reset();
@ -294,14 +296,14 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
// initialized (async stream between client side and server side // initialized (async stream between client side and server side
// established). It is necessary when client init metadata is // established). It is necessary when client init metadata is
// coalesced // coalesced
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
while (static_cast<int>(reinterpret_cast<intptr_t>(t)) != 0) { while (static_cast<int>(reinterpret_cast<intptr_t>(t)) != 0) {
// In some cases tag:2 comes before tag:0 (write tag comes out // In some cases tag:2 comes before tag:0 (write tag comes out
// first), this while loop is to make sure get tag:0. // first), this while loop is to make sure get tag:0.
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(await_tags & (1 << i)); CHECK(await_tags & (1 << i));
await_tags &= ~(1 << i); await_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
} }
} }
@ -313,8 +315,8 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
await_tags |= (1 << 5); await_tags |= (1 << 5);
while (await_tags != 0) { while (await_tags != 0) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
// If server recv is complete, start the server send operation // If server recv is complete, start the server send operation
@ -339,7 +341,7 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
} }
} }
GPR_ASSERT(expect_tags & (1 << i)); CHECK(expect_tags & (1 << i));
expect_tags &= ~(1 << i); expect_tags &= ~(1 << i);
await_tags &= ~(1 << i); await_tags &= ~(1 << i);
} }
@ -364,12 +366,12 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
request_rw->WritesDone(tag(6)); request_rw->WritesDone(tag(6));
// wait for server call data structure(call_hook, etc.) to be // wait for server call data structure(call_hook, etc.) to be
// initialized, since initial metadata is corked. // initialized, since initial metadata is corked.
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
while (static_cast<int>(reinterpret_cast<intptr_t>(t)) != 0) { while (static_cast<int>(reinterpret_cast<intptr_t>(t)) != 0) {
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(expect_tags & (1 << i)); CHECK(expect_tags & (1 << i));
expect_tags &= ~(1 << i); expect_tags &= ~(1 << i);
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
} }
response_rw.Finish(Status::OK, tag(7)); response_rw.Finish(Status::OK, tag(7));
} else { } else {
@ -382,13 +384,13 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) {
request_rw->Finish(&recv_status, tag(8)); request_rw->Finish(&recv_status, tag(8));
while (expect_tags) { while (expect_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(expect_tags & (1 << i)); CHECK(expect_tags & (1 << i));
expect_tags &= ~(1 << i); expect_tags &= ~(1 << i);
} }
GPR_ASSERT(recv_status.ok()); CHECK(recv_status.ok());
} }
} }

@ -25,6 +25,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
#include "test/cpp/microbenchmarks/fullstack_fixtures.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h"
@ -61,17 +63,17 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
void* t; void* t;
bool ok; bool ok;
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
response_rw.Read(&recv_request, tag(0)); response_rw.Read(&recv_request, tag(0));
for (auto _ : state) { for (auto _ : state) {
request_rw->Write(send_request, tag(1)); request_rw->Write(send_request, tag(1));
while (true) { while (true) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
if (t == tag(0)) { if (t == tag(0)) {
response_rw.Read(&recv_request, tag(0)); response_rw.Read(&recv_request, tag(0));
} else if (t == tag(1)) { } else if (t == tag(1)) {
@ -84,9 +86,9 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
request_rw->WritesDone(tag(1)); request_rw->WritesDone(tag(1));
need_tags = (1 << 0) | (1 << 1); need_tags = (1 << 0) | (1 << 1);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
response_rw.Finish(Status::OK, tag(0)); response_rw.Finish(Status::OK, tag(0));
@ -94,12 +96,12 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) {
request_rw->Finish(&final_status, tag(1)); request_rw->Finish(&final_status, tag(1));
need_tags = (1 << 0) | (1 << 1); need_tags = (1 << 0) | (1 << 1);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
GPR_ASSERT(final_status.ok()); CHECK(final_status.ok());
} }
fixture.reset(); fixture.reset();
state.SetBytesProcessed(state.range(0) * state.iterations()); state.SetBytesProcessed(state.range(0) * state.iterations());
@ -128,17 +130,17 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
void* t; void* t;
bool ok; bool ok;
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
request_rw->Read(&recv_response, tag(0)); request_rw->Read(&recv_response, tag(0));
for (auto _ : state) { for (auto _ : state) {
response_rw.Write(send_response, tag(1)); response_rw.Write(send_response, tag(1));
while (true) { while (true) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
if (t == tag(0)) { if (t == tag(0)) {
request_rw->Read(&recv_response, tag(0)); request_rw->Read(&recv_response, tag(0));
} else if (t == tag(1)) { } else if (t == tag(1)) {
@ -151,9 +153,9 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) {
response_rw.Finish(Status::OK, tag(1)); response_rw.Finish(Status::OK, tag(1));
need_tags = (1 << 0) | (1 << 1); need_tags = (1 << 0) | (1 << 1);
while (need_tags) { while (need_tags) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
int i = static_cast<int>(reinterpret_cast<intptr_t>(t)); int i = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(need_tags & (1 << i)); CHECK(need_tags & (1 << i));
need_tags &= ~(1 << i); need_tags &= ~(1 << i);
} }
} }

@ -25,6 +25,8 @@
#include <benchmark/benchmark.h> #include <benchmark/benchmark.h>
#include "absl/log/check.h"
#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h"
#include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h"
#include "test/cpp/microbenchmarks/fullstack_fixtures.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h"
@ -81,21 +83,21 @@ static void BM_UnaryPingPong(benchmark::State& state) {
response_reader->Finish(&recv_response, &recv_status, tag(4)); response_reader->Finish(&recv_response, &recv_status, tag(4));
void* t; void* t;
bool ok; bool ok;
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
GPR_ASSERT(t == tag(0) || t == tag(1)); CHECK(t == tag(0) || t == tag(1));
intptr_t slot = reinterpret_cast<intptr_t>(t); intptr_t slot = reinterpret_cast<intptr_t>(t);
ServerEnv* senv = server_env[slot]; ServerEnv* senv = server_env[slot];
ServerContextMutator svr_ctx_mut(&senv->ctx); ServerContextMutator svr_ctx_mut(&senv->ctx);
senv->response_writer.Finish(send_response, Status::OK, tag(3)); senv->response_writer.Finish(send_response, Status::OK, tag(3));
for (int i = (1 << 3) | (1 << 4); i != 0;) { for (int i = (1 << 3) | (1 << 4); i != 0;) {
GPR_ASSERT(fixture->cq()->Next(&t, &ok)); CHECK(fixture->cq()->Next(&t, &ok));
GPR_ASSERT(ok); CHECK(ok);
int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t)); int tagnum = static_cast<int>(reinterpret_cast<intptr_t>(t));
GPR_ASSERT(i & (1 << tagnum)); CHECK(i & (1 << tagnum));
i -= 1 << tagnum; i -= 1 << tagnum;
} }
GPR_ASSERT(recv_status.ok()); CHECK(recv_status.ok());
senv->~ServerEnv(); senv->~ServerEnv();
senv = new (senv) ServerEnv(); senv = new (senv) ServerEnv();

@ -20,18 +20,18 @@
#include <string.h> #include <string.h>
#include <grpc/support/log.h> #include "absl/log/check.h"
static LibraryInitializer* g_libraryInitializer; static LibraryInitializer* g_libraryInitializer;
LibraryInitializer::LibraryInitializer() { LibraryInitializer::LibraryInitializer() {
GPR_ASSERT(g_libraryInitializer == nullptr); CHECK_EQ(g_libraryInitializer, nullptr);
g_libraryInitializer = this; g_libraryInitializer = this;
} }
LibraryInitializer::~LibraryInitializer() { g_libraryInitializer = nullptr; } LibraryInitializer::~LibraryInitializer() { g_libraryInitializer = nullptr; }
LibraryInitializer& LibraryInitializer::get() { LibraryInitializer& LibraryInitializer::get() {
GPR_ASSERT(g_libraryInitializer != nullptr); CHECK_NE(g_libraryInitializer, nullptr);
return *g_libraryInitializer; return *g_libraryInitializer;
} }

Loading…
Cancel
Save