Ticket #8391 (closed defect: fixed)
Change 'top' to 'prstat' on Solaris for get_memory_usage() and top()
|Reported by:||drkirkby||Owned by:||drkirkby|
|Report Upstream:||N/A||Reviewers:||Jaap Spies|
|Authors:||David Kirkby||Merged in:||sage-4.3.4.alpha1|
Description (last modified by drkirkby) (diff)
The file 'getusage.py' has two main functions.
- top() - Display the output of the 'top' command for the current process.
- get_memory_usage() - Display the memory usage in MB.
The Sage implementation of top() and get_memory_usage() on Solaris are particularly poor for many reasons.
- The Sage function 'top()' calls the external command 'top' on Solaris, despite the fact that 'top' has never been part of the Solaris operating system. ('top' can be installed, but it is not standard.)
- The Sage function get_memory_usage() calls the function top(), so obviously get_memory_usage() fails if the command 'top' is not installed.
- 'top' is not very accurate on modern Solaris versions - it was OK 10+ years ago, but not now.
- You need root access to install 'top'.
- The ticket #6028 created by Micheal Abshoff with the title "get_memory_usage() sucks performance wise on Solaris" gives a gentle hint at one more problem.
- I believe not having 'top' is causing doctest failures, which brings the system to an almost standstill as documented at #7153.
Even having it causes failures, as noted above.
Overall, the usage of 'top' in Solaris is a disaster.
The proper way to get the memory usage is to use a system call, but it is going to take some effort to sort out how to do so and is not high on the list of priorities.
A command with similar functionality to 'top', but greater accuracy is '/usr/bin/prstat' which comes as part of all recent versions of Solaris. The output looks similar to that of 'top'
PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP 604 drkirkby 189M 106M cpu2 59 0 537:45:37 11% Xorg/1 28286 drkirkby 78M 19M sleep 32 0 244:22:50 5.2% zenity/1 15753 drkirkby 553M 517M sleep 49 0 46:10:43 0.5% VirtualBox/24 14951 drkirkby 345M 161M sleep 48 0 0:07:45 0.3% firefox-bin/20 22223 drkirkby 163M 80M sleep 59 0 0:06:58 0.0% gnome-terminal/2 731 drkirkby 106M 26M sleep 59 0 0:14:12 0.0% gnome-netstatus/2 719 drkirkby 113M 34M sleep 59 0 0:08:23 0.0% wnck-applet/1 7703 drkirkby 6328K 3144K cpu3 49 0 0:00:00 0.0% prstat/1 730 drkirkby 107M 26M sleep 59 0 0:09:18 0.0% mixer_applet2/1 741 root 1636K 1080K sleep 59 0 0:12:55 0.0% gnome-netstatus/1 663 drkirkby 94M 35M sleep 59 0 0:06:55 0.0% metacity/1 294 root 4804K 2056K sleep 59 0 0:00:00 0.0% dbus-daemon/1 153 root 6396K 2824K sleep 59 0 0:00:00 0.0% picld/4 385 root 5140K 1576K sleep 59 0 0:00:00 0.0% automountd/2 270 root 4596K 1420K sleep 59 0 0:00:02 0.0% cron/1 Total: 141 processes, 389 lwps, load averages: 1.79, 1.70, 1.66
Hence I propose to replace the call to 'top' with one to 'prstat'. Despite I know this is not the correct way to determine memory usage, using 'prstat' is at least better than the current implementation using 'top'
- Summary changed from Temporary ugly fix: Change 'top' to 'prstat' on Solaris for 'getusage.py' to Change 'top' to 'prstat' on Solaris for get_memory_usage() and top()
- Status changed from new to needs_review
- Milestone set to sage-4.3.4
- Authors set to David Kirkby
Changed 3 years ago by drkirkby
- attachment trac_8391-prstat_solaris-multiply-divide=1024.patch added
- Status changed from needs_review to positive_review
- Reviewers set to Jaap Spies