diff options
author | 2017-11-16 19:31:28 -0800 | |
---|---|---|
committer | 2017-11-16 19:31:28 -0800 | |
commit | 177039b2f89e73ad0d048da021f939f3a153c4e2 (patch) | |
tree | c7f10f04cd9a0872863e2b181162bc9928160cd8 /test/cpp/microbenchmarks | |
parent | 995aa91bbbc68deb6dfd7c667cfee3af2bedec08 (diff) | |
parent | 82c8f945302f128495e261b853ac49f1dfbe69a1 (diff) |
Merge master
Diffstat (limited to 'test/cpp/microbenchmarks')
-rw-r--r-- | test/cpp/microbenchmarks/bm_call_create.cc | 91 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 6 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_chttp2_transport.cc | 8 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_closure.cc | 60 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_cq.cc | 31 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_cq_multiple_threads.cc | 8 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_error.cc | 8 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_fullstack_trickle.cc | 4 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_metadata.cc | 22 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/bm_pollset.cc | 8 | ||||
-rw-r--r-- | test/cpp/microbenchmarks/fullstack_fixtures.h | 10 |
11 files changed, 133 insertions, 123 deletions
diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index bb76a2e762..b17f79613a 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -91,7 +91,7 @@ class InsecureChannel : public BaseChannelFixture { public: InsecureChannel() : BaseChannelFixture( - grpc_insecure_channel_create("localhost:1234", NULL, NULL)) {} + grpc_insecure_channel_create("localhost:1234", nullptr, nullptr)) {} }; class LameChannel : public BaseChannelFixture { @@ -105,14 +105,14 @@ template <class Fixture> static void BM_CallCreateDestroy(benchmark::State& state) { TrackCounters track_counters; Fixture fixture; - grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", + nullptr, nullptr); while (state.KeepRunning()) { grpc_call_unref(grpc_channel_create_registered_call( - fixture.channel(), NULL, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl, - deadline, NULL)); + fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, cq, method_hdl, + deadline, nullptr)); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); @@ -161,7 +161,7 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { grpc_completion_queue* cq; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer* response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = nullptr; grpc_status_code status; grpc_slice details; grpc::testing::EchoRequest send_request; @@ -170,14 +170,14 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { channel = grpc_lame_client_channel_create( "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"); - cq = grpc_completion_queue_create_for_next(NULL); + cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( - channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL); + channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( - channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, + gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); grpc_byte_buffer* request_payload_send = @@ -210,9 +210,9 @@ static void BM_LameChannelCallCreateCore(benchmark::State& state) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void*)1, NULL)); + (void*)1, nullptr)); grpc_event ev = grpc_completion_queue_next( - cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); GPR_ASSERT(ev.success != 0); grpc_call_unref(call); @@ -235,7 +235,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { grpc_completion_queue* cq; grpc_metadata_array initial_metadata_recv; grpc_metadata_array trailing_metadata_recv; - grpc_byte_buffer* response_payload_recv = NULL; + grpc_byte_buffer* response_payload_recv = nullptr; grpc_status_code status; grpc_slice details; grpc::testing::EchoRequest send_request; @@ -244,14 +244,14 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { channel = grpc_lame_client_channel_create( "localhost:1234", GRPC_STATUS_UNAUTHENTICATED, "blah"); - cq = grpc_completion_queue_create_for_next(NULL); + cq = grpc_completion_queue_create_for_next(nullptr); void* rc = grpc_channel_register_call( - channel, "/grpc.testing.EchoTestService/Echo", NULL, NULL); + channel, "/grpc.testing.EchoTestService/Echo", nullptr, nullptr); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( - channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, rc, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + channel, nullptr, GRPC_PROPAGATE_DEFAULTS, cq, rc, + gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); grpc_metadata_array_init(&initial_metadata_recv); grpc_metadata_array_init(&trailing_metadata_recv); grpc_byte_buffer* request_payload_send = @@ -271,7 +271,7 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { op++; GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void*)0, NULL)); + (void*)nullptr, nullptr)); memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_INITIAL_METADATA; @@ -289,13 +289,13 @@ static void BM_LameChannelCallCreateCoreSeparateBatch(benchmark::State& state) { GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops, (size_t)(op - ops), - (void*)1, NULL)); + (void*)1, nullptr)); grpc_event ev = grpc_completion_queue_next( - cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + cq, gpr_inf_future(GPR_CLOCK_REALTIME), nullptr); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); GPR_ASSERT(ev.success == 0); ev = grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), - NULL); + nullptr); GPR_ASSERT(ev.type != GRPC_QUEUE_SHUTDOWN); GPR_ASSERT(ev.success != 0); grpc_call_unref(call); @@ -523,7 +523,7 @@ static void BM_IsolatedFilter(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; size_t channel_size = grpc_channel_stack_size( - filters.size() == 0 ? NULL : &filters[0], filters.size()); + filters.size() == 0 ? nullptr : &filters[0], filters.size()); grpc_channel_stack* channel_stack = static_cast<grpc_channel_stack*>(gpr_zalloc(channel_size)); GPR_ASSERT(GRPC_LOG_IF_ERROR( @@ -544,8 +544,8 @@ static void BM_IsolatedFilter(benchmark::State& state) { TestOp test_op_data; grpc_call_element_args call_args; call_args.call_stack = call_stack; - call_args.server_transport_data = NULL; - call_args.context = NULL; + call_args.server_transport_data = nullptr; + call_args.context = nullptr; call_args.path = method; call_args.start_time = start_time; call_args.deadline = deadline; @@ -554,9 +554,9 @@ static void BM_IsolatedFilter(benchmark::State& state) { while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); GRPC_ERROR_UNREF( - grpc_call_stack_init(channel_stack, 1, DoNothing, NULL, &call_args)); + grpc_call_stack_init(channel_stack, 1, DoNothing, nullptr, &call_args)); typename TestOp::Op op(&test_op_data, call_stack); - grpc_call_stack_destroy(call_stack, &final_info, NULL); + grpc_call_stack_destroy(call_stack, &final_info, nullptr); op.Finish(); grpc_core::ExecCtx::Get()->Flush(); // recreate arena every 64k iterations to avoid oom @@ -689,12 +689,13 @@ class IsolatedCallFixture : public TrackCounters { grpc_channel_stack_builder_set_name(builder, "dummy"); grpc_channel_stack_builder_set_target(builder, "dummy_target"); GPR_ASSERT(grpc_channel_stack_builder_append_filter( - builder, &isolated_call_filter::isolated_call_filter, NULL, NULL)); + builder, &isolated_call_filter::isolated_call_filter, nullptr, + nullptr)); { grpc_core::ExecCtx _local_exec_ctx; channel_ = grpc_channel_create_with_builder(builder, GRPC_CLIENT_CHANNEL); } - cq_ = grpc_completion_queue_create_for_next(NULL); + cq_ = grpc_completion_queue_create_for_next(nullptr); } void Finish(benchmark::State& state) { @@ -714,13 +715,13 @@ class IsolatedCallFixture : public TrackCounters { static void BM_IsolatedCall_NoOp(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", + nullptr, nullptr); while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call_unref(grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), - method_hdl, deadline, NULL)); + method_hdl, deadline, nullptr)); } fixture.Finish(state); } @@ -729,11 +730,11 @@ BENCHMARK(BM_IsolatedCall_NoOp); static void BM_IsolatedCall_Unary(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", + nullptr, nullptr); grpc_slice slice = grpc_slice_from_static_string("hello world"); grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1); - grpc_byte_buffer* recv_message = NULL; + grpc_byte_buffer* recv_message = nullptr; grpc_status_code status_code; grpc_slice status_details = grpc_empty_slice(); grpc_metadata_array recv_initial_metadata; @@ -759,10 +760,10 @@ static void BM_IsolatedCall_Unary(benchmark::State& state) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), - method_hdl, deadline, NULL); - grpc_call_start_batch(call, ops, 6, tag(1), NULL); + method_hdl, deadline, nullptr); + grpc_call_start_batch(call, ops, 6, tag(1), nullptr); grpc_completion_queue_next(fixture.cq(), - gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); + gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); grpc_call_unref(call); } fixture.Finish(state); @@ -775,8 +776,8 @@ BENCHMARK(BM_IsolatedCall_Unary); static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { IsolatedCallFixture fixture; gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); - void* method_hdl = - grpc_channel_register_call(fixture.channel(), "/foo/bar", NULL, NULL); + void* method_hdl = grpc_channel_register_call(fixture.channel(), "/foo/bar", + nullptr, nullptr); grpc_slice slice = grpc_slice_from_static_string("hello world"); grpc_byte_buffer* send_message = grpc_raw_byte_buffer_create(&slice, 1); grpc_metadata_array recv_initial_metadata; @@ -791,18 +792,18 @@ static void BM_IsolatedCall_StreamingSend(benchmark::State& state) { &recv_initial_metadata; grpc_call* call = grpc_channel_create_registered_call( fixture.channel(), nullptr, GRPC_PROPAGATE_DEFAULTS, fixture.cq(), - method_hdl, deadline, NULL); - grpc_call_start_batch(call, ops, 2, tag(1), NULL); + method_hdl, deadline, nullptr); + grpc_call_start_batch(call, ops, 2, tag(1), nullptr); grpc_completion_queue_next(fixture.cq(), gpr_inf_future(GPR_CLOCK_MONOTONIC), - NULL); + nullptr); memset(ops, 0, sizeof(ops)); ops[0].op = GRPC_OP_SEND_MESSAGE; ops[0].data.send_message.send_message = send_message; while (state.KeepRunning()) { GPR_TIMER_SCOPE("BenchmarkCycle", 0); - grpc_call_start_batch(call, ops, 1, tag(2), NULL); + grpc_call_start_batch(call, ops, 1, tag(2), nullptr); grpc_completion_queue_next(fixture.cq(), - gpr_inf_future(GPR_CLOCK_MONOTONIC), NULL); + gpr_inf_future(GPR_CLOCK_MONOTONIC), nullptr); } grpc_call_unref(call); fixture.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index d4f78e60b7..6b6b441d93 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -85,7 +85,7 @@ static void BM_HpackEncoderEncodeDeadline(benchmark::State& state) { (size_t)1024, &stats, }; - grpc_chttp2_encode_header(&c, NULL, 0, &b, &hopt, &outbuf); + grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf); grpc_slice_buffer_reset_and_unref_internal(&outbuf); grpc_core::ExecCtx::Get()->Flush(); } @@ -134,7 +134,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State& state) { (size_t)state.range(1), &stats, }; - grpc_chttp2_encode_header(&c, NULL, 0, &b, &hopt, &outbuf); + grpc_chttp2_encode_header(&c, nullptr, 0, &b, &hopt, &outbuf); if (!logged_representative_output && state.iterations() > 3) { logged_representative_output = true; for (size_t i = 0; i < outbuf.count; i++) { @@ -765,7 +765,7 @@ static void OnHeaderNew(void* user_data, grpc_mdelem md) { grpc_millis* cached_timeout = static_cast<grpc_millis*>(grpc_mdelem_get_user_data(md, free_timeout)); grpc_millis timeout; - if (cached_timeout != NULL) { + if (cached_timeout != nullptr) { timeout = *cached_timeout; } else { if (!grpc_http2_decode_timeout(GRPC_MDVALUE(md), &timeout)) { diff --git a/test/cpp/microbenchmarks/bm_chttp2_transport.cc b/test/cpp/microbenchmarks/bm_chttp2_transport.cc index caccde0cd9..044417830f 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_transport.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_transport.cc @@ -99,7 +99,7 @@ class DummyEndpoint : public grpc_endpoint { GRPC_CLOSURE_SCHED(cb, GRPC_ERROR_NONE); } - static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return NULL; } + static grpc_workqueue* get_workqueue(grpc_endpoint* ep) { return nullptr; } static void add_to_pollset(grpc_endpoint* ep, grpc_pollset* pollset) {} @@ -132,7 +132,7 @@ class Fixture { grpc_channel_args c_args = args.c_channel_args(); ep_ = new DummyEndpoint; t_ = grpc_create_chttp2_transport(&c_args, ep_, client); - grpc_chttp2_transport_start_reading(t_, NULL); + grpc_chttp2_transport_start_reading(t_, nullptr); FlushExecCtx(); } @@ -212,7 +212,7 @@ class Stream { } grpc_transport_init_stream(f_->transport(), static_cast<grpc_stream*>(stream_), &refcount_, - NULL, arena_); + nullptr, arena_); } void DestroyThen(grpc_closure* closure) { @@ -570,7 +570,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { }); drain_start = MakeClosure([&](grpc_error* error) { - if (recv_stream == NULL) { + if (recv_stream == nullptr) { GPR_ASSERT(!state.KeepRunning()); return; } diff --git a/test/cpp/microbenchmarks/bm_closure.cc b/test/cpp/microbenchmarks/bm_closure.cc index 64925fd3f9..f28093ae17 100644 --- a/test/cpp/microbenchmarks/bm_closure.cc +++ b/test/cpp/microbenchmarks/bm_closure.cc @@ -58,7 +58,7 @@ static void BM_ClosureInitAgainstExecCtx(benchmark::State& state) { grpc_closure c; while (state.KeepRunning()) { benchmark::DoNotOptimize( - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx)); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx)); } track_counters.Finish(state); } @@ -71,7 +71,7 @@ static void BM_ClosureInitAgainstCombiner(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { benchmark::DoNotOptimize(GRPC_CLOSURE_INIT( - &c, DoNothing, NULL, grpc_combiner_scheduler(combiner))); + &c, DoNothing, nullptr, grpc_combiner_scheduler(combiner))); } GRPC_COMBINER_UNREF(combiner, "finished"); @@ -82,7 +82,7 @@ BENCHMARK(BM_ClosureInitAgainstCombiner); static void BM_ClosureRunOnExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c; - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_RUN(&c, GRPC_ERROR_NONE); @@ -98,7 +98,7 @@ static void BM_ClosureCreateAndRun(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_RUN( - GRPC_CLOSURE_CREATE(DoNothing, NULL, grpc_schedule_on_exec_ctx), + GRPC_CLOSURE_CREATE(DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); } @@ -112,7 +112,7 @@ static void BM_ClosureInitAndRun(benchmark::State& state) { grpc_closure c; while (state.KeepRunning()) { GRPC_CLOSURE_RUN( - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx), + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx), GRPC_ERROR_NONE); } @@ -123,7 +123,7 @@ BENCHMARK(BM_ClosureInitAndRun); static void BM_ClosureSchedOnExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c; - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE); @@ -138,8 +138,8 @@ static void BM_ClosureSched2OnExecCtx(benchmark::State& state) { TrackCounters track_counters; grpc_closure c1; grpc_closure c2; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); @@ -156,9 +156,9 @@ static void BM_ClosureSched3OnExecCtx(benchmark::State& state) { grpc_closure c1; grpc_closure c2; grpc_closure c3; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_schedule_on_exec_ctx); - GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_schedule_on_exec_ctx); + GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_schedule_on_exec_ctx); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); @@ -179,7 +179,7 @@ static void BM_AcquireMutex(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { gpr_mu_lock(&mu); - DoNothing(NULL, GRPC_ERROR_NONE); + DoNothing(nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); } @@ -195,7 +195,7 @@ static void BM_TryAcquireMutex(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { if (gpr_mu_trylock(&mu)) { - DoNothing(NULL, GRPC_ERROR_NONE); + DoNothing(nullptr, GRPC_ERROR_NONE); gpr_mu_unlock(&mu); } else { abort(); @@ -213,7 +213,7 @@ static void BM_AcquireSpinlock(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { gpr_spinlock_lock(&mu); - DoNothing(NULL, GRPC_ERROR_NONE); + DoNothing(nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); } @@ -228,7 +228,7 @@ static void BM_TryAcquireSpinlock(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { if (gpr_spinlock_trylock(&mu)) { - DoNothing(NULL, GRPC_ERROR_NONE); + DoNothing(nullptr, GRPC_ERROR_NONE); gpr_spinlock_unlock(&mu); } else { abort(); @@ -243,7 +243,7 @@ static void BM_ClosureSchedOnCombiner(benchmark::State& state) { TrackCounters track_counters; grpc_combiner* combiner = grpc_combiner_create(); grpc_closure c; - GRPC_CLOSURE_INIT(&c, DoNothing, NULL, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c, GRPC_ERROR_NONE); @@ -260,8 +260,8 @@ static void BM_ClosureSched2OnCombiner(benchmark::State& state) { grpc_combiner* combiner = grpc_combiner_create(); grpc_closure c1; grpc_closure c2; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); @@ -280,9 +280,9 @@ static void BM_ClosureSched3OnCombiner(benchmark::State& state) { grpc_closure c1; grpc_closure c2; grpc_closure c3; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner)); - GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); + GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, grpc_combiner_scheduler(combiner)); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); @@ -302,8 +302,10 @@ static void BM_ClosureSched2OnTwoCombiners(benchmark::State& state) { grpc_combiner* combiner2 = grpc_combiner_create(); grpc_closure c1; grpc_closure c2; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner1)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner2)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, + grpc_combiner_scheduler(combiner1)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, + grpc_combiner_scheduler(combiner2)); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); @@ -325,10 +327,14 @@ static void BM_ClosureSched4OnTwoCombiners(benchmark::State& state) { grpc_closure c2; grpc_closure c3; grpc_closure c4; - GRPC_CLOSURE_INIT(&c1, DoNothing, NULL, grpc_combiner_scheduler(combiner1)); - GRPC_CLOSURE_INIT(&c2, DoNothing, NULL, grpc_combiner_scheduler(combiner2)); - GRPC_CLOSURE_INIT(&c3, DoNothing, NULL, grpc_combiner_scheduler(combiner1)); - GRPC_CLOSURE_INIT(&c4, DoNothing, NULL, grpc_combiner_scheduler(combiner2)); + GRPC_CLOSURE_INIT(&c1, DoNothing, nullptr, + grpc_combiner_scheduler(combiner1)); + GRPC_CLOSURE_INIT(&c2, DoNothing, nullptr, + grpc_combiner_scheduler(combiner2)); + GRPC_CLOSURE_INIT(&c3, DoNothing, nullptr, + grpc_combiner_scheduler(combiner1)); + GRPC_CLOSURE_INIT(&c4, DoNothing, nullptr, + grpc_combiner_scheduler(combiner2)); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { GRPC_CLOSURE_SCHED(&c1, GRPC_ERROR_NONE); diff --git a/test/cpp/microbenchmarks/bm_cq.cc b/test/cpp/microbenchmarks/bm_cq.cc index 85248ef91a..16f451d98f 100644 --- a/test/cpp/microbenchmarks/bm_cq.cc +++ b/test/cpp/microbenchmarks/bm_cq.cc @@ -47,7 +47,7 @@ static void BM_CreateDestroyCpp2(benchmark::State& state) { TrackCounters track_counters; while (state.KeepRunning()) { grpc_completion_queue* core_cq = - grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue_create_for_next(nullptr); CompletionQueue cq(core_cq); } track_counters.Finish(state); @@ -59,7 +59,8 @@ static void BM_CreateDestroyCore(benchmark::State& state) { while (state.KeepRunning()) { // TODO: sreek Templatize this benchmark and pass completion type and // polling type as parameters - grpc_completion_queue_destroy(grpc_completion_queue_create_for_next(NULL)); + grpc_completion_queue_destroy( + grpc_completion_queue_create_for_next(nullptr)); } track_counters.Finish(state); } @@ -83,7 +84,7 @@ static void BM_Pass1Cpp(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; GPR_ASSERT(grpc_cq_begin_op(c_cq, &dummy_tag)); grpc_cq_end_op(c_cq, &dummy_tag, GRPC_ERROR_NONE, DoneWithCompletionOnStack, - NULL, &completion); + nullptr, &completion); void* tag; bool ok; @@ -96,16 +97,16 @@ BENCHMARK(BM_Pass1Cpp); static void BM_Pass1Core(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; grpc_core::ExecCtx _local_exec_ctx; - GPR_ASSERT(grpc_cq_begin_op(cq, NULL)); - grpc_cq_end_op(cq, NULL, GRPC_ERROR_NONE, DoneWithCompletionOnStack, NULL, - &completion); + GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); + grpc_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack, + nullptr, &completion); - grpc_completion_queue_next(cq, deadline, NULL); + grpc_completion_queue_next(cq, deadline, nullptr); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); @@ -115,16 +116,16 @@ BENCHMARK(BM_Pass1Core); static void BM_Pluck1Core(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_pluck(nullptr); gpr_timespec deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { grpc_cq_completion completion; grpc_core::ExecCtx _local_exec_ctx; - GPR_ASSERT(grpc_cq_begin_op(cq, NULL)); - grpc_cq_end_op(cq, NULL, GRPC_ERROR_NONE, DoneWithCompletionOnStack, NULL, - &completion); + GPR_ASSERT(grpc_cq_begin_op(cq, nullptr)); + grpc_cq_end_op(cq, nullptr, GRPC_ERROR_NONE, DoneWithCompletionOnStack, + nullptr, &completion); - grpc_completion_queue_pluck(cq, NULL, deadline, NULL); + grpc_completion_queue_pluck(cq, nullptr, deadline, nullptr); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); @@ -134,10 +135,10 @@ BENCHMARK(BM_Pluck1Core); static void BM_EmptyCore(benchmark::State& state) { TrackCounters track_counters; // TODO: sreek Templatize this benchmark and pass polling_type as a param - grpc_completion_queue* cq = grpc_completion_queue_create_for_next(NULL); + grpc_completion_queue* cq = grpc_completion_queue_create_for_next(nullptr); gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_MONOTONIC); while (state.KeepRunning()) { - grpc_completion_queue_next(cq, deadline, NULL); + grpc_completion_queue_next(cq, deadline, nullptr); } grpc_completion_queue_destroy(cq); track_counters.Finish(state); diff --git a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc index aeeba0963f..874c834931 100644 --- a/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc +++ b/test/cpp/microbenchmarks/bm_cq_multiple_threads.cc @@ -74,7 +74,7 @@ static grpc_error* pollset_work(grpc_pollset* ps, grpc_pollset_worker** worker, gpr_mu_unlock(&ps->mu); GPR_ASSERT(grpc_cq_begin_op(g_cq, g_tag)); - grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, NULL, + grpc_cq_end_op(g_cq, g_tag, GRPC_ERROR_NONE, cq_done_cb, nullptr, (grpc_cq_completion*)gpr_malloc(sizeof(grpc_cq_completion))); grpc_core::ExecCtx::Get()->Flush(); gpr_mu_lock(&ps->mu); @@ -102,7 +102,7 @@ static void setup() { g_old_vtable = grpc_get_event_engine_test_only(); grpc_set_event_engine_test_only(&g_vtable); - g_cq = grpc_completion_queue_create_for_next(NULL); + g_cq = grpc_completion_queue_create_for_next(nullptr); } static void teardown() { @@ -110,7 +110,7 @@ static void teardown() { /* Drain any events */ gpr_timespec deadline = gpr_time_0(GPR_CLOCK_MONOTONIC); - while (grpc_completion_queue_next(g_cq, deadline, NULL).type != + while (grpc_completion_queue_next(g_cq, deadline, nullptr).type != GRPC_QUEUE_SHUTDOWN) { /* Do nothing */ } @@ -145,7 +145,7 @@ static void BM_Cq_Throughput(benchmark::State& state) { } while (state.KeepRunning()) { - GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, NULL).type == + GPR_ASSERT(grpc_completion_queue_next(g_cq, deadline, nullptr).type == GRPC_OP_COMPLETE); } diff --git a/test/cpp/microbenchmarks/bm_error.cc b/test/cpp/microbenchmarks/bm_error.cc index d6dba1d82f..0ee491a271 100644 --- a/test/cpp/microbenchmarks/bm_error.cc +++ b/test/cpp/microbenchmarks/bm_error.cc @@ -251,7 +251,7 @@ static void BM_ErrorGetStatus(benchmark::State& state) { grpc_status_code status; grpc_slice slice; grpc_error_get_status(fixture.error(), fixture.deadline(), &status, &slice, - NULL); + nullptr); } track_counters.Finish(state); @@ -264,8 +264,8 @@ static void BM_ErrorGetStatusCode(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { grpc_status_code status; - grpc_error_get_status(fixture.error(), fixture.deadline(), &status, NULL, - NULL); + grpc_error_get_status(fixture.error(), fixture.deadline(), &status, nullptr, + nullptr); } track_counters.Finish(state); @@ -278,7 +278,7 @@ static void BM_ErrorHttpError(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { grpc_http2_error_code error; - grpc_error_get_status(fixture.error(), fixture.deadline(), NULL, NULL, + grpc_error_get_status(fixture.error(), fixture.deadline(), nullptr, nullptr, &error); } diff --git a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc index 7b04909ee1..23ca750307 100644 --- a/test/cpp/microbenchmarks/bm_fullstack_trickle.cc +++ b/test/cpp/microbenchmarks/bm_fullstack_trickle.cc @@ -216,10 +216,10 @@ class TrickledCHTTP2 : public EndpointPairFixture { void UpdateStats(grpc_chttp2_transport* t, Stats* s, size_t backlog) GPR_ATTRIBUTE_NO_TSAN { if (backlog == 0) { - if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != NULL) { + if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_STREAM].head != nullptr) { s->streams_stalled_due_to_stream_flow_control++; } - if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != NULL) { + if (t->lists[GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT].head != nullptr) { s->streams_stalled_due_to_transport_flow_control++; } } diff --git a/test/cpp/microbenchmarks/bm_metadata.cc b/test/cpp/microbenchmarks/bm_metadata.cc index 3a00db7a13..62c9a2e335 100644 --- a/test/cpp/microbenchmarks/bm_metadata.cc +++ b/test/cpp/microbenchmarks/bm_metadata.cc @@ -92,7 +92,7 @@ static void BM_MetadataFromNonInternedSlices(benchmark::State& state) { gpr_slice v = grpc_slice_from_static_string("value"); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL)); + GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } track_counters.Finish(state); @@ -105,7 +105,7 @@ static void BM_MetadataFromInternedSlices(benchmark::State& state) { gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL)); + GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } grpc_slice_unref(k); @@ -120,9 +120,9 @@ static void BM_MetadataFromInternedSlicesAlreadyInIndex( gpr_slice k = grpc_slice_intern(grpc_slice_from_static_string("key")); gpr_slice v = grpc_slice_intern(grpc_slice_from_static_string("value")); grpc_core::ExecCtx _local_exec_ctx; - grpc_mdelem seed = grpc_mdelem_create(k, v, NULL); + grpc_mdelem seed = grpc_mdelem_create(k, v, nullptr); while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL)); + GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } GRPC_MDELEM_UNREF(seed); @@ -138,7 +138,7 @@ static void BM_MetadataFromInternedKey(benchmark::State& state) { gpr_slice v = grpc_slice_from_static_string("value"); grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL)); + GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } grpc_slice_unref(k); @@ -203,7 +203,7 @@ static void BM_MetadataFromStaticMetadataStrings(benchmark::State& state) { gpr_slice v = GRPC_MDSTR_200; grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL)); + GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } grpc_slice_unref(k); @@ -218,7 +218,7 @@ static void BM_MetadataFromStaticMetadataStringsNotIndexed( gpr_slice v = GRPC_MDSTR_GZIP; grpc_core::ExecCtx _local_exec_ctx; while (state.KeepRunning()) { - GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, NULL)); + GRPC_MDELEM_UNREF(grpc_mdelem_create(k, v, nullptr)); } grpc_slice_unref(k); @@ -264,8 +264,9 @@ BENCHMARK(BM_MetadataRefUnrefInterned); static void BM_MetadataRefUnrefAllocated(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx _local_exec_ctx; - grpc_mdelem el = grpc_mdelem_create(grpc_slice_from_static_string("a"), - grpc_slice_from_static_string("b"), NULL); + grpc_mdelem el = + grpc_mdelem_create(grpc_slice_from_static_string("a"), + grpc_slice_from_static_string("b"), nullptr); while (state.KeepRunning()) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } @@ -278,7 +279,8 @@ BENCHMARK(BM_MetadataRefUnrefAllocated); static void BM_MetadataRefUnrefStatic(benchmark::State& state) { TrackCounters track_counters; grpc_core::ExecCtx _local_exec_ctx; - grpc_mdelem el = grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, NULL); + grpc_mdelem el = + grpc_mdelem_create(GRPC_MDSTR_STATUS, GRPC_MDSTR_200, nullptr); while (state.KeepRunning()) { GRPC_MDELEM_UNREF(GRPC_MDELEM_REF(el)); } diff --git a/test/cpp/microbenchmarks/bm_pollset.cc b/test/cpp/microbenchmarks/bm_pollset.cc index 59ee937fe4..ec0bf4e4b9 100644 --- a/test/cpp/microbenchmarks/bm_pollset.cc +++ b/test/cpp/microbenchmarks/bm_pollset.cc @@ -117,7 +117,7 @@ static void BM_PollEmptyPollset(benchmark::State& state) { grpc_core::ExecCtx _local_exec_ctx; gpr_mu_lock(mu); while (state.KeepRunning()) { - GRPC_ERROR_UNREF(grpc_pollset_work(ps, NULL, 0)); + GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, 0)); } grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, @@ -145,7 +145,7 @@ static void BM_PollAddFd(benchmark::State& state) { grpc_pollset_add_fd(ps, fd); grpc_core::ExecCtx::Get()->Flush(); } - grpc_fd_orphan(fd, NULL, NULL, false /* already_closed */, "xxx"); + grpc_fd_orphan(fd, nullptr, nullptr, false /* already_closed */, "xxx"); grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, grpc_schedule_on_exec_ctx); @@ -239,9 +239,9 @@ static void BM_SingleThreadPollOneFd(benchmark::State& state) { grpc_fd_notify_on_read(wakeup, continue_closure); gpr_mu_lock(mu); while (!done) { - GRPC_ERROR_UNREF(grpc_pollset_work(ps, NULL, GRPC_MILLIS_INF_FUTURE)); + GRPC_ERROR_UNREF(grpc_pollset_work(ps, nullptr, GRPC_MILLIS_INF_FUTURE)); } - grpc_fd_orphan(wakeup, NULL, NULL, false /* already_closed */, "done"); + grpc_fd_orphan(wakeup, nullptr, nullptr, false /* already_closed */, "done"); wakeup_fd.read_fd = 0; grpc_closure shutdown_ps_closure; GRPC_CLOSURE_INIT(&shutdown_ps_closure, shutdown_ps, ps, diff --git a/test/cpp/microbenchmarks/fullstack_fixtures.h b/test/cpp/microbenchmarks/fullstack_fixtures.h index 4efcafa8e1..1520282009 100644 --- a/test/cpp/microbenchmarks/fullstack_fixtures.h +++ b/test/cpp/microbenchmarks/fullstack_fixtures.h @@ -184,9 +184,9 @@ class EndpointPairFixture : public BaseFixture { grpc_endpoint_add_to_pollset(endpoints.server, pollsets[i]); } - grpc_server_setup_transport(server_->c_server(), server_transport_, NULL, - server_args); - grpc_chttp2_transport_start_reading(server_transport_, NULL); + grpc_server_setup_transport(server_->c_server(), server_transport_, + nullptr, server_args); + grpc_chttp2_transport_start_reading(server_transport_, nullptr); } /* create channel */ @@ -201,7 +201,7 @@ class EndpointPairFixture : public BaseFixture { GPR_ASSERT(client_transport_); grpc_channel* channel = grpc_channel_create( "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, client_transport_); - grpc_chttp2_transport_start_reading(client_transport_, NULL); + grpc_chttp2_transport_start_reading(client_transport_, nullptr); channel_ = CreateChannelInternal("", channel); } @@ -241,7 +241,7 @@ class SockPair : public EndpointPairFixture { SockPair(Service* service, const FixtureConfiguration& fixture_configuration = FixtureConfiguration()) : EndpointPairFixture(service, - grpc_iomgr_create_endpoint_pair("test", NULL), + grpc_iomgr_create_endpoint_pair("test", nullptr), fixture_configuration) {} }; |