Skip to content

Commit dbc8a0f

Browse files
committed
update benchmark
1 parent a142446 commit dbc8a0f

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

include/ylt/coro_io/ibverbs/ib_socket.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ struct ib_socket_shared_state_t
206206
sr.opcode = IBV_WR_SEND;
207207
sr.send_flags |= IBV_SEND_SIGNALED;
208208
std::error_code err;
209-
if (self->qp_ == nullptr) {
209+
if (self->has_close_) {
210210
err = std::make_error_code(std::errc::operation_canceled);
211211
}
212212
// post the receive request to the RQ

src/coro_rpc/benchmark/bench.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline std::string_view echo() {
7171
return g_resp_str;
7272
}
7373

74-
ylt::metric::summary_t g_latency{"rpc call latency(us)", "help",
74+
ylt::metric::summary_t g_latency{"Latency(us) of rpc call", "help",
7575
std::vector{0.5, 0.9, 0.95, 0.99},
7676
std::chrono::seconds{60}};
7777

@@ -94,13 +94,15 @@ async_simple::coro::Lazy<void> watcher(const bench_config& conf) {
9494
std::cout << "qps " << c / conf.send_data_len << ", Throughput:" << val
9595
<< " Gb/s\n";
9696
}
97+
98+
std::cout << "# Benchmark result \n";
9799
double val = (8.0 * total) / (1000'000'000ll * conf.duration);
98100
std::cout << "avg qps " << total / (conf.send_data_len * conf.duration)
99101
<< " and throughput:" << val << " Gb/s in duration "
100102
<< conf.duration << "\n";
101103
std::string str_rate;
102104
g_latency.serialize(str_rate);
103-
std::cout << "latency: " << str_rate << "\n";
105+
std::cout << str_rate << "\n";
104106
co_return;
105107
}
106108

@@ -127,7 +129,7 @@ async_simple::coro::Lazy<std::error_code> request(const bench_config& conf) {
127129
auto start = std::chrono::steady_clock::now();
128130
auto result = co_await client.call<echo>();
129131
if (!result.has_value()) {
130-
ELOG_ERROR << result.error().msg;
132+
ELOG_WARN << result.error().msg;
131133
co_return false;
132134
}
133135
auto now = std::chrono::steady_clock::now();

website/docs/zh/coro_rpc/coro_rpc_client.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,46 @@ Lazy<void> call() {
336336
单个coro_rpc_client在多个线程同时调用时需要注意,只有部分成员函数是线程安全的,包括`send_request()`,`close()`,`connect()`,`get_executor()`,`get_pipeline_size()`,`get_client_id()`,`get_config()`等。如果用户没有重新调用connect()函数并传入endpoint或hostname,那么`get_port()`,`get_host()`函数也是线程安全的。
337337
338338
需要注意,`call`,`get_resp_attachment`,`set_req_attachment`,`release_resp_attachment`和`init_config`函数均不是线程安全的,禁止多个线程同时调用。此时只能使用`send_request`实现多个线程并发请求同一个连接。
339+
340+
# coro_rpc 性能测试
341+
先编译coro_rpc 的bench再执行bench命令行,命令行详情:
342+
```
343+
options:
344+
-u, --url url (string [=0.0.0.0:9000])
345+
-s, --send_data_len send data length (unsigned long [=8388608])
346+
-c, --client_concurrency total number of http clients (unsigned int [=0])
347+
-m, --max_request_count max request count (unsigned long [=100000000])
348+
-p, --port server port (unsigned short [=9000])
349+
-r, --resp_len response data length (unsigned long [=13])
350+
-b, --buffer_size buffer size (unsigned int [=2097152])
351+
-o, --log_level Severity::INFO 1 as default, WARN is 4 (int [=1])
352+
-i, --enable_ib enable ib (bool [=1])
353+
-d, --duration duration seconds (unsigned int [=100000])
354+
-?, --help print this message
355+
```
356+
357+
server侧命令行:
358+
`./bench -p 9004 -r 13 -o 5`
359+
360+
含义:启动服务端,response的数据长度为13,日志级别为error(日志级别和easylog的日志级别对应)。
361+
362+
client测命令行:
363+
`./bench -u 0.0.0.0:9004 -c 100 -s 8388608 -o 5 -d 30`
364+
365+
含义:启动100个client去压测,每次请求发送8MB数据,日志级别为error,持续时间30秒。
366+
367+
默认会启用ibverbs,如果希望只测试tcp则添加`-i 0`
368+
369+
性能测试完成之后将输出qps,吞吐和latency数据,测试结果类似于:
370+
```
371+
# Benchmark result
372+
avg qps 2757 and throughput:185.04 Gb/s in duration 30
373+
# HELP Latency(us) of rpc call help
374+
# TYPE Latency(us) of rpc call summary
375+
rpc call latency(us){quantile="0.500000"} 3616.000000
376+
rpc call latency(us){quantile="0.900000"} 3712.000000
377+
rpc call latency(us){quantile="0.950000"} 3776.000000
378+
rpc call latency(us){quantile="0.990000"} 3872.000000
379+
rpc call latency(us)_sum 298707968.000000
380+
rpc call latency(us)_count 82761
381+
```

0 commit comments

Comments
 (0)