Add PSS (proportional set size), Swap and SwapPSS calculation on Linux#843
Add PSS (proportional set size), Swap and SwapPSS calculation on Linux#843ntninja wants to merge 2 commits intohishamhm:masterfrom
Conversation
|
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. |
|
|
||
| static bool LinuxProcessList_readSmapsFile(LinuxProcess* process, const char* dirname, const char* name, bool haveSmapsRollup) { | ||
| //http://elixir.free-electrons.com/linux/v4.10/source/fs/proc/task_mmu.c#L719 | ||
| //kernel will return data in chunks of size PAGE_SIZE or less. |
There was a problem hiding this comment.
@hishamhm: True and well analyzed! However, such reads will never happen for regular smaps because data is returned in chunks of PAGE_SIZE. For smaps_rollup, as you have correctly pointed out, this discussion is irrelevant anyways.
Regarding the verification of this claim: The linked code does appear to write out each result entry separately and when I run strace cat /proc/$$/smaps each read returns as many entries as fit into a 4k-page, without any “half-entries”.
(For the most part we have to trust the previous author's judgment here. Fortunately however we do not need to worry about kernel changes, since we're only really talking about Linux ~2.6.26 up to 2.13 here).
|
@hishamhm: I have already explained why this is not a problem in the comment above. Mind considering a merge again? |
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
|
@hishamhm: Ping |
|
Merged here: htop-dev/htop@f9625ca |
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>/smapsis 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 uselessActually this is not true making PSS data somewhat usable, but incomplete for users other than the current user, unless you're root. 🙁htopruns as root.smapsdata 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