summaryrefslogtreecommitdiffhomepage
path: root/test/perf/linux
diff options
context:
space:
mode:
authorRahat Mahmood <rahat@google.com>2021-07-23 10:21:31 -0700
committergVisor bot <gvisor-bot@google.com>2021-07-23 10:24:39 -0700
commitc3c5c55d134dcc22480984e3882072b936bae899 (patch)
treefb9a3c6fff099d86c64c87227a8629e9431b7225 /test/perf/linux
parentaa2698170041e9bc00542378269231b5eaeffd5d (diff)
Handle EINTR from socket syscalls in send/recv benchmark.
The benchmark check fails if any of the socket syscalls fail with EINTR. We see this manifest in S/R lifecycles since S/R has a high probability of aborting these syscalls with EINTR. PiperOrigin-RevId: 386480365
Diffstat (limited to 'test/perf/linux')
-rw-r--r--test/perf/linux/send_recv_benchmark.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/perf/linux/send_recv_benchmark.cc b/test/perf/linux/send_recv_benchmark.cc
index 41509e211..2d443f54f 100644
--- a/test/perf/linux/send_recv_benchmark.cc
+++ b/test/perf/linux/send_recv_benchmark.cc
@@ -80,6 +80,9 @@ void BM_Recvmsg(benchmark::State& state) {
int64_t bytes_received = 0;
for (auto ignored : state) {
int n = recvmsg(recv_socket.get(), recv_msg.header(), 0);
+ if (n == -1 && errno == EINTR) {
+ continue;
+ }
TEST_CHECK(n > 0);
bytes_received += n;
}
@@ -108,6 +111,9 @@ void BM_Sendmsg(benchmark::State& state) {
int64_t bytes_sent = 0;
for (auto ignored : state) {
int n = sendmsg(send_socket.get(), send_msg.header(), 0);
+ if (n == -1 && errno == EINTR) {
+ continue;
+ }
TEST_CHECK(n > 0);
bytes_sent += n;
}
@@ -137,6 +143,9 @@ void BM_Recvfrom(benchmark::State& state) {
for (auto ignored : state) {
int n = recvfrom(recv_socket.get(), recv_buffer, kMessageSize, 0, nullptr,
nullptr);
+ if (n == -1 && errno == EINTR) {
+ continue;
+ }
TEST_CHECK(n > 0);
bytes_received += n;
}
@@ -166,6 +175,9 @@ void BM_Sendto(benchmark::State& state) {
int64_t bytes_sent = 0;
for (auto ignored : state) {
int n = sendto(send_socket.get(), send_buffer, kMessageSize, 0, nullptr, 0);
+ if (n == -1 && errno == EINTR) {
+ continue;
+ }
TEST_CHECK(n > 0);
bytes_sent += n;
}
@@ -247,6 +259,9 @@ void BM_RecvmsgWithControlBuf(benchmark::State& state) {
int64_t bytes_received = 0;
for (auto ignored : state) {
int n = recvmsg(recv_socket.get(), recv_msg.header(), 0);
+ if (n == -1 && errno == EINTR) {
+ continue;
+ }
TEST_CHECK(n > 0);
bytes_received += n;
}
@@ -316,7 +331,11 @@ void BM_SendmsgTCP(benchmark::State& state) {
ScopedThread t([&recv_msg, &recv_socket, &notification] {
while (!notification.HasBeenNotified()) {
- TEST_CHECK(recvmsg(recv_socket.get(), recv_msg.header(), 0) >= 0);
+ int rc = recvmsg(recv_socket.get(), recv_msg.header(), 0);
+ if (rc == -1 && errno == EINTR) {
+ continue;
+ }
+ TEST_CHECK(rc >= 0);
}
});