|  | @@ -259,18 +259,21 @@ static void BM_StreamCreateDestroy(benchmark::State& state) {
 | 
	
		
			
				|  |  |    TrackCounters track_counters;
 | 
	
		
			
				|  |  |    grpc_core::ExecCtx exec_ctx;
 | 
	
		
			
				|  |  |    Fixture f(grpc::ChannelArguments(), true);
 | 
	
		
			
				|  |  | -  Stream s(&f);
 | 
	
		
			
				|  |  | +  auto* s = new Stream(&f);
 | 
	
		
			
				|  |  |    grpc_transport_stream_op_batch op;
 | 
	
		
			
				|  |  |    grpc_transport_stream_op_batch_payload op_payload(nullptr);
 | 
	
		
			
				|  |  |    memset(&op, 0, sizeof(op));
 | 
	
		
			
				|  |  |    op.cancel_stream = true;
 | 
	
		
			
				|  |  |    op.payload = &op_payload;
 | 
	
		
			
				|  |  |    op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
 | 
	
		
			
				|  |  | -  std::unique_ptr<Closure> next = MakeClosure([&](grpc_error* error) {
 | 
	
		
			
				|  |  | -    if (!state.KeepRunning()) return;
 | 
	
		
			
				|  |  | -    s.Init(state);
 | 
	
		
			
				|  |  | -    s.Op(&op);
 | 
	
		
			
				|  |  | -    s.DestroyThen(next.get());
 | 
	
		
			
				|  |  | +  std::unique_ptr<Closure> next = MakeClosure([&, s](grpc_error* error) {
 | 
	
		
			
				|  |  | +    if (!state.KeepRunning()) {
 | 
	
		
			
				|  |  | +      delete s;
 | 
	
		
			
				|  |  | +      return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    s->Init(state);
 | 
	
		
			
				|  |  | +    s->Op(&op);
 | 
	
		
			
				|  |  | +    s->DestroyThen(next.get());
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |    GRPC_CLOSURE_RUN(next.get(), GRPC_ERROR_NONE);
 | 
	
		
			
				|  |  |    f.FlushExecCtx();
 | 
	
	
		
			
				|  | @@ -305,7 +308,7 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
 | 
	
		
			
				|  |  |    TrackCounters track_counters;
 | 
	
		
			
				|  |  |    grpc_core::ExecCtx exec_ctx;
 | 
	
		
			
				|  |  |    Fixture f(grpc::ChannelArguments(), true);
 | 
	
		
			
				|  |  | -  Stream s(&f);
 | 
	
		
			
				|  |  | +  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;
 | 
	
	
		
			
				|  | @@ -327,21 +330,24 @@ static void BM_StreamCreateSendInitialMetadataDestroy(benchmark::State& state) {
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    f.FlushExecCtx();
 | 
	
		
			
				|  |  | -  start = MakeClosure([&](grpc_error* error) {
 | 
	
		
			
				|  |  | -    if (!state.KeepRunning()) return;
 | 
	
		
			
				|  |  | -    s.Init(state);
 | 
	
		
			
				|  |  | +  start = MakeClosure([&, s](grpc_error* error) {
 | 
	
		
			
				|  |  | +    if (!state.KeepRunning()) {
 | 
	
		
			
				|  |  | +      delete s;
 | 
	
		
			
				|  |  | +      return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    s->Init(state);
 | 
	
		
			
				|  |  |      reset_op();
 | 
	
		
			
				|  |  |      op.on_complete = done.get();
 | 
	
		
			
				|  |  |      op.send_initial_metadata = true;
 | 
	
		
			
				|  |  |      op.payload->send_initial_metadata.send_initial_metadata = &b;
 | 
	
		
			
				|  |  | -    s.Op(&op);
 | 
	
		
			
				|  |  | +    s->Op(&op);
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |    done = MakeClosure([&](grpc_error* error) {
 | 
	
		
			
				|  |  |      reset_op();
 | 
	
		
			
				|  |  |      op.cancel_stream = true;
 | 
	
		
			
				|  |  |      op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
 | 
	
		
			
				|  |  | -    s.Op(&op);
 | 
	
		
			
				|  |  | -    s.DestroyThen(start.get());
 | 
	
		
			
				|  |  | +    s->Op(&op);
 | 
	
		
			
				|  |  | +    s->DestroyThen(start.get());
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |    GRPC_CLOSURE_SCHED(start.get(), GRPC_ERROR_NONE);
 | 
	
		
			
				|  |  |    f.FlushExecCtx();
 | 
	
	
		
			
				|  | @@ -355,8 +361,8 @@ static void BM_TransportEmptyOp(benchmark::State& state) {
 | 
	
		
			
				|  |  |    TrackCounters track_counters;
 | 
	
		
			
				|  |  |    grpc_core::ExecCtx exec_ctx;
 | 
	
		
			
				|  |  |    Fixture f(grpc::ChannelArguments(), true);
 | 
	
		
			
				|  |  | -  Stream s(&f);
 | 
	
		
			
				|  |  | -  s.Init(state);
 | 
	
		
			
				|  |  | +  auto* s = new Stream(&f);
 | 
	
		
			
				|  |  | +  s->Init(state);
 | 
	
		
			
				|  |  |    grpc_transport_stream_op_batch op;
 | 
	
		
			
				|  |  |    grpc_transport_stream_op_batch_payload op_payload(nullptr);
 | 
	
		
			
				|  |  |    auto reset_op = [&]() {
 | 
	
	
		
			
				|  | @@ -367,15 +373,15 @@ static void BM_TransportEmptyOp(benchmark::State& state) {
 | 
	
		
			
				|  |  |      if (!state.KeepRunning()) return;
 | 
	
		
			
				|  |  |      reset_op();
 | 
	
		
			
				|  |  |      op.on_complete = c.get();
 | 
	
		
			
				|  |  | -    s.Op(&op);
 | 
	
		
			
				|  |  | +    s->Op(&op);
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |    GRPC_CLOSURE_SCHED(c.get(), GRPC_ERROR_NONE);
 | 
	
		
			
				|  |  |    f.FlushExecCtx();
 | 
	
		
			
				|  |  |    reset_op();
 | 
	
		
			
				|  |  |    op.cancel_stream = true;
 | 
	
		
			
				|  |  |    op_payload.cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
 | 
	
		
			
				|  |  | -  s.Op(&op);
 | 
	
		
			
				|  |  | -  s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
 | 
	
		
			
				|  |  | +  s->Op(&op);
 | 
	
		
			
				|  |  | +  s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; }));
 | 
	
		
			
				|  |  |    f.FlushExecCtx();
 | 
	
		
			
				|  |  |    track_counters.Finish(state);
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -519,8 +525,8 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
 | 
	
		
			
				|  |  |    TrackCounters track_counters;
 | 
	
		
			
				|  |  |    grpc_core::ExecCtx exec_ctx;
 | 
	
		
			
				|  |  |    Fixture f(grpc::ChannelArguments(), true);
 | 
	
		
			
				|  |  | -  Stream s(&f);
 | 
	
		
			
				|  |  | -  s.Init(state);
 | 
	
		
			
				|  |  | +  auto* s = new Stream(&f);
 | 
	
		
			
				|  |  | +  s->Init(state);
 | 
	
		
			
				|  |  |    grpc_transport_stream_op_batch_payload op_payload(nullptr);
 | 
	
		
			
				|  |  |    grpc_transport_stream_op_batch op;
 | 
	
		
			
				|  |  |    grpc_core::OrphanablePtr<grpc_core::ByteStream> recv_stream;
 | 
	
	
		
			
				|  | @@ -556,7 +562,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
 | 
	
		
			
				|  |  |    std::unique_ptr<Closure> c = MakeClosure([&](grpc_error* error) {
 | 
	
		
			
				|  |  |      if (!state.KeepRunning()) return;
 | 
	
		
			
				|  |  |      // force outgoing window to be yuge
 | 
	
		
			
				|  |  | -    s.chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
 | 
	
		
			
				|  |  | +    s->chttp2_stream()->flow_control->TestOnlyForceHugeWindow();
 | 
	
		
			
				|  |  |      f.chttp2_transport()->flow_control->TestOnlyForceHugeWindow();
 | 
	
		
			
				|  |  |      received = 0;
 | 
	
		
			
				|  |  |      reset_op();
 | 
	
	
		
			
				|  | @@ -564,7 +570,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
 | 
	
		
			
				|  |  |      op.recv_message = true;
 | 
	
		
			
				|  |  |      op.payload->recv_message.recv_message = &recv_stream;
 | 
	
		
			
				|  |  |      op.payload->recv_message.recv_message_ready = drain_start.get();
 | 
	
		
			
				|  |  | -    s.Op(&op);
 | 
	
		
			
				|  |  | +    s->Op(&op);
 | 
	
		
			
				|  |  |      f.PushInput(grpc_slice_ref(incoming_data));
 | 
	
		
			
				|  |  |    });
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -605,7 +611,7 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
 | 
	
		
			
				|  |  |    op.payload->recv_initial_metadata.recv_initial_metadata_ready =
 | 
	
		
			
				|  |  |        do_nothing.get();
 | 
	
		
			
				|  |  |    op.on_complete = c.get();
 | 
	
		
			
				|  |  | -  s.Op(&op);
 | 
	
		
			
				|  |  | +  s->Op(&op);
 | 
	
		
			
				|  |  |    f.PushInput(SLICE_FROM_BUFFER(
 | 
	
		
			
				|  |  |        "\x00\x00\x00\x04\x00\x00\x00\x00\x00"
 | 
	
		
			
				|  |  |        // Generated using:
 | 
	
	
		
			
				|  | @@ -623,12 +629,12 @@ static void BM_TransportStreamRecv(benchmark::State& state) {
 | 
	
		
			
				|  |  |    reset_op();
 | 
	
		
			
				|  |  |    op.cancel_stream = true;
 | 
	
		
			
				|  |  |    op.payload->cancel_stream.cancel_error = GRPC_ERROR_CANCELLED;
 | 
	
		
			
				|  |  | -  s.Op(&op);
 | 
	
		
			
				|  |  | -  s.DestroyThen(MakeOnceClosure([](grpc_error* error) {}));
 | 
	
		
			
				|  |  | -  f.FlushExecCtx();
 | 
	
		
			
				|  |  | -  track_counters.Finish(state);
 | 
	
		
			
				|  |  | +  s->Op(&op);
 | 
	
		
			
				|  |  | +  s->DestroyThen(MakeOnceClosure([s](grpc_error* error) { delete s; }));
 | 
	
		
			
				|  |  |    grpc_metadata_batch_destroy(&b);
 | 
	
		
			
				|  |  |    grpc_metadata_batch_destroy(&b_recv);
 | 
	
		
			
				|  |  | +  f.FlushExecCtx();
 | 
	
		
			
				|  |  | +  track_counters.Finish(state);
 | 
	
		
			
				|  |  |    grpc_slice_unref(incoming_data);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  BENCHMARK(BM_TransportStreamRecv)->Range(0, 128 * 1024 * 1024);
 |