Opened 10 years ago

Closed 9 years ago

#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 Merged in: sage-5.9.beta0
Authors: Stephen Montgomery-Smith Reviewers: Karl-Dieter Crisman
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by kcrisman)

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 (1)

trac_12828.patch (1.7 KB) - added by kcrisman 9 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 Changed 10 years ago by kcrisman

  • Authors set to Stephen Montgomery-Smith

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

comment:2 Changed 10 years 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:3 Changed 9 years ago by kcrisman

I guess it was a patch all along.

Changed 9 years ago by kcrisman

comment:4 Changed 9 years ago by kcrisman

  • Description modified (diff)
  • Status changed from new to needs_review

comment:5 follow-up: Changed 9 years 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 9 years 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 9 years 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 9 years 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:9 Changed 9 years ago by jdemeyer

  • Milestone changed from sage-5.8 to sage-5.9

comment:10 Changed 9 years ago by jdemeyer

  • Merged in set to sage-5.9.beta0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.