htop
htop copied to clipboard
Add PSS (proportional set size), Swap and SwapPSS calculation on Linux
I did not write this code and took a patch for this from https://github.com/linvinus/htop-mod. Please tell me about any improvements required.
While I can attest PSS to be a big improvement over RSS, there are some pain points about this:
-
/proc/<pid>/smaps
is only readable by the (effective?) user of the given process. ~Since PSS calculation requires all memory mapping tables to be available for accurate calculation, this makes the PSS value somewhat uselesshtop
runs as root.~ Actually this is not true making PSS data somewhat usable, but incomplete for users other than the current user, unless you're root. :slightly_frowning_face: - Greatly improved on Linux 4.14+ thanks to @himikof's suggestion! (Crunching the
smaps
data noticeably slows downhtop
– far from unusable, but slower.)
Original code was written by Craig M. Brandenburg for htop 1.0.2 Many performance improvements by GitHub user linvinus, ported to htop 2.0.2
Maybe the code could be extended to try smaps_rollup if available (in kernel since 4.14)? The format is exactly the same, just less data to parse.
@himikof: Thanks for the suggestion! I've implemented your suggestion and it does give quite a performance boost. Still not as quite snappy as when not reading any smaps file, but it stops the UI from feeling somewhat sluggish while PSS reporting is enabled.
Thanks for the patch! I still need to take some time to give it a spin, but on first glance my initial comment is that we'll probably not want to enable PSS by default, given the performance concerns.
I agree one that sentiment unfortunately. The original patch had it in by default, but given the speed on pre-4.14 kernels and the root requirement (that RSS and friends doesn't have) for complete reporting it is really a sane default currently. Let me know of any other things you notice and I'll apply the requested updates once there is more to do.
@hishamhm: I have already explained why this is not a problem in the comment above. Mind considering a merge again?
@hishamhm: Ping
Merged here: htop-dev/htop@f9625ca