Don't let find drop into /proc
By user12625760 on Sep 12, 2007
Today I had the pleasure of looking at a crash dump of a system where ps, prstat et al were hanging. I never got the chance to get to the bottom of it due to meetings. However there was one command that was running on that dump that jumped out as doing lots of harm to the performance of the system for no benefit. The command was “find / .....”. The find had descended into “/proc” where it would have been walking all the directories locking and unlocking processes when what it was looking for was never going to be in /proc. Clive pointed out similar issues from running ps, prstat on performance by walking /proc and supplied the dtrace to show it.
Given that it is so rarely the case that you would want a find starting form “/” to drop into /proc I wonder if it would not be better if either /proc was invisible in the same way as the “.zfs” directories can be invisible in ZFS. I'd be interested in comments on that.
In the mean time if you really want to run find from “/” do this:
find / \\( -fstype proc -prune \\) -o ....
It will not descend into procfs but in all other respects will be the same.