[api] Use large socket buffers and remove mid-loop draining

Increase socket buffer to 16MB so benchmarks never hit WOULD_BLOCK
during an inner loop iteration. Remove per-iteration drain_socket
calls that were adding noise and causing the immediate path to
fall back to batching. Drain only between outer iterations.
This commit is contained in:
J. Nick Koston
2026-04-01 08:54:30 -10:00
parent f469a7ced2
commit d717c7b46c
3 changed files with 3 additions and 18 deletions
@@ -54,9 +54,6 @@ static void SendSensorState_Immediate(benchmark::State &state) {
for (auto _ : state) {
for (int i = 0; i < kInnerIterations; i++) {
conn->send_sensor_state(&sensor);
if ((i & 0xFF) == 0)
drain_socket(read_fd);
}
drain_socket(read_fd);
benchmark::DoNotOptimize(conn.get());
@@ -137,12 +134,8 @@ static void ProcessBatch_SingleSensor(benchmark::State &state) {
for (auto _ : state) {
for (int i = 0; i < kInnerIterations; i++) {
// Queue the sensor state, then process the batch
conn->send_sensor_state(&sensor);
bench_process_batch(conn.get());
if ((i & 0xFF) == 0)
drain_socket(read_fd);
}
drain_socket(read_fd);
benchmark::DoNotOptimize(conn.get());
@@ -179,9 +172,6 @@ static void ProcessBatch_5Sensors(benchmark::State &state) {
for (auto &s : sensors)
conn->send_sensor_state(&s);
bench_process_batch(conn.get());
if ((i & 0xFF) == 0)
drain_socket(read_fd);
}
drain_socket(read_fd);
benchmark::DoNotOptimize(conn.get());