Go to the documentation of this file.
19 #include <forward_list>
30 #include "absl/memory/memory.h"
41 #include "src/proto/grpc/testing/benchmark_service.grpc.pb.h"
65 template <
class RequestType,
class ResponseType>
101 case State::RESP_DONE:
116 clone->StartInternal(
cq);
131 std::function<std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>(
137 std::unique_ptr<grpc::ClientAsyncResponseReader<ResponseType>>
145 alarm_ = absl::make_unique<Alarm>();
151 template <
class StubType,
class RequestType>
167 std::function<std::unique_ptr<StubType>(std::shared_ptr<Channel>)>
175 for (
int i = 0;
i < num_cqs;
i++) {
187 for (
int i = 0;
i <
config.outstanding_rpcs_per_channel();
i++) {
200 while ((*cq)->Next(&got_tag, &
ok)) {
234 std::lock_guard<std::mutex> lock((*ss)->mutex);
235 (*ss)->shutdown =
true;
271 if (
ctx ==
nullptr) {
277 if (!
ctx->RunNextState(
ok, entry_ptr)) {
280 ctx->StartNewClone(cli_cqs_[cq_[thread_idx]].get());
286 t->UpdateHistogram(entry_ptr);
290 if (
ctx ==
nullptr) {
297 std::vector<std::unique_ptr<CompletionQueue>>
cli_cqs_;
304 const std::shared_ptr<Channel>&
ch) {
305 return BenchmarkService::NewStub(
ch);
309 :
public AsyncClient<BenchmarkService::Stub, SimpleRequest> {
323 static std::unique_ptr<grpc::ClientAsyncResponseReader<SimpleResponse>>
337 template <
class RequestType,
class ResponseType>
365 case State::STREAM_IDLE:
374 alarm_ = absl::make_unique<Alarm>();
377 case State::READY_TO_WRITE:
390 case State::WRITE_DONE:
398 case State::READ_DONE:
414 case State::WRITES_DONE_DONE:
418 case State::FINISH_DONE:
456 std::unique_ptr<grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>(
461 std::unique_ptr<grpc::ClientAsyncReaderWriter<RequestType, ResponseType>>
492 :
public AsyncClient<BenchmarkService::Stub, SimpleRequest> {
505 static std::unique_ptr<
523 template <
class RequestType,
class ResponseType>
551 case State::STREAM_IDLE:
559 alarm_ = absl::make_unique<Alarm>();
563 case State::READY_TO_WRITE:
571 case State::WRITE_DONE:
587 clone->StartInternal(
cq);
608 std::function<std::unique_ptr<grpc::ClientAsyncWriter<RequestType>>(
614 std::unique_ptr<grpc::ClientAsyncWriter<RequestType>>
stream_;
625 :
public AsyncClient<BenchmarkService::Stub, SimpleRequest> {
638 static std::unique_ptr<grpc::ClientAsyncWriter<SimpleRequest>>
PrepareReq(
655 template <
class RequestType,
class ResponseType>
683 case State::STREAM_IDLE:
691 case State::READ_DONE:
708 clone->StartInternal(
cq);
723 std::function<std::unique_ptr<grpc::ClientAsyncReader<ResponseType>>(
729 std::unique_ptr<grpc::ClientAsyncReader<ResponseType>>
stream_;
741 :
public AsyncClient<BenchmarkService::Stub, SimpleRequest> {
754 static std::unique_ptr<grpc::ClientAsyncReader<SimpleResponse>>
PrepareReq(
776 std::function<std::unique_ptr<grpc::GenericClientAsyncReaderWriter>(
798 case State::STREAM_IDLE:
807 alarm_ = absl::make_unique<Alarm>();
810 case State::READY_TO_WRITE:
818 case State::WRITE_DONE:
825 case State::READ_DONE:
836 case State::WRITES_DONE_DONE:
840 case State::FINISH_DONE:
876 std::function<std::unique_ptr<grpc::GenericClientAsyncReaderWriter>(
882 std::unique_ptr<grpc::GenericClientAsyncReaderWriter>
stream_;
891 "/grpc.testing.BenchmarkService/StreamingCall");
901 const std::shared_ptr<Channel>&
ch) {
902 return absl::make_unique<grpc::GenericStub>(
ch);
906 :
public AsyncClient<grpc::GenericStub, ByteBuffer> {
918 static std::unique_ptr<grpc::GenericClientAsyncReaderWriter>
PrepareReq(
935 switch (
config.rpc_type()) {
940 case STREAMING_FROM_CLIENT:
941 return std::unique_ptr<Client>(
943 case STREAMING_FROM_SERVER:
944 return std::unique_ptr<Client>(
946 case STREAMING_BOTH_WAYS:
static ClientRpcContext * detag(void *t)
static void * tag(ClientRpcContext *c)
void set_status(int status)
static ClientRpcContext * SetupCtx(BenchmarkService::Stub *stub, std::function< gpr_timespec()> next_issue, const SimpleRequest &req)
~ClientRpcContextStreamingFromServerImpl() override
ClientRpcContextUnaryImpl(BenchmarkService::Stub *stub, const RequestType &req, std::function< gpr_timespec()> next_issue, std::function< std::unique_ptr< grpc::ClientAsyncResponseReader< ResponseType >>(BenchmarkService::Stub *, grpc::ClientContext *, const RequestType &, CompletionQueue *)> prepare_req, std::function< void(grpc::Status, ResponseType *, HistogramEntry *)> on_done)
std::unique_ptr< Client > CreateGenericAsyncStreamingClient(const ClientConfig &config)
std::function< std::unique_ptr< grpc::GenericClientAsyncReaderWriter > grpc::GenericStub *, grpc::ClientContext *, const std::string &, CompletionQueue *)> prepare_req_
grpc::ClientContext context_
static std::unique_ptr< grpc::GenericStub > GenericStubCreator(const std::shared_ptr< Channel > &ch)
static bool setup_ctx(SSL *ssl, EVP_MD_CTX *ctx, EVP_PKEY *pkey, uint16_t sigalg, bool is_verify)
std::function< std::unique_ptr< grpc::ClientAsyncResponseReader< ResponseType > > BenchmarkService::Stub *, grpc::ClientContext *, const RequestType &, CompletionQueue *)> prepare_req_
void StartInternal(CompletionQueue *cq)
std::unique_ptr< Alarm > alarm_
bool ok() const
Is the status OK?
void TryCancel() override
BenchmarkService::Stub * stub_
AsyncUnaryClient(const ClientConfig &config)
std::unique_ptr< grpc::GenericClientAsyncReaderWriter > stream_
std::unique_ptr< grpc::ClientAsyncResponseReader< ResponseType > > response_reader_
std::unique_ptr< Alarm > alarm_
std::function< void(grpc::Status, ByteBuffer *)> callback_
const SimpleRequest * request()
void SetupLoadTest(const ClientConfig &config, size_t num_threads)
const int num_async_threads_
bool RunNextState(bool, HistogramEntry *entry) override
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
static ClientRpcContext * SetupCtx(BenchmarkService::Stub *stub, std::function< gpr_timespec()> next_issue, const SimpleRequest &req)
static struct test_ctx ctx
void ThreadFunc(size_t thread_idx, Client::Thread *t) final
static std::unique_ptr< grpc::ClientAsyncReaderWriter< SimpleRequest, SimpleResponse > > PrepareReq(BenchmarkService::Stub *stub, grpc::ClientContext *ctx, CompletionQueue *cq)
int NumThreads(const ClientConfig &config)
std::function< gpr_timespec()> next_issue_
static AllocList * Next(int i, AllocList *prev, LowLevelAlloc::Arena *arena)
void StartInternal(CompletionQueue *cq, int messages_per_stream)
void DestroyMultithreading() final
std::function< std::unique_ptr< grpc::ClientAsyncReaderWriter< RequestType, ResponseType > > BenchmarkService::Stub *, grpc::ClientContext *, CompletionQueue *)> prepare_req_
static void CheckDone(const grpc::Status &, ByteBuffer *)
static gpr_mu shutdown_mu
std::function< gpr_timespec()> NextIssuer(int thread_idx)
static std::unique_ptr< BenchmarkService::Stub > BenchmarkStubCreator(const std::shared_ptr< Channel > &ch)
grpc::ClientContext context_
Per-message write options.
void StartInternal(CompletionQueue *cq)
std::function< void(grpc::Status, ResponseType *)> callback_
void set_initial_metadata_corked(bool corked)
AsyncStreamingPingPongClient(const ClientConfig &config)
AsyncStreamingFromServerClient(const ClientConfig &config)
std::unique_ptr< grpc::ClientAsyncWriter< RequestType > > stream_
grpc::ClientContext context_
std::unique_ptr< Alarm > alarm_
ClientRpcContextStreamingPingPongImpl(BenchmarkService::Stub *stub, const RequestType &req, std::function< gpr_timespec()> next_issue, std::function< std::unique_ptr< grpc::ClientAsyncReaderWriter< RequestType, ResponseType >>(BenchmarkService::Stub *, grpc::ClientContext *, CompletionQueue *)> prepare_req, std::function< void(grpc::Status, ResponseType *)> on_done)
~AsyncStreamingFromServerClient() override
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
void StartThreads(size_t num_threads)
void TryCancel() override
std::vector< std::unique_ptr< PerThreadShutdownState > > shutdown_state_
virtual void Start(CompletionQueue *cq, const ClientConfig &config)=0
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
static ClientRpcContext * SetupCtx(BenchmarkService::Stub *stub, std::function< gpr_timespec()> next_issue, const SimpleRequest &req)
std::unique_ptr< Alarm > alarm_
ClientRpcContextStreamingFromServerImpl(BenchmarkService::Stub *stub, const RequestType &req, std::function< gpr_timespec()> next_issue, std::function< std::unique_ptr< grpc::ClientAsyncReader< ResponseType >>(BenchmarkService::Stub *, grpc::ClientContext *, const RequestType &, CompletionQueue *)> prepare_req, std::function< void(grpc::Status, ResponseType *)> on_done)
ClientRpcContext * ProcessTag(size_t thread_idx, void *tag)
void StartNewClone(CompletionQueue *cq) override
std::function< std::unique_ptr< grpc::ClientAsyncWriter< RequestType > > BenchmarkService::Stub *, grpc::ClientContext *, ResponseType *, CompletionQueue *)> prepare_req_
std::unique_ptr< Alarm > alarm_
static std::unique_ptr< grpc::ClientAsyncReader< SimpleResponse > > PrepareReq(BenchmarkService::Stub *stub, grpc::ClientContext *ctx, const SimpleRequest &req, CompletionQueue *cq)
grpc::ClientContext context_
GenericAsyncStreamingClient(const ClientConfig &config)
std::function< gpr_timespec()> next_issue_
std::function< void(grpc::Status, ResponseType *)> callback_
~ClientRpcContextStreamingPingPongImpl() override
static void CheckDone(const grpc::Status &s, SimpleResponse *, HistogramEntry *entry)
grpc::ClientContext context_
static ClientRpcContext * SetupCtx(grpc::GenericStub *stub, std::function< gpr_timespec()> next_issue, const ByteBuffer &req)
~ClientRpcContextStreamingFromClientImpl() override
~AsyncUnaryClient() override
bool RunNextState(bool ok, HistogramEntry *entry) override
std::function< gpr_timespec()> next_issue_
static std::unique_ptr< grpc::ClientAsyncResponseReader< SimpleResponse > > PrepareReq(BenchmarkService::Stub *stub, grpc::ClientContext *ctx, const SimpleRequest &request, CompletionQueue *cq)
bool RunNextState(bool ok, HistogramEntry *entry) override
static void * tag(intptr_t t)
virtual void StartNewClone(CompletionQueue *cq)=0
void Start(CompletionQueue *cq, const ClientConfig &config) override
~ClientRpcContextUnaryImpl() override
ClientRpcContextStreamingFromClientImpl(BenchmarkService::Stub *stub, const RequestType &req, std::function< gpr_timespec()> next_issue, std::function< std::unique_ptr< grpc::ClientAsyncWriter< RequestType >>(BenchmarkService::Stub *, grpc::ClientContext *, ResponseType *, CompletionQueue *)> prepare_req, std::function< void(grpc::Status, ResponseType *)> on_done)
std::unique_ptr< grpc::ClientAsyncReader< ResponseType > > stream_
BenchmarkService::Stub * stub_
void Start(CompletionQueue *cq, const ClientConfig &config) override
virtual bool RunNextState(bool, HistogramEntry *entry)=0
static std::unique_ptr< grpc::ClientAsyncWriter< SimpleRequest > > PrepareReq(BenchmarkService::Stub *stub, grpc::ClientContext *ctx, SimpleResponse *resp, CompletionQueue *cq)
AsyncClient(const ClientConfig &config, std::function< ClientRpcContext *(StubType *, std::function< gpr_timespec()> next_issue, const RequestType &)> setup_ctx, std::function< std::unique_ptr< StubType >(std::shared_ptr< Channel >)> create_stub)
static std::unique_ptr< grpc::GenericClientAsyncReaderWriter > PrepareReq(grpc::GenericStub *stub, grpc::ClientContext *ctx, const std::string &method_name, CompletionQueue *cq)
~ClientRpcContextGenericStreamingImpl() override
void Start(CompletionQueue *cq, const ClientConfig &config) override
~GenericAsyncStreamingClient() override
struct gpr_timespec gpr_timespec
static ClientRpcContext * SetupCtx(BenchmarkService::Stub *stub, std::function< gpr_timespec()> next_issue, const SimpleRequest &req)
void TryCancel() override
static void CheckDone(const grpc::Status &, SimpleResponse *)
void StartInternal(CompletionQueue *cq, int messages_per_stream, bool coalesce)
std::vector< ClientChannelInfo > channels_
void TryCancel() override
void StartNewClone(CompletionQueue *cq) override
void TryCancel() override
int GetPollCount() override
static volatile int num_threads
std::function< void(grpc::Status, ResponseType *)> callback_
ClientRpcContextGenericStreamingImpl(grpc::GenericStub *stub, const ByteBuffer &req, std::function< gpr_timespec()> next_issue, std::function< std::unique_ptr< grpc::GenericClientAsyncReaderWriter >(grpc::GenericStub *, grpc::ClientContext *, const std::string &method_name, CompletionQueue *)> prepare_req, std::function< void(grpc::Status, ByteBuffer *)> on_done)
void StartNewClone(CompletionQueue *cq) override
BenchmarkService::Stub * stub_
void Start(CompletionQueue *cq, const ClientConfig &config) override
void StartInternal(CompletionQueue *cq)
BenchmarkService::Stub * stub_
virtual ~ClientRpcContext()
std::function< gpr_timespec()> next_issue_
AsyncStreamingFromClientClient(const ClientConfig &config)
bool RunNextState(bool ok, HistogramEntry *entry) override
~AsyncStreamingPingPongClient() override
static void CheckDone(const grpc::Status &, SimpleResponse *)
std::function< void(grpc::Status, ResponseType *, HistogramEntry *)> callback_
bool RunNextState(bool ok, HistogramEntry *entry) override
~AsyncStreamingFromClientClient() override
std::unique_ptr< grpc::ClientAsyncReaderWriter< RequestType, ResponseType > > stream_
void StartNewClone(CompletionQueue *cq) override
virtual void TryCancel()=0
void StartNewClone(CompletionQueue *cq) override
def create_stub(channel, args)
grpc::GenericStub * stub_
static void CheckDone(const grpc::Status &, SimpleResponse *)
int grpc_get_cq_poll_num(grpc_completion_queue *cq)
absl::string_view method_name
void Start(CompletionQueue *cq, const ClientConfig &config) override
std::function< std::unique_ptr< grpc::ClientAsyncReader< ResponseType > > BenchmarkService::Stub *, grpc::ClientContext *, const RequestType &, CompletionQueue *)> prepare_req_
std::unique_ptr< Client > CreateAsyncClient(const ClientConfig &config)
static grpc_completion_queue * cq
std::vector< std::unique_ptr< CompletionQueue > > cli_cqs_
std::function< gpr_timespec()> next_issue_
std::vector< std::function< gpr_timespec()> > next_issuers_
grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:46