Skip to content

Commit aa6f57b

Browse files
committed
test(vsock): remove delay in measurement
Signed-off-by: Aaron Ang <aaron.angyd@gmail.com>
1 parent d2445d8 commit aa6f57b

2 files changed

Lines changed: 11 additions & 35 deletions

File tree

tests/host_tools/vsock_helper.c

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ int print_usage() {
3333
fprintf(stderr, " Connect to echo server at CID:port. Pipe STDIN to server,\n");
3434
fprintf(stderr, " server response to STDOUT.\n");
3535
fprintf(stderr, "\n");
36-
fprintf(stderr, " ping <cid> <port> <count> <delay>\n");
36+
fprintf(stderr, " ping <cid> <port> <count>\n");
3737
fprintf(stderr, " Send <count> ping messages to echo server at CID:port.\n");
38-
fprintf(stderr, " <delay> is the delay in seconds between pings (float).\n");
3938
fprintf(stderr, " Prints RTT for each ping in microseconds.\n");
4039
fprintf(stderr, "\n");
41-
fprintf(stderr, " ping-uds <uds_path> <port> <count> <delay>\n");
40+
fprintf(stderr, " ping-uds <uds_path> <port> <count>\n");
4241
fprintf(stderr, " Send <count> ping messages to echo server at <uds_path>:port.\n");
4342
fprintf(stderr, " Uses Unix Domain Socket with Firecracker CONNECT protocol.\n");
44-
fprintf(stderr, " <delay> is the delay in seconds between pings (float).\n");
4543
fprintf(stderr, " Prints RTT for each ping in microseconds.\n");
4644
fprintf(stderr, "\n");
4745
return -1;
@@ -101,7 +99,7 @@ int run_echo(uint32_t cid, uint32_t port) {
10199
}
102100

103101

104-
int run_ping(uint32_t cid, uint32_t port, int count, double delay_sec) {
102+
int run_ping(uint32_t cid, uint32_t port, int count) {
105103

106104
int sock = socket(AF_VSOCK, SOCK_STREAM, 0);
107105
if (sock < 0) {
@@ -123,10 +121,6 @@ int run_ping(uint32_t cid, uint32_t port, int count, double delay_sec) {
123121
char ping_msg[64];
124122
memset(ping_msg, 'A', sizeof(ping_msg));
125123

126-
struct timespec delay_ts;
127-
delay_ts.tv_sec = (time_t)delay_sec;
128-
delay_ts.tv_nsec = (long)((delay_sec - (time_t)delay_sec) * 1000000000);
129-
130124
for (int seq = 1; seq <= count; seq++) {
131125
struct timespec start, end;
132126

@@ -168,18 +162,14 @@ int run_ping(uint32_t cid, uint32_t port, int count, double delay_sec) {
168162

169163
printf("rtt=%.3f us seq=%d\n", (double)rtt_us, seq);
170164
fflush(stdout);
171-
172-
if (seq < count && delay_sec > 0) {
173-
nanosleep(&delay_ts, NULL);
174-
}
175165
}
176166

177167
close(sock);
178168
return 0;
179169
}
180170

181171

182-
int run_ping_uds(const char *uds_path, uint32_t port, int count, double delay_sec) {
172+
int run_ping_uds(const char *uds_path, uint32_t port, int count) {
183173

184174
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
185175
if (sock < 0) {
@@ -231,10 +221,6 @@ int run_ping_uds(const char *uds_path, uint32_t port, int count, double delay_se
231221
char ping_msg[64];
232222
memset(ping_msg, 'A', sizeof(ping_msg));
233223

234-
struct timespec delay_ts;
235-
delay_ts.tv_sec = (time_t)delay_sec;
236-
delay_ts.tv_nsec = (long)((delay_sec - (time_t)delay_sec) * 1000000000);
237-
238224
for (int seq = 1; seq <= count; seq++) {
239225
struct timespec start, end;
240226

@@ -276,10 +262,6 @@ int run_ping_uds(const char *uds_path, uint32_t port, int count, double delay_se
276262

277263
printf("rtt=%.3f us seq=%d\n", (double)rtt_us, seq);
278264
fflush(stdout);
279-
280-
if (seq < count && delay_sec > 0) {
281-
nanosleep(&delay_ts, NULL);
282-
}
283265
}
284266

285267
close(sock);
@@ -306,33 +288,31 @@ int main(int argc, char **argv) {
306288
}
307289

308290
if (strcmp(argv[1], "ping") == 0) {
309-
if (argc != 6) {
291+
if (argc != 5) {
310292
return print_usage();
311293
}
312294
uint32_t cid = atoi(argv[2]);
313295
uint32_t port = atoi(argv[3]);
314296
int count = atoi(argv[4]);
315-
double delay = atof(argv[5]);
316297

317-
if (!cid || !port || count <= 0 || delay < 0) {
298+
if (!cid || !port || count <= 0) {
318299
return print_usage();
319300
}
320-
return run_ping(cid, port, count, delay);
301+
return run_ping(cid, port, count);
321302
}
322303

323304
if (strcmp(argv[1], "ping-uds") == 0) {
324-
if (argc != 6) {
305+
if (argc != 5) {
325306
return print_usage();
326307
}
327308
const char *uds_path = argv[2];
328309
uint32_t port = atoi(argv[3]);
329310
int count = atoi(argv[4]);
330-
double delay = atof(argv[5]);
331311

332-
if (!port || count <= 0 || delay < 0) {
312+
if (!port || count <= 0) {
333313
return print_usage();
334314
}
335-
return run_ping_uds(uds_path, port, count, delay);
315+
return run_ping_uds(uds_path, port, count);
336316
}
337317

338318
return print_usage();

tests/integration_tests/performance/test_vsock.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ def test_vsock_latency_g2h(uvm_plain_acpi, vcpus, metrics, bin_vsock_path):
157157
"""
158158
rounds = 15
159159
requests_per_round = 30
160-
delay_sec = 0.01
161160

162161
mem_size_mib = 1024
163162
vm = uvm_plain_acpi
@@ -201,8 +200,7 @@ def test_vsock_latency_g2h(uvm_plain_acpi, vcpus, metrics, bin_vsock_path):
201200
samples = []
202201
for _ in range(rounds):
203202
_, ping_output, _ = vm.ssh.check_output(
204-
f"/tmp/vsock_helper ping 2 {ECHO_SERVER_PORT} "
205-
f"{requests_per_round} {delay_sec}"
203+
f"/tmp/vsock_helper ping 2 {ECHO_SERVER_PORT} {requests_per_round}"
206204
)
207205
samples.extend(consume_vsock_ping_output(ping_output))
208206

@@ -227,7 +225,6 @@ def test_vsock_latency_h2g(uvm_plain_acpi, vcpus, metrics, bin_vsock_path):
227225
"""
228226
rounds = 15
229227
requests_per_round = 30
230-
delay_sec = 0.01
231228

232229
mem_size_mib = 1024
233230
vm = uvm_plain_acpi
@@ -258,7 +255,6 @@ def test_vsock_latency_h2g(uvm_plain_acpi, vcpus, metrics, bin_vsock_path):
258255
uds_path,
259256
str(ECHO_SERVER_PORT),
260257
str(requests_per_round),
261-
str(delay_sec),
262258
],
263259
capture_output=True,
264260
text=True,

0 commit comments

Comments
 (0)