On 9/6/17, Andrew Morton [off-list ref] wrote:
On Tue, 5 Sep 2017 22:05:00 +0300 Alexey Dobriyan [off-list ref]
wrote:
quoted
Implement system call for bulk retrieveing of pids in binary form.
Using /proc is slower than necessary: 3 syscalls + another 3 for each
thread +
converting with atoi().
/proc may be not mounted especially in containers. Natural extension of
hidepid=2 efforts is to not mount /proc at all.
It could be used by programs like ps, top or CRIU. Speed increase will
become more drastic once combined with bulk retrieval of process
statistics.
The patches are performance optimizations, but their changelogs contain
no performance measurements!
Demonstration of some compelling real-world performance benefits would
help things along a lot.
I forgot the sheet with numbers at work. :^)
They're very embarrassing for /proc.
pidmap:
N=1<<16 times
~130 processes (~250 task_structs) on a regular desktop system
opendir + readdir + closedir /proc + the same for every /proc/$PID/task
(roughly what htop(1) does) vs pidmap
/proc 16.80+-0.73%
pidmap 0.06+-0.31%
fdmap:
N=1<<22 times
4 opened descriptors (0, 1, 2, 3)
opendir+readdir+closedir /proc/self/fd (lsof(1)) vs fdmap
/proc 8.31+-0.37%
fdmap 0.32+-0.72%
Currently performance improvements may not be huge or even visible.
That's because programs like ps/top/lsof _have_ to use /proc to retrieve
other information. If combined with bulk taskstats-ish retrieval interfaces
they should run around /proc.