tpo/debian-goodies — pull request #2 by bisscuitt (2014-12-17 23:52:17+00:00)
Title: POC: Checkrestart performance improvements

This is a proof of concept to remove the requirement of `lsof` from `checkrestart`

`lsof` can take a long time to return on systems with a large number of files causing `checkrestart` to to take minutes to run. `lsof` also appears to use lots of CPU resources on systems with a large number of open files:

# time checkrestart -p
Found 1 processes using old versions of upgraded files
(1 distinct program)
(1 distinct packages)
These processes do not seem to have an associated init script to restart them:
ruby1.9.1:
8408 /usr/bin/ruby1.9.1

real 1m3.366s
user 0m33.206s
sys 0m31.298s```

By utilising `/proc//fd` to find open files natively in python and `pmap` to find mmap'd files in processes we can significantly reduce the processing time:

# time /home/luser/checkrestart -p
Found 1 processes using old versions of upgraded files
(1 distinct program)
(1 distinct packages)
These processes do not seem to have an associated init script to restart them:
ruby1.9.1:
8408 /usr/bin/ruby1.9.1

real 0m0.463s
user 0m0.136s
sys 0m0.144s```

I've also added an option to ignore specific pids during the check. Our MySQL servers have a ton of open files and we can reduce processing by ignoring the mysql daemon completely:

```/home/luser/checkrestart -p -e`cat /var/run/mysqld/mysqld.pid` ```