MCPcopy Create free account
hub / github.com/apache/arrow / DoSinglePerfRun

Function DoSinglePerfRun

cpp/src/arrow/flight/flight_benchmark.cc:273–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

271}
272
273Status DoSinglePerfRun(FlightClient* client, const FlightClientOptions client_options,
274 const FlightCallOptions& call_options, bool test_put,
275 PerformanceStats* stats) {
276 // schema not needed
277 perf::Perf perf;
278 perf.set_stream_count(FLAGS_num_streams);
279 perf.set_records_per_stream(FLAGS_records_per_stream);
280 perf.set_records_per_batch(FLAGS_records_per_batch);
281
282 // Plan the query
283 FlightDescriptor descriptor;
284 descriptor.type = FlightDescriptor::CMD;
285 perf.SerializeToString(&descriptor.cmd);
286
287 ARROW_ASSIGN_OR_RAISE(auto plan, client->GetFlightInfo(call_options, descriptor));
288
289 // Read the streams in parallel
290 ipc::DictionaryMemo dict_memo;
291 ARROW_ASSIGN_OR_RAISE(auto schema, plan->GetSchema(&dict_memo));
292
293 int64_t start_total_records = stats->total_records;
294
295 auto test_loop = test_put ? &RunDoPutTest : &RunDoGetTest;
296 auto ConsumeStream = [&client, &stats, &test_loop, &client_options,
297 &call_options](const FlightEndpoint& endpoint) {
298 std::unique_ptr<FlightClient> local_client;
299 FlightClient* data_client;
300 if (endpoint.locations.empty()) {
301 data_client = client;
302 } else {
303 ARROW_ASSIGN_OR_RAISE(
304 local_client,
305 FlightClient::Connect(endpoint.locations.front(), client_options));
306 data_client = local_client.get();
307 }
308
309 perf::Token token;
310 token.ParseFromString(endpoint.ticket.ticket);
311
312 const auto& result = test_loop(data_client, call_options, token, endpoint, stats);
313 if (result.ok()) {
314 const PerformanceResult& perf = result.ValueOrDie();
315 stats->Update(perf.num_batches, perf.num_records, perf.num_bytes);
316 }
317 return result.status();
318 };
319
320 // XXX(wesm): Serial version for debugging
321 // for (const auto& endpoint : plan->endpoints()) {
322 // RETURN_NOT_OK(ConsumeStream(endpoint));
323 // }
324
325 ARROW_ASSIGN_OR_RAISE(auto pool, ThreadPool::Make(FLAGS_num_threads));
326 std::vector<Future<>> tasks;
327 for (const auto& endpoint : plan->endpoints()) {
328 ARROW_ASSIGN_OR_RAISE(auto task, pool->Submit(ConsumeStream, endpoint));
329 tasks.push_back(std::move(task));
330 }

Callers 1

RunPerformanceTestFunction · 0.85

Calls 11

ValueOrDieMethod · 0.80
push_backMethod · 0.80
ARROW_ASSIGN_OR_RAISEFunction · 0.70
InvalidFunction · 0.50
OKFunction · 0.50
SerializeToStringMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45
okMethod · 0.45
UpdateMethod · 0.45
statusMethod · 0.45

Tested by

no test coverage detected