From 3e0eeed4fa4dd57f10084f0461c382497d2d6f11 Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Wed, 10 Apr 2024 06:00:15 -0700 Subject: [PATCH] =?UTF-8?q?[grpc][Gpr=5FTo=5FAbsl=5FLogging]=20Migrating?= =?UTF-8?q?=20from=20gpr=20to=20absl=20logging=20GPR=5FAS=E2=80=A6=20(#362?= =?UTF-8?q?67)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [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. Closes #36267 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36267 from tanvi-jagtap:tjagtap_grpc_assert_02 3aed62610192ef9e46b2b25f215e694a4a6f6862 PiperOrigin-RevId: 623469007 --- CMakeLists.txt | 1 + build_autogenerated.yaml | 1 + test/cpp/microbenchmarks/BUILD | 40 +++++++++++- .../microbenchmarks/bm_basic_work_queue.cc | 8 ++- test/cpp/microbenchmarks/bm_byte_buffer.cc | 10 +-- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 7 ++- .../microbenchmarks/bm_chttp2_transport.cc | 8 ++- test/cpp/microbenchmarks/bm_cq.cc | 22 ++++--- .../microbenchmarks/bm_cq_multiple_threads.cc | 13 ++-- .../microbenchmarks/bm_event_engine_run.cc | 3 +- test/cpp/microbenchmarks/bm_thread_pool.cc | 3 +- .../callback_streaming_ping_pong.h | 6 +- .../microbenchmarks/callback_test_service.cc | 4 +- .../callback_unary_ping_pong.h | 4 +- test/cpp/microbenchmarks/fullstack_fixtures.h | 11 ++-- .../fullstack_streaming_ping_pong.h | 62 ++++++++++--------- .../fullstack_streaming_pump.h | 32 +++++----- .../fullstack_unary_ping_pong.h | 16 ++--- test/cpp/microbenchmarks/helpers.cc | 6 +- 19 files changed, 161 insertions(+), 96 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f54a1859548..b42fc76fee6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4021,6 +4021,7 @@ target_include_directories(benchmark_helpers ) target_link_libraries(benchmark_helpers ${_gRPC_ALLTARGETS_LIBRARIES} + absl::check ${_gRPC_BENCHMARK_LIBRARIES} grpc++_unsecure grpc_test_util_unsecure diff --git a/build_autogenerated.yaml b/build_autogenerated.yaml index 116f68e9ae3..6685eea1008 100644 --- a/build_autogenerated.yaml +++ b/build_autogenerated.yaml @@ -3620,6 +3620,7 @@ libs: - test/core/util/tracer_util.cc - test/cpp/microbenchmarks/helpers.cc deps: + - absl/log:check - benchmark - grpc++_unsecure - grpc_test_util_unsecure diff --git a/test/cpp/microbenchmarks/BUILD b/test/cpp/microbenchmarks/BUILD index 68f2669c32d..7159f75a6ed 100644 --- a/test/cpp/microbenchmarks/BUILD +++ b/test/cpp/microbenchmarks/BUILD @@ -74,6 +74,7 @@ grpc_cc_test( srcs = ["bm_event_engine_run.cc"], args = grpc_benchmark_args(), external_deps = [ + "absl/log:check", "absl/debugging:leak_check", "benchmark", ], @@ -90,6 +91,7 @@ grpc_cc_test( srcs = ["bm_thread_pool.cc"], args = grpc_benchmark_args(), external_deps = [ + "absl/log:check", "benchmark", ], uses_event_engine = False, @@ -110,6 +112,7 @@ grpc_cc_library( "helpers.h", ], external_deps = [ + "absl/log:check", "benchmark", ], deps = [ @@ -132,6 +135,7 @@ grpc_cc_library( "helpers.h", ], external_deps = [ + "absl/log:check", "benchmark", ], deps = [ @@ -204,6 +208,9 @@ grpc_cc_test( name = "bm_byte_buffer", srcs = ["bm_byte_buffer.cc"], args = grpc_benchmark_args(), + external_deps = [ + "absl/log:check", + ], tags = [ "no_mac", "no_windows", @@ -230,6 +237,9 @@ grpc_cc_test( name = "bm_cq", srcs = ["bm_cq.cc"], args = grpc_benchmark_args(), + external_deps = [ + "absl/log:check", + ], tags = [ "no_mac", "no_windows", @@ -241,6 +251,9 @@ grpc_cc_test( name = "bm_cq_multiple_threads", srcs = ["bm_cq_multiple_threads.cc"], args = grpc_benchmark_args(), + external_deps = [ + "absl/log:check", + ], tags = [ "no_mac", "no_windows", @@ -256,6 +269,9 @@ grpc_cc_library( hdrs = [ "fullstack_streaming_ping_pong.h", ], + external_deps = [ + "absl/log:check", + ], tags = [ "no_mac", "no_windows", @@ -284,6 +300,9 @@ grpc_cc_library( hdrs = [ "fullstack_streaming_pump.h", ], + external_deps = [ + "absl/log:check", + ], deps = [":helpers"], ) @@ -306,6 +325,9 @@ grpc_cc_library( hdrs = [ "fullstack_unary_ping_pong.h", ], + external_deps = [ + "absl/log:check", + ], deps = [":helpers_secure"], ) @@ -344,6 +366,9 @@ grpc_cc_test( name = "bm_chttp2_hpack", srcs = ["bm_chttp2_hpack.cc"], args = grpc_benchmark_args(), + external_deps = [ + "absl/log:check", + ], tags = [ "no_mac", "no_windows", @@ -360,6 +385,9 @@ grpc_cc_test( name = "bm_chttp2_transport", srcs = ["bm_chttp2_transport.cc"], args = grpc_benchmark_args(), + external_deps = [ + "absl/log:check", + ], tags = [ "no_mac", "no_windows", @@ -390,6 +418,7 @@ grpc_cc_library( srcs = ["callback_test_service.cc"], hdrs = ["callback_test_service.h"], external_deps = [ + "absl/log:check", "benchmark", ], deps = [ @@ -405,6 +434,9 @@ grpc_cc_library( hdrs = [ "callback_unary_ping_pong.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ ":bm_callback_test_service_impl", ":helpers", @@ -433,6 +465,9 @@ grpc_cc_library( hdrs = [ "callback_streaming_ping_pong.h", ], + external_deps = [ + "absl/log:check", + ], deps = [ ":bm_callback_test_service_impl", ":helpers", @@ -460,7 +495,10 @@ grpc_cc_test( name = "bm_basic_work_queue", srcs = ["bm_basic_work_queue.cc"], args = grpc_benchmark_args(), - external_deps = ["benchmark"], + external_deps = [ + "absl/log:check", + "benchmark", + ], tags = [ "manual", "no_windows", diff --git a/test/cpp/microbenchmarks/bm_basic_work_queue.cc b/test/cpp/microbenchmarks/bm_basic_work_queue.cc index 094c61c0524..aa8f59ec810 100644 --- a/test/cpp/microbenchmarks/bm_basic_work_queue.cc +++ b/test/cpp/microbenchmarks/bm_basic_work_queue.cc @@ -15,6 +15,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -68,7 +70,7 @@ void BM_MultithreadedWorkQueuePopOldest(benchmark::State& state) { benchmark::Counter(element_count * state.iterations() / pop_attempts, benchmark::Counter::kAvgThreads); if (state.thread_index() == 0) { - GPR_ASSERT(globalWorkQueue.Empty()); + CHECK(globalWorkQueue.Empty()); } } BENCHMARK(BM_MultithreadedWorkQueuePopOldest) @@ -93,7 +95,7 @@ void BM_MultithreadedWorkQueuePopMostRecent(benchmark::State& state) { benchmark::Counter(element_count * state.iterations() / pop_attempts, benchmark::Counter::kAvgThreads); if (state.thread_index() == 0) { - GPR_ASSERT(globalWorkQueue.Empty()); + CHECK(globalWorkQueue.Empty()); } } BENCHMARK(BM_MultithreadedWorkQueuePopMostRecent) @@ -111,7 +113,7 @@ void BM_MultithreadedStdDequeLIFO(benchmark::State& state) { grpc_core::MutexLock lock(&globalMu); EventEngine::Closure* popped = globalDeque.back(); globalDeque.pop_back(); - GPR_ASSERT(popped != nullptr); + CHECK_NE(popped, nullptr); } } state.counters["added"] = element_count * state.iterations(); diff --git a/test/cpp/microbenchmarks/bm_byte_buffer.cc b/test/cpp/microbenchmarks/bm_byte_buffer.cc index a43be1115d3..552b302a813 100644 --- a/test/cpp/microbenchmarks/bm_byte_buffer.cc +++ b/test/cpp/microbenchmarks/bm_byte_buffer.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -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_reader reader; - GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); + CHECK(grpc_byte_buffer_reader_init(&reader, bb)); for (auto _ : state) { grpc_slice* slice; if (GPR_UNLIKELY(!grpc_byte_buffer_reader_peek(&reader, &slice))) { grpc_byte_buffer_reader_destroy(&reader); - GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); + CHECK(grpc_byte_buffer_reader_init(&reader, bb)); 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_reader reader; - GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); + CHECK(grpc_byte_buffer_reader_init(&reader, bb)); for (auto _ : state) { grpc_slice* slice; if (GPR_UNLIKELY(!grpc_byte_buffer_reader_peek(&reader, &slice))) { grpc_byte_buffer_reader_destroy(&reader); - GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb)); + CHECK(grpc_byte_buffer_reader_init(&reader, bb)); continue; } } diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index df358551224..29dd386db58 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -25,6 +25,7 @@ #include +#include "absl/log/check.h" #include "absl/random/random.h" #include @@ -364,7 +365,7 @@ static void BM_HpackParserParseHeader(benchmark::State& state) { auto error = p.Parse(slices[i], i == slices.size() - 1, absl::BitGenRef(bitgen), /*call_tracer=*/nullptr); - GPR_ASSERT(error.ok()); + CHECK(error.ok()); } }; parse_vec(init_slices); @@ -443,8 +444,8 @@ class FromEncoderFixture { i++; } // Remove the HTTP header. - GPR_ASSERT(!out.empty()); - GPR_ASSERT(GRPC_SLICE_LENGTH(out[0]) > 9); + CHECK(!out.empty()); + CHECK(GRPC_SLICE_LENGTH(out[0]) > 9); out[0] = grpc_slice_sub_no_ref(out[0], 9, GRPC_SLICE_LENGTH(out[0])); return out; } diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index 0160015eeab..9321c2347cf 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -26,6 +26,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -64,7 +66,7 @@ class PhonyEndpoint : public grpc_endpoint { void PushInput(grpc_slice slice) { if (read_cb_ == nullptr) { - GPR_ASSERT(!have_slice_); + CHECK(!have_slice_); buffered_slice_ = slice; have_slice_ = true; return; @@ -81,7 +83,7 @@ class PhonyEndpoint : public grpc_endpoint { grpc_slice buffered_slice_; void QueueRead(grpc_slice_buffer* slices, grpc_closure* cb) { - GPR_ASSERT(read_cb_ == nullptr); + CHECK_EQ(read_cb_, nullptr); if (have_slice_) { have_slice_ = false; grpc_slice_buffer_add(slices, buffered_slice_); @@ -393,7 +395,7 @@ static void BM_TransportEmptyOp(benchmark::State& state) { gpr_event_init(stream_cancel_done); std::unique_ptr stream_cancel_closure = MakeTestClosure([&](grpc_error_handle error) { - GPR_ASSERT(error.ok()); + CHECK(error.ok()); gpr_event_set(stream_cancel_done, reinterpret_cast(1)); }); op.on_complete = stream_cancel_closure.get(); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 373a233b6ed..f7bd13b0446 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -21,6 +21,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -85,7 +87,7 @@ static void BM_Pass1Cpp(benchmark::State& state) { grpc_cq_completion completion; PhonyTag phony_tag; 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(), DoneWithCompletionOnStack, nullptr, &completion); @@ -103,7 +105,7 @@ static void BM_Pass1Core(benchmark::State& state) { for (auto _ : state) { grpc_cq_completion completion; 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, nullptr, &completion); @@ -120,7 +122,7 @@ static void BM_Pluck1Core(benchmark::State& state) { for (auto _ : state) { grpc_cq_completion completion; 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, nullptr, &completion); @@ -160,7 +162,7 @@ class TagCallback : public grpc_completion_queue_functor { ~TagCallback() {} static void Run(grpc_completion_queue_functor* cb, int ok) { gpr_mu_lock(&mu); - GPR_ASSERT(static_cast(ok)); + CHECK(static_cast(ok)); *static_cast(cb)->iter_ += 1; gpr_cv_signal(&cv); 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::ExecCtx exec_ctx; 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, nullptr, &completion); } @@ -237,8 +239,8 @@ static void BM_Callback_CQ_Pass1Core(benchmark::State& state) { } gpr_mu_unlock(&shutdown_mu); - GPR_ASSERT(got_shutdown); - GPR_ASSERT(iteration == static_cast(state.iterations())); + CHECK(got_shutdown); + CHECK(iteration == static_cast(state.iterations())); gpr_cv_destroy(&cv); gpr_mu_destroy(&mu); 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::ExecCtx exec_ctx; 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, nullptr, completion); } @@ -280,8 +282,8 @@ static void BM_Callback_CQ_Pass1CoreHeapCompletion(benchmark::State& state) { } gpr_mu_unlock(&shutdown_mu); - GPR_ASSERT(got_shutdown); - GPR_ASSERT(iteration == static_cast(state.iterations())); + CHECK(got_shutdown); + CHECK(iteration == static_cast(state.iterations())); gpr_cv_destroy(&cv); gpr_mu_destroy(&mu); gpr_cv_destroy(&shutdown_cv); diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index bdfa8a34438..a82530d39c7 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -22,6 +22,8 @@ #include +#include "absl/log/check.h" + #include #include #include @@ -82,7 +84,7 @@ static grpc_error_handle pollset_work(grpc_pollset* ps, gpr_mu_unlock(&ps->mu); void* tag = reinterpret_cast(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( g_cq, tag, absl::OkStatus(), cq_done_cb, nullptr, static_cast(gpr_malloc(sizeof(grpc_cq_completion)))); @@ -117,9 +119,8 @@ static grpc_event_engine_vtable make_engine_vtable(const char* name) { static void setup() { grpc_init(); - GPR_ASSERT(strcmp(grpc_get_poll_strategy_name(), "none") == 0 || - strcmp(grpc_get_poll_strategy_name(), "bm_cq_multiple_threads") == - 0); + CHECK(strcmp(grpc_get_poll_strategy_name(), "none") == 0 || + strcmp(grpc_get_poll_strategy_name(), "bm_cq_multiple_threads") == 0); g_cq = grpc_completion_queue_create_for_next(nullptr); } @@ -176,8 +177,8 @@ static void BM_Cq_Throughput(benchmark::State& state) { gpr_mu_unlock(&g_mu); for (auto _ : state) { - GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type == - GRPC_OP_COMPLETE); + CHECK(grpc_completion_queue_next(g_cq, deadline, nullptr).type == + GRPC_OP_COMPLETE); } state.SetItemsProcessed(state.iterations()); diff --git a/test/cpp/microbenchmarks/bm_event_engine_run.cc b/test/cpp/microbenchmarks/bm_event_engine_run.cc index 53a6af9b316..1dcbbe81465 100644 --- a/test/cpp/microbenchmarks/bm_event_engine_run.cc +++ b/test/cpp/microbenchmarks/bm_event_engine_run.cc @@ -21,6 +21,7 @@ #include "absl/debugging/leak_check.h" #include "absl/functional/any_invocable.h" +#include "absl/log/check.h" #include "absl/strings/str_format.h" #include @@ -160,7 +161,7 @@ FanoutParameters GetFanoutParameters(benchmark::State& state) { (1 - std::pow(params.fanout, params.depth + 1)) / (1 - params.fanout); } // sanity checking - GPR_ASSERT(params.limit >= params.fanout * params.depth); + CHECK(params.limit >= params.fanout * params.depth); return params; } diff --git a/test/cpp/microbenchmarks/bm_thread_pool.cc b/test/cpp/microbenchmarks/bm_thread_pool.cc index 4a16f4864ad..b0e101109eb 100644 --- a/test/cpp/microbenchmarks/bm_thread_pool.cc +++ b/test/cpp/microbenchmarks/bm_thread_pool.cc @@ -19,6 +19,7 @@ #include +#include "absl/log/check.h" #include "absl/strings/str_format.h" #include @@ -135,7 +136,7 @@ FanoutParameters GetFanoutParameters(benchmark::State& state) { (1 - std::pow(params.fanout, params.depth + 1)) / (1 - params.fanout); } // sanity checking - GPR_ASSERT(params.limit >= params.fanout * params.depth); + CHECK(params.limit >= params.fanout * params.depth); return params; } diff --git a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h index 5c98f9bbfd0..3ac9a30b538 100644 --- a/test/cpp/microbenchmarks/callback_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_streaming_ping_pong.h @@ -23,6 +23,8 @@ #include +#include "absl/log/check.h" + #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h" @@ -68,8 +70,8 @@ class BidiClient : public grpc::ClientBidiReactor { } void OnDone(const Status& s) override { - GPR_ASSERT(s.ok()); - GPR_ASSERT(writes_complete_ == msgs_to_send_); + CHECK(s.ok()); + CHECK_EQ(writes_complete_, msgs_to_send_); if (state_->KeepRunning()) { writes_complete_ = 0; StartNewRpc(); diff --git a/test/cpp/microbenchmarks/callback_test_service.cc b/test/cpp/microbenchmarks/callback_test_service.cc index 87290f57d26..3b22041d4f3 100644 --- a/test/cpp/microbenchmarks/callback_test_service.cc +++ b/test/cpp/microbenchmarks/callback_test_service.cc @@ -18,6 +18,8 @@ #include "test/cpp/microbenchmarks/callback_test_service.h" +#include "absl/log/check.h" + namespace grpc { namespace testing { namespace { @@ -71,7 +73,7 @@ CallbackStreamingTestService::BidiStream(CallbackServerContext* context) { StartRead(&request_); } void OnDone() override { - GPR_ASSERT(finished_); + CHECK(finished_); delete this; } void OnCancel() override {} diff --git a/test/cpp/microbenchmarks/callback_unary_ping_pong.h b/test/cpp/microbenchmarks/callback_unary_ping_pong.h index 550e0210eca..a7188fc1f0d 100644 --- a/test/cpp/microbenchmarks/callback_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/callback_unary_ping_pong.h @@ -25,6 +25,8 @@ #include +#include "absl/log/check.h" + #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/microbenchmarks/callback_test_service.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h" @@ -46,7 +48,7 @@ inline void SendCallbackUnaryPingPong( stub_->async()->Echo( cli_ctx, request, response, [state, cli_ctx, request, response, stub_, done, mu, cv](Status s) { - GPR_ASSERT(s.ok()); + CHECK(s.ok()); if (state->KeepRunning()) { cli_ctx->~ClientContext(); new (cli_ctx) ClientContext(); diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 40f1a032906..338d5b3d7f1 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -19,6 +19,8 @@ #ifndef GRPC_TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H #define GRPC_TEST_CPP_MICROBENCHMARKS_FULLSTACK_FIXTURES_H +#include "absl/log/check.h" + #include #include #include @@ -183,10 +185,9 @@ class EndpointPairFixture : public BaseFixture { grpc_endpoint_add_to_pollset(endpoints.server, pollset); } - GPR_ASSERT(GRPC_LOG_IF_ERROR( - "SetupTransport", - core_server->SetupTransport(server_transport_, nullptr, server_args, - nullptr))); + CHECK(GRPC_LOG_IF_ERROR("SetupTransport", core_server->SetupTransport( + server_transport_, nullptr, + server_args, nullptr))); grpc_chttp2_transport_start_reading(server_transport_, nullptr, nullptr, nullptr); } @@ -207,7 +208,7 @@ class EndpointPairFixture : public BaseFixture { } client_transport_ = grpc_create_chttp2_transport(c_args, endpoints.client, true); - GPR_ASSERT(client_transport_); + CHECK(client_transport_); grpc_channel* channel = grpc_core::ChannelCreate("target", c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_) diff --git a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h index 26ca9d22d65..6fd8ba807fe 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_ping_pong.h @@ -25,6 +25,8 @@ #include +#include "absl/log/check.h" + #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h" @@ -82,10 +84,10 @@ static void BM_StreamingPingPong(benchmark::State& state) { bool ok; int need_tags = (1 << 0) | (1 << 1); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(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); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); // 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)); } - GPR_ASSERT(need_tags & (1 << i)); + CHECK(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); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(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; int need_tags = (1 << 0) | (1 << 1); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(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); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); // 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)); } - GPR_ASSERT(need_tags & (1 << i)); + CHECK(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); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(need_tags & (1 << i)); need_tags &= ~(1 << i); } - GPR_ASSERT(recv_status.ok()); + CHECK(recv_status.ok()); } fixture.reset(); @@ -294,14 +296,14 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { // initialized (async stream between client side and server side // established). It is necessary when client init metadata is // coalesced - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); while (static_cast(reinterpret_cast(t)) != 0) { // In some cases tag:2 comes before tag:0 (write tag comes out // first), this while loop is to make sure get tag:0. int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(await_tags & (1 << i)); + CHECK(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); while (await_tags != 0) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); // 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); await_tags &= ~(1 << i); } @@ -364,12 +366,12 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { request_rw->WritesDone(tag(6)); // wait for server call data structure(call_hook, etc.) to be // initialized, since initial metadata is corked. - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); while (static_cast(reinterpret_cast(t)) != 0) { int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(expect_tags & (1 << i)); + CHECK(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)); } else { @@ -382,13 +384,13 @@ static void BM_StreamingPingPongWithCoalescingApi(benchmark::State& state) { request_rw->Finish(&recv_status, tag(8)); while (expect_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(expect_tags & (1 << i)); + CHECK(expect_tags & (1 << i)); expect_tags &= ~(1 << i); } - GPR_ASSERT(recv_status.ok()); + CHECK(recv_status.ok()); } } diff --git a/test/cpp/microbenchmarks/fullstack_streaming_pump.h b/test/cpp/microbenchmarks/fullstack_streaming_pump.h index a76de55dbad..df0953fd9b0 100644 --- a/test/cpp/microbenchmarks/fullstack_streaming_pump.h +++ b/test/cpp/microbenchmarks/fullstack_streaming_pump.h @@ -25,6 +25,8 @@ #include +#include "absl/log/check.h" + #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.h" #include "test/cpp/microbenchmarks/fullstack_fixtures.h" @@ -61,17 +63,17 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) { void* t; bool ok; while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(need_tags & (1 << i)); need_tags &= ~(1 << i); } response_rw.Read(&recv_request, tag(0)); for (auto _ : state) { request_rw->Write(send_request, tag(1)); while (true) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); if (t == tag(0)) { response_rw.Read(&recv_request, tag(0)); } else if (t == tag(1)) { @@ -84,9 +86,9 @@ static void BM_PumpStreamClientToServer(benchmark::State& state) { request_rw->WritesDone(tag(1)); need_tags = (1 << 0) | (1 << 1); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(need_tags & (1 << i)); need_tags &= ~(1 << i); } 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)); need_tags = (1 << 0) | (1 << 1); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(need_tags & (1 << i)); need_tags &= ~(1 << i); } - GPR_ASSERT(final_status.ok()); + CHECK(final_status.ok()); } fixture.reset(); state.SetBytesProcessed(state.range(0) * state.iterations()); @@ -128,17 +130,17 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) { void* t; bool ok; while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(need_tags & (1 << i)); need_tags &= ~(1 << i); } request_rw->Read(&recv_response, tag(0)); for (auto _ : state) { response_rw.Write(send_response, tag(1)); while (true) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); if (t == tag(0)) { request_rw->Read(&recv_response, tag(0)); } else if (t == tag(1)) { @@ -151,9 +153,9 @@ static void BM_PumpStreamServerToClient(benchmark::State& state) { response_rw.Finish(Status::OK, tag(1)); need_tags = (1 << 0) | (1 << 1); while (need_tags) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); + CHECK(fixture->cq()->Next(&t, &ok)); int i = static_cast(reinterpret_cast(t)); - GPR_ASSERT(need_tags & (1 << i)); + CHECK(need_tags & (1 << i)); need_tags &= ~(1 << i); } } diff --git a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h index 869646ada91..06e4d9e16a8 100644 --- a/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h +++ b/test/cpp/microbenchmarks/fullstack_unary_ping_pong.h @@ -25,6 +25,8 @@ #include +#include "absl/log/check.h" + #include "src/proto/grpc/testing/echo.grpc.pb.h" #include "test/cpp/microbenchmarks/fullstack_context_mutators.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)); void* t; bool ok; - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); - GPR_ASSERT(t == tag(0) || t == tag(1)); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); + CHECK(t == tag(0) || t == tag(1)); intptr_t slot = reinterpret_cast(t); ServerEnv* senv = server_env[slot]; ServerContextMutator svr_ctx_mut(&senv->ctx); senv->response_writer.Finish(send_response, Status::OK, tag(3)); for (int i = (1 << 3) | (1 << 4); i != 0;) { - GPR_ASSERT(fixture->cq()->Next(&t, &ok)); - GPR_ASSERT(ok); + CHECK(fixture->cq()->Next(&t, &ok)); + CHECK(ok); int tagnum = static_cast(reinterpret_cast(t)); - GPR_ASSERT(i & (1 << tagnum)); + CHECK(i & (1 << tagnum)); i -= 1 << tagnum; } - GPR_ASSERT(recv_status.ok()); + CHECK(recv_status.ok()); senv->~ServerEnv(); senv = new (senv) ServerEnv(); diff --git a/test/cpp/microbenchmarks/helpers.cc b/test/cpp/microbenchmarks/helpers.cc index 5e9be0807d9..362ef566812 100644 --- a/test/cpp/microbenchmarks/helpers.cc +++ b/test/cpp/microbenchmarks/helpers.cc @@ -20,18 +20,18 @@ #include -#include +#include "absl/log/check.h" static LibraryInitializer* g_libraryInitializer; LibraryInitializer::LibraryInitializer() { - GPR_ASSERT(g_libraryInitializer == nullptr); + CHECK_EQ(g_libraryInitializer, nullptr); g_libraryInitializer = this; } LibraryInitializer::~LibraryInitializer() { g_libraryInitializer = nullptr; } LibraryInitializer& LibraryInitializer::get() { - GPR_ASSERT(g_libraryInitializer != nullptr); + CHECK_NE(g_libraryInitializer, nullptr); return *g_libraryInitializer; }