|
|
|
@ -154,14 +154,14 @@ class Fixture { |
|
|
|
|
grpc_transport* t_; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
class Closure : public grpc_closure { |
|
|
|
|
class TestClosure : public grpc_closure { |
|
|
|
|
public: |
|
|
|
|
virtual ~Closure() {} |
|
|
|
|
virtual ~TestClosure() {} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
template <class F> |
|
|
|
|
std::unique_ptr<Closure> MakeClosure(F f) { |
|
|
|
|
struct C : public Closure { |
|
|
|
|
std::unique_ptr<TestClosure> MakeTestClosure(F f) { |
|
|
|
|
struct C : public TestClosure { |
|
|
|
|
explicit C(const F& f) : f_(f) { |
|
|
|
|
GRPC_CLOSURE_INIT(this, Execute, this, nullptr); |
|
|
|
|
} |
|
|
|
@ -170,7 +170,7 @@ std::unique_ptr<Closure> MakeClosure(F f) { |
|
|
|
|
static_cast<C*>(arg)->f_(error); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
return std::unique_ptr<Closure>(new C(f)); |
|
|
|
|
return std::unique_ptr<TestClosure>(new C(f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template <class F> |
|
|
|
@ -267,7 +267,8 @@ static void BM_StreamCreateDestroy(benchmark::State& state) { |
|
|
|
|
op.cancel_stream = true; |
|
|
|
|
op.payload = &op_payload; |
|
|
|
|
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; |
|
|
|
|
std::unique_ptr<Closure> next = MakeClosure([&, s](grpc_error* /*error*/) { |
|
|
|
|
std::unique_ptr<TestClosure> next = |
|
|
|
|
MakeTestClosure([&, s](grpc_error* /*error*/) { |
|
|
|
|
if (!state.KeepRunning()) { |
|
|
|
|
delete s; |
|
|
|
|
return; |
|
|
|
@ -312,8 +313,8 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { |
|
|
|
|
auto* s = new Stream(&f); |
|
|
|
|
grpc_transport_stream_op_batch op; |
|
|
|
|
grpc_transport_stream_op_batch_payload op_payload(nullptr); |
|
|
|
|
std::unique_ptr<Closure> start; |
|
|
|
|
std::unique_ptr<Closure> done; |
|
|
|
|
std::unique_ptr<TestClosure> start; |
|
|
|
|
std::unique_ptr<TestClosure> done; |
|
|
|
|
|
|
|
|
|
auto reset_op = [&]() { |
|
|
|
|
op = {}; |
|
|
|
@ -333,7 +334,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { |
|
|
|
|
f.FlushExecCtx(); |
|
|
|
|
gpr_event bm_done; |
|
|
|
|
gpr_event_init(&bm_done); |
|
|
|
|
start = MakeClosure([&, s](grpc_error* /*error*/) { |
|
|
|
|
start = MakeTestClosure([&, s](grpc_error* /*error*/) { |
|
|
|
|
if (!state.KeepRunning()) { |
|
|
|
|
delete s; |
|
|
|
|
gpr_event_set(&bm_done, (void*)1); |
|
|
|
@ -346,7 +347,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) { |
|
|
|
|
op.payload->send_initial_metadata.send_initial_metadata = &b; |
|
|
|
|
s->Op(&op); |
|
|
|
|
}); |
|
|
|
|
done = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
done = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
reset_op(); |
|
|
|
|
op.cancel_stream = true; |
|
|
|
|
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; |
|
|
|
@ -374,7 +375,7 @@ static void BM_TransportEmptyOp(benchmark::State& state) { |
|
|
|
|
op = {}; |
|
|
|
|
op.payload = &op_payload; |
|
|
|
|
}; |
|
|
|
|
std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
std::unique_ptr<TestClosure> c = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
if (!state.KeepRunning()) return; |
|
|
|
|
reset_op(); |
|
|
|
|
op.on_complete = c.get(); |
|
|
|
@ -387,8 +388,8 @@ static void BM_TransportEmptyOp(benchmark::State& state) { |
|
|
|
|
op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; |
|
|
|
|
gpr_event* stream_cancel_done = new gpr_event; |
|
|
|
|
gpr_event_init(stream_cancel_done); |
|
|
|
|
std::unique_ptr<Closure> stream_cancel_closure = |
|
|
|
|
MakeClosure([&](grpc_error* error) { |
|
|
|
|
std::unique_ptr<TestClosure> stream_cancel_closure = |
|
|
|
|
MakeTestClosure([&](grpc_error* error) { |
|
|
|
|
GPR_ASSERT(error == GRPC_ERROR_NONE); |
|
|
|
|
gpr_event_set(stream_cancel_done, (void*)(1)); |
|
|
|
|
}); |
|
|
|
@ -436,7 +437,7 @@ static void BM_TransportStreamSend(benchmark::State& state) { |
|
|
|
|
gpr_event* bm_done = new gpr_event; |
|
|
|
|
gpr_event_init(bm_done); |
|
|
|
|
|
|
|
|
|
std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
std::unique_ptr<TestClosure> c = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
if (!state.KeepRunning()) { |
|
|
|
|
gpr_event_set(bm_done, (void*)(1)); |
|
|
|
|
return; |
|
|
|
@ -471,8 +472,8 @@ static void BM_TransportStreamSend(benchmark::State& state) { |
|
|
|
|
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; |
|
|
|
|
gpr_event* stream_cancel_done = new gpr_event; |
|
|
|
|
gpr_event_init(stream_cancel_done); |
|
|
|
|
std::unique_ptr<Closure> stream_cancel_closure = |
|
|
|
|
MakeClosure([&](grpc_error* error) { |
|
|
|
|
std::unique_ptr<TestClosure> stream_cancel_closure = |
|
|
|
|
MakeTestClosure([&](grpc_error* error) { |
|
|
|
|
GPR_ASSERT(error == GRPC_ERROR_NONE); |
|
|
|
|
gpr_event_set(stream_cancel_done, (void*)(1)); |
|
|
|
|
}); |
|
|
|
@ -575,17 +576,17 @@ static void BM_TransportStreamRecv(benchmark::State& state) { |
|
|
|
|
"addmd", grpc_metadata_batch_add_tail(&b, &storage[i], elems[i]))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::unique_ptr<Closure> do_nothing = |
|
|
|
|
MakeClosure([](grpc_error* /*error*/) {}); |
|
|
|
|
std::unique_ptr<TestClosure> do_nothing = |
|
|
|
|
MakeTestClosure([](grpc_error* /*error*/) {}); |
|
|
|
|
|
|
|
|
|
uint32_t received; |
|
|
|
|
|
|
|
|
|
std::unique_ptr<Closure> drain_start; |
|
|
|
|
std::unique_ptr<Closure> drain; |
|
|
|
|
std::unique_ptr<Closure> drain_continue; |
|
|
|
|
std::unique_ptr<TestClosure> drain_start; |
|
|
|
|
std::unique_ptr<TestClosure> drain; |
|
|
|
|
std::unique_ptr<TestClosure> drain_continue; |
|
|
|
|
grpc_slice recv_slice; |
|
|
|
|
|
|
|
|
|
std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
std::unique_ptr<TestClosure> c = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
if (!state.KeepRunning()) return; |
|
|
|
|
// force outgoing window to be yuge
|
|
|
|
|
s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow(); |
|
|
|
@ -600,7 +601,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { |
|
|
|
|
f.PushInput(grpc_slice_ref(incoming_data)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
drain_start = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
drain_start = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
if (recv_stream == nullptr) { |
|
|
|
|
GPR_ASSERT(!state.KeepRunning()); |
|
|
|
|
return; |
|
|
|
@ -608,7 +609,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { |
|
|
|
|
grpc_core::Closure::Run(DEBUG_LOCATION, drain.get(), GRPC_ERROR_NONE); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
drain = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
drain = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
do { |
|
|
|
|
if (received == recv_stream->length()) { |
|
|
|
|
recv_stream.reset(); |
|
|
|
@ -622,7 +623,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) { |
|
|
|
|
grpc_slice_unref_internal(recv_slice), true)); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
drain_continue = MakeClosure([&](grpc_error* /*error*/) { |
|
|
|
|
drain_continue = MakeTestClosure([&](grpc_error* /*error*/) { |
|
|
|
|
recv_stream->Pull(&recv_slice); |
|
|
|
|
received += GRPC_SLICE_LENGTH(recv_slice); |
|
|
|
|
grpc_slice_unref_internal(recv_slice); |
|
|
|
@ -657,8 +658,8 @@ static void BM_TransportStreamRecv(benchmark::State& state) { |
|
|
|
|
op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED; |
|
|
|
|
gpr_event* stream_cancel_done = new gpr_event; |
|
|
|
|
gpr_event_init(stream_cancel_done); |
|
|
|
|
std::unique_ptr<Closure> stream_cancel_closure = |
|
|
|
|
MakeClosure([&](grpc_error* error) { |
|
|
|
|
std::unique_ptr<TestClosure> stream_cancel_closure = |
|
|
|
|
MakeTestClosure([&](grpc_error* error) { |
|
|
|
|
GPR_ASSERT(error == GRPC_ERROR_NONE); |
|
|
|
|
gpr_event_set(stream_cancel_done, (void*)(1)); |
|
|
|
|
}); |
|
|
|
|