From dc848c3e054ef9366af749a364189355139aba9b Mon Sep 17 00:00:00 2001 From: Tanvi Jagtap <139093547+tanvi-jagtap@users.noreply.github.com> Date: Fri, 19 Apr 2024 18:32:37 -0700 Subject: [PATCH] [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT (#36405) [grpc][Gpr_To_Absl_Logging] Migrating from gpr to absl logging GPR_ASSERT Replacing GPR_ASSERT with absl CHECK These changes have been made using string replacement and regex. Will not be replacing all instances of CHECK with CHECK_EQ , CHECK_NE etc because there are too many callsites. Only ones which are doable using very simple regex with least chance of failure will be replaced. 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 #36405 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36405 from tanvi-jagtap:tjagtap_microbenchmarks_01 0dcec5d852af05d7b24625a44b77318856114541 PiperOrigin-RevId: 626522246 --- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 4 ++-- test/cpp/microbenchmarks/bm_chttp2_transport.cc | 2 +- test/cpp/microbenchmarks/bm_event_engine_run.cc | 4 ++-- test/cpp/microbenchmarks/bm_thread_pool.cc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 29dd386db58..05045fc5a12 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -365,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); - CHECK(error.ok()); + CHECK_OK(error); } }; parse_vec(init_slices); @@ -445,7 +445,7 @@ class FromEncoderFixture { } // Remove the HTTP header. CHECK(!out.empty()); - CHECK(GRPC_SLICE_LENGTH(out[0]) > 9); + CHECK_GT(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 9321c2347cf..909cee97cf3 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -395,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) { - CHECK(error.ok()); + CHECK_OK(error); gpr_event_set(stream_cancel_done, reinterpret_cast(1)); }); op.on_complete = stream_cancel_closure.get(); diff --git a/test/cpp/microbenchmarks/bm_event_engine_run.cc b/test/cpp/microbenchmarks/bm_event_engine_run.cc index 1dcbbe81465..6c7fc5a5708 100644 --- a/test/cpp/microbenchmarks/bm_event_engine_run.cc +++ b/test/cpp/microbenchmarks/bm_event_engine_run.cc @@ -181,7 +181,7 @@ void FanOutCallback(std::shared_ptr engine, signal.Notify(); return; } - GPR_DEBUG_ASSERT(local_cnt < params.limit); + DCHECK_LT(local_cnt, params.limit); if (params.depth == processing_layer) return; for (int i = 0; i < params.fanout; i++) { engine->Run([engine, params, processing_layer, &count, &signal]() { @@ -244,7 +244,7 @@ void BM_EventEngine_Closure_FanOut(benchmark::State& state) { })); } for (auto _ : state) { - GPR_DEBUG_ASSERT(count.load(std::memory_order_relaxed) == 0); + DCHECK_EQ(count.load(std::memory_order_relaxed), 0); engine->Run(closures[params.depth + 1]); do { signal->WaitForNotification(); diff --git a/test/cpp/microbenchmarks/bm_thread_pool.cc b/test/cpp/microbenchmarks/bm_thread_pool.cc index b0e101109eb..351b6921bfc 100644 --- a/test/cpp/microbenchmarks/bm_thread_pool.cc +++ b/test/cpp/microbenchmarks/bm_thread_pool.cc @@ -156,7 +156,7 @@ void FanOutCallback(std::shared_ptr pool, signal.Notify(); return; } - GPR_DEBUG_ASSERT(local_cnt < params.limit); + DCHECK_LT(local_cnt, params.limit); if (params.depth == processing_layer) return; for (int i = 0; i < params.fanout; i++) { pool->Run([pool, params, processing_layer, &count, &signal]() { @@ -222,7 +222,7 @@ void BM_ThreadPool_Closure_FanOut(benchmark::State& state) { })); } for (auto _ : state) { - GPR_DEBUG_ASSERT(count.load(std::memory_order_relaxed) == 0); + DCHECK_EQ(count.load(std::memory_order_relaxed), 0); pool->Run(closures[params.depth + 1]); do { signal->WaitForNotification();