Ticket #12828 (closed enhancement: fixed)
get_memory_usage and top under FreeBSD
| Reported by: | stephen | Owned by: | pjeremy |
|---|---|---|---|
| Priority: | major | Milestone: | sage-5.9 |
| Component: | porting: BSD | Keywords: | |
| Cc: | jpflori | Work issues: | |
| Report Upstream: | N/A | Reviewers: | Karl-Dieter Crisman |
| Authors: | Stephen Montgomery-Smith | Merged in: | sage-5.9.beta0 |
| Dependencies: | Stopgaps: |
Description (last modified by kcrisman) (diff)
Suggested changes to sage/misc/getusage.py:
--- sage-5.0.beta13/sage/misc/getusage.py-orig 2012-04-11 00:14:47.000000000 +0000
+++ sage-5.0.beta13/sage/misc/getusage.py 2012-04-11 00:47:03.000000000 +0000
@@ -20,6 +20,8 @@
"""
Return the 'top' or 'prstat' line that contains this running Sage
process.
+ For FreeBSD, return the line containing this running Sage process from
+ 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm'.
OUTPUT:
@@ -53,6 +55,8 @@
cmd = 'top -l 1 |grep "^ *%s "' % pid
elif U == 'sunos':
cmd = '/usr/bin/prstat -n 100000 1 1 | grep "^ *%s "' % pid
+ elif U == 'freebsd':
+ cmd = 'ps -axwww -o pid,user,vsz,rss,state,pri,nice,time,cpu,comm | grep "^ *%s "' % pid
else:
raise NotImplementedError("top not implemented on platform %s" % U)
@@ -83,6 +87,9 @@
usage, ``prstat`` will output the data in KB, MB or GB. In each
case, the value returned by this function will always be in MB.
+ - ``FreeBSD`` - Returns float number (in megabytes) that matches
+ RSS column of ``ps -auxwww``
+
- ``other`` - not implemented for any other operating systems
EXAMPLES::
@@ -129,6 +136,9 @@
m = float(memory_in_KB_MB_or_GB.strip("M"))
elif memory_in_KB_MB_or_GB.endswith("G"):
m = float(memory_in_KB_MB_or_GB.strip("G")) * 1024
+ elif U == 'freebsd':
+ memory_in_KB = top().split()[3]
+ m = float(memory_in_KB) / 1024
else:
raise NotImplementedError("memory usage not implemented on platform %s" % U)
Apply trac_12828.patch.
Attachments
Change History
comment:2 Changed 4 months ago by kcrisman
This comment is mostly a reminder to myself to turn this into a patch file. Nice find, though, and hopefully it will help us with #9170 as well.
comment:4 Changed 2 months ago by kcrisman
- Status changed from new to needs_review
- Description modified (diff)
comment:5 follow-up: ↓ 6 Changed 2 months ago by kcrisman
- Cc jpflori added
- Reviewers set to Karl-Dieter Crisman
- Status changed from needs_review to needs_work
I don't there is anyone else currently doing much with FreeBSD that is active enough to review this (JP?), so let's say we trust Stephen :)
Unfortunately, it will need rebase on 5.8.beta4 and #9170, but that should be pretty easy.
comment:6 in reply to: ↑ 5 Changed 2 months ago by kcrisman
- Status changed from needs_work to positive_review
Unfortunately, it will need rebase on 5.8.beta4 and #9170, but that should be pretty easy.
I don't know why I said that.
comment:7 Changed 2 months ago by kcrisman
Also, to release manager... this shouldn't affect any other platform, and we have no such buildbot yet, so it could still make it into 5.8 if you are amenable to this.
comment:8 Changed 2 months ago by stephen
Actually I am in no hurry. I have hit a road block in sage-5.8.beta4 in that document building is not working correctly. It is probably something wrong with semaphores. It may take me a while to figure it out.
comment:10 Changed 2 months ago by jdemeyer
- Status changed from positive_review to closed
- Resolution set to fixed
- Merged in set to sage-5.9.beta0


This just needs to be a patch for us to review it. Thanks for all the work on this.