2

I am trying to measure an API using Google Benchmark. It deals with the client/server code. The Google Benchmark application, runs the setUp() TearDown() pairs several times to measure the timing in an appropriate way. The client/server works over TCP Transport.

Problem: Within a single process (Google Benchmark) the client is restarted many number of times. This causes remnant anonymous inodes existing and as a result, I get an error

epoll: too many files open

When I try lsof | grep "a_inode", I see that all the anonymous inodes created by eventfd/eventpoll/filefd exist in opened state.

COMMAND PID TID USER FD TYPE DEVICE SIZE/OFF NODE NAME

gbench 6514 6517 boarnerges 1020u a_inode 0,13 0 9567 [eventfd]

gbench 6514 6517 boarnerges 1021u a_inode 0,13 0 9567 [eventpoll]

gbench 6514 6517 boarnerges 1022u a_inode 0,13 0 9567 [timerfd]

gbench 6514 6520 boarnerges cwd DIR 8,1 4096 543203 /home/boarnerges/project_GoogleBenchmark/build

gbench 6514 6520 boarnerges rtd DIR 8,1 4096 2 /

gbench 6514 6520 boarnerges txt REG 8,1 2494784 949699 /home/boarnerges/project_GoogleBenchmark/build/tests/tests/GBenchmarkTests/benchmark_client/it_gbenchmark_client

How do I solve this problem? Can the anonymous inodes be released from within the process?

Community
  • 1
  • 1
Boanerges
  • 476
  • 1
  • 5
  • 16
  • Is this the full output of "lsof | grep a_inode"? 3 does not seem like a lot, or enough to exhaust process- or system-wide file descriptors. It's also not clear to me if it's your code (the one being benchmarked) that is creating these epoll FDs or if it's Google Benchmark. – Tomasz Noinski Apr 23 '19 at 16:08
  • I am using C++ asio library (for the client creation) and it is managing the epoll stuff. This is not the full output of the lsof command. The real output is so so huge. I have just added the last five lines (1020, 1021, 1022). The limit is 1024. – Boanerges Apr 23 '19 at 17:14
  • 1
    I can only guess that asio could be misused to prevent the relevant destructor from closing the epoll file descriptor (which in turn would release the associated anonymous inode). From a quick search, asio is doing this in the destructor of https://www.boost.org/doc/libs/1_42_0/boost/asio/detail/epoll_reactor.hpp (see "close(epoll_fd_)") – Tomasz Noinski Apr 23 '19 at 20:33

0 Answers0