From 15fdd74e5c5d2558317733cdd4fc62764439e6bb Mon Sep 17 00:00:00 2001 From: Ghanan Gowripalan Date: Mon, 16 Oct 2023 13:43:29 -0700 Subject: [PATCH] Limit SelectAllEvents benchmark to 512 FDs ...since `select` only supports FD values up to 1024 and creating 1024 event FDs will result in FD values that are greater than 1024 because of the initial set of FDs that exist for most programs (stdin, stdout, stderr). https://www.man7.org/linux/man-pages/man2/select.2.html PiperOrigin-RevId: 573916775 --- test/perf/linux/select_benchmark.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/perf/linux/select_benchmark.cc b/test/perf/linux/select_benchmark.cc index 803310d50..bc6718456 100644 --- a/test/perf/linux/select_benchmark.cc +++ b/test/perf/linux/select_benchmark.cc @@ -46,6 +46,8 @@ void Setup(int count, std::vector& event_fds, fd_set& read_fds, FD_SET(fd.get(), &read_fds); event_fds.push_back(std::move(fd)); } + + ASSERT_LT(max_fd, FD_SETSIZE); } // Benchmarks a call to select(2) when no FD is "ready" with varying timeout @@ -94,7 +96,7 @@ void BM_SelectAllEvents(benchmark::State& state) { } } -BENCHMARK(BM_SelectAllEvents)->Range(/*start=*/2, /*limit=*/1024); +BENCHMARK(BM_SelectAllEvents)->Range(/*start=*/2, /*limit=*/512); } // namespace