MCPcopy Create free account
hub / github.com/apache/impala / TEST

Function TEST

be/src/kudu/rpc/service_queue-test.cc:100–148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100TEST(TestServiceQueue, LifoServiceQueuePerf) {
101 LifoServiceQueue queue(FLAGS_max_queue_size);
102 vector<std::thread> producers;
103 vector<std::thread> consumers;
104
105 for (int i = 0; i < FLAGS_num_producers; i++) {
106 producers.emplace_back(&ProducerThread<LifoServiceQueue>, &queue);
107 }
108
109 for (int i = 0; i < FLAGS_num_consumers; i++) {
110 consumers.emplace_back(&ConsumerThread<LifoServiceQueue>, &queue);
111 }
112
113 int seconds = AllowSlowTests() ? 10 : 1;
114 uint64_t total_sample = 0;
115 uint64_t total_queue_len = 0;
116 uint64_t total_idle_workers = 0;
117 Stopwatch sw(Stopwatch::ALL_THREADS);
118 sw.start();
119 int32_t before = total;
120
121 for (int i = 0; i < seconds * 50; i++) {
122 SleepFor(MonoDelta::FromMilliseconds(20));
123 total_sample++;
124 total_queue_len += queue.estimated_queue_length();
125 total_idle_workers += queue.estimated_idle_worker_count();
126 }
127
128 sw.stop();
129 int32_t delta = total - before;
130
131 queue.Shutdown();
132 for (int i = 0; i < FLAGS_num_producers; i++) {
133 producers[i].join();
134 }
135 for (int i = 0; i < FLAGS_num_consumers; i++) {
136 consumers[i].join();
137 }
138
139 float reqs_per_second = static_cast<float>(delta / sw.elapsed().wall_seconds());
140 float user_cpu_micros_per_req = static_cast<float>(sw.elapsed().user / 1000.0 / delta);
141 float sys_cpu_micros_per_req = static_cast<float>(sw.elapsed().system / 1000.0 / delta);
142
143 LOG(INFO) << "Reqs/sec: " << (int32_t)reqs_per_second;
144 LOG(INFO) << "User CPU per req: " << user_cpu_micros_per_req << "us";
145 LOG(INFO) << "Sys CPU per req: " << sys_cpu_micros_per_req << "us";
146 LOG(INFO) << "Avg rpc queue length: " << total_queue_len / static_cast<double>(total_sample);
147 LOG(INFO) << "Avg idle workers: " << total_idle_workers / static_cast<double>(total_sample);
148}
149
150} // namespace rpc
151} // namespace kudu

Callers

nothing calls this directly

Calls 10

AllowSlowTestsFunction · 0.85
SleepForFunction · 0.85
wall_secondsMethod · 0.80
elapsedMethod · 0.80
startMethod · 0.65
stopMethod · 0.65
ShutdownMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected