Closed bobrik closed 1 year ago
Looks nice, thanks. I just realized that we don't have any tests for fd_count()
... would you mind adding a small commit that calls fd_count
-- probably best in test_all()
or test_proc_fds()
Sure, I added a basic test to make sure that the count increments and decrements as expected. It needs to run single threaded to avoid picking up fds from other threads. Let me know if you had something else in mind.
That's perfect, thank you!
Existing slow path takes ~52000us of CPU time on my laptop to count 100k open files. Compare this to just 13us for the baseline, when no extra files are open by a program:
Adding fastpath from Linux v6.2 makes it fast:
This is before taking in account any lock contention effects in the kernel if you try to count files from multiple threads concurrently, which makes the slow path even slower, burning a lot more CPU in the process. See:
I used the following code to benchmark:
See also: https://github.com/prometheus/procfs/pull/486