Skip to content

Commit e49d180

Browse files
committed
perf/bench: replace suite warmup lambdas with per-bench self-warmup
Add --warmup <secs> flag (default 0, disabled) that runs every benchmark once with a throwaway state before the real measurement. The self-warmup exercises the exact code path being measured, eliminating the sync-vs-async warmup asymmetry in the previous scheme where corosio's set_warmup lambdas exercised async I/O paths while asio's used synchronous asio::write/read. Removes benchmark_suite::set_warmup and all 18 .set_warmup([]{...}) call sites across corosio, asio coroutine, and asio callback. For benches with needs_conntrack_drain, drain runs before both warmup and real measurement.
1 parent 4c079c3 commit e49d180

20 files changed

Lines changed: 81 additions & 295 deletions

perf/bench/asio/callback/http_server_bench.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -338,30 +338,6 @@ make_http_server_suite()
338338
{
339339
using F = bench::bench_flags;
340340
return bench::benchmark_suite("http_server", F::needs_conntrack_drain)
341-
.set_warmup([] {
342-
asio::io_context ioc;
343-
auto [c, s] = asio_bench::make_socket_pair(ioc);
344-
char buf[256] = {};
345-
for (int i = 0; i < 10; ++i)
346-
{
347-
asio::write(
348-
c,
349-
asio::buffer(
350-
bench::http::small_request,
351-
bench::http::small_request_size));
352-
asio::read(
353-
s, asio::buffer(buf, bench::http::small_request_size));
354-
asio::write(
355-
s,
356-
asio::buffer(
357-
bench::http::small_response,
358-
bench::http::small_response_size));
359-
asio::read(
360-
c, asio::buffer(buf, bench::http::small_response_size));
361-
}
362-
c.close();
363-
s.close();
364-
})
365341
.add("single_conn", bench_single_connection)
366342
.add("single_conn_lockless", bench_single_connection_lockless)
367343
.add("concurrent", bench_concurrent_connections)

perf/bench/asio/callback/io_context_bench.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,6 @@ make_io_context_suite()
236236
{
237237
using F = bench::bench_flags;
238238
return bench::benchmark_suite("io_context", F::is_microbenchmark)
239-
.set_warmup([] {
240-
asio::io_context ioc;
241-
int64_t counter = 0;
242-
for (int i = 0; i < 1000; ++i)
243-
asio::post(ioc, [&counter] { ++counter; });
244-
ioc.run();
245-
})
246239
.add("single_threaded", bench_single_threaded_post)
247240
.add("multithreaded", bench_multithreaded_scaling)
248241
.args({8})

perf/bench/asio/callback/local_socket_latency_bench.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -284,18 +284,6 @@ make_local_socket_latency_suite()
284284
{
285285
using F = bench::bench_flags;
286286
return bench::benchmark_suite("local_socket_latency", F::none)
287-
.set_warmup([] {
288-
asio::io_context ioc;
289-
auto [c, s] = asio_bench::make_local_socket_pair(ioc);
290-
char buf[64] = {};
291-
for (int i = 0; i < 100; ++i)
292-
{
293-
asio::write(c, asio::buffer(buf));
294-
asio::read(s, asio::buffer(buf));
295-
}
296-
c.close();
297-
s.close();
298-
})
299287
.add("pingpong", bench_pingpong_latency)
300288
.args({1, 64, 1024})
301289
.add("pingpong_lockless", bench_pingpong_latency_lockless)

perf/bench/asio/callback/local_socket_throughput_bench.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,6 @@ make_local_socket_throughput_suite()
248248
{
249249
using F = bench::bench_flags;
250250
return bench::benchmark_suite("local_socket_throughput", F::none)
251-
.set_warmup([] {
252-
asio::io_context ioc;
253-
auto [w, r] = asio_bench::make_local_socket_pair(ioc);
254-
std::vector<char> buf(4096, 'w');
255-
asio::write(w, asio::buffer(buf));
256-
asio::read(r, asio::buffer(buf));
257-
w.close();
258-
r.close();
259-
})
260251
.add("unidirectional", bench_throughput)
261252
.range(1024, 1048576, 4)
262253
.add("unidirectional_lockless", bench_throughput_lockless)

perf/bench/asio/callback/socket_latency_bench.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,6 @@ make_socket_latency_suite()
287287
{
288288
using F = bench::bench_flags;
289289
return bench::benchmark_suite("socket_latency", F::needs_conntrack_drain)
290-
.set_warmup([] {
291-
asio::io_context ioc;
292-
auto [c, s] = asio_bench::make_socket_pair(ioc);
293-
char buf[64] = {};
294-
for (int i = 0; i < 100; ++i)
295-
{
296-
asio::write(c, asio::buffer(buf));
297-
asio::read(s, asio::buffer(buf));
298-
}
299-
c.close();
300-
s.close();
301-
})
302290
.add("pingpong", bench_pingpong_latency)
303291
.args({1, 64, 1024})
304292
.add("pingpong_lockless", bench_pingpong_latency_lockless)

perf/bench/asio/callback/socket_throughput_bench.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,15 +390,6 @@ make_socket_throughput_suite()
390390
{
391391
using F = bench::bench_flags;
392392
return bench::benchmark_suite("socket_throughput", F::needs_conntrack_drain)
393-
.set_warmup([] {
394-
asio::io_context ioc;
395-
auto [w, r] = asio_bench::make_socket_pair(ioc);
396-
std::vector<char> buf(4096, 'w');
397-
asio::write(w, asio::buffer(buf));
398-
asio::read(r, asio::buffer(buf));
399-
w.close();
400-
r.close();
401-
})
402393
.add("unidirectional", bench_throughput)
403394
.range(1024, 1048576, 4)
404395
.add("unidirectional_lockless", bench_throughput_lockless)

perf/bench/asio/coroutine/http_server_bench.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -282,28 +282,6 @@ make_http_server_suite()
282282
using F = bench::bench_flags;
283283

284284
return bench::benchmark_suite("http_server", F::needs_conntrack_drain)
285-
.set_warmup([]{
286-
asio::io_context ioc;
287-
auto [c, s] = make_socket_pair(ioc);
288-
char buf[256] = {};
289-
for (int i = 0; i < 10; ++i)
290-
{
291-
asio::write(
292-
c,
293-
asio::buffer(
294-
bench::http::small_request,
295-
bench::http::small_request_size));
296-
asio::read(s, asio::buffer(buf, bench::http::small_request_size));
297-
asio::write(
298-
s,
299-
asio::buffer(
300-
bench::http::small_response,
301-
bench::http::small_response_size));
302-
asio::read(c, asio::buffer(buf, bench::http::small_response_size));
303-
}
304-
c.close();
305-
s.close();
306-
})
307285
.add("single_conn", bench_single_connection)
308286
.add("single_conn_lockless", bench_single_connection_lockless)
309287
.add("concurrent", bench_concurrent_connections)

perf/bench/asio/coroutine/io_context_bench.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,6 @@ make_io_context_suite()
248248
{
249249
using F = bench::bench_flags;
250250
return bench::benchmark_suite("io_context", F::is_microbenchmark)
251-
.set_warmup([] {
252-
asio::io_context ioc;
253-
int64_t counter = 0;
254-
for (int i = 0; i < 1000; ++i)
255-
asio::co_spawn(ioc, increment_task(counter), asio::detached);
256-
ioc.run();
257-
})
258251
.add("single_threaded", bench_single_threaded_post)
259252
.add("multithreaded", bench_multithreaded_scaling)
260253
.args({8})

perf/bench/asio/coroutine/local_socket_latency_bench.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,6 @@ bench::benchmark_suite
238238
make_local_socket_latency_suite()
239239
{
240240
return bench::benchmark_suite("local_socket_latency")
241-
.set_warmup([] {
242-
asio::io_context ioc;
243-
auto [c, s] = make_local_socket_pair(ioc);
244-
char buf[64] = {};
245-
for (int i = 0; i < 100; ++i)
246-
{
247-
asio::write(c, asio::buffer(buf));
248-
asio::read(s, asio::buffer(buf));
249-
}
250-
c.close();
251-
s.close();
252-
})
253241
.add("pingpong", bench_pingpong_latency)
254242
.args({1, 64, 1024})
255243
.add("pingpong_lockless", bench_pingpong_latency_lockless)

perf/bench/asio/coroutine/local_socket_throughput_bench.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,15 +377,6 @@ bench::benchmark_suite
377377
make_local_socket_throughput_suite()
378378
{
379379
return bench::benchmark_suite("local_socket_throughput")
380-
.set_warmup([] {
381-
asio::io_context ioc;
382-
auto [w, r] = make_local_socket_pair(ioc);
383-
std::vector<char> buf(4096, 'w');
384-
asio::write(w, asio::buffer(buf));
385-
asio::read(r, asio::buffer(buf));
386-
w.close();
387-
r.close();
388-
})
389380
.add("unidirectional", bench_throughput)
390381
.range(1024, 1048576, 4)
391382
.add("unidirectional_lockless", bench_throughput_lockless)

0 commit comments

Comments
 (0)