Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_memory_usage and top under FreeBSD #12828

Closed
sagetrac-stephen mannequin opened this issue Apr 11, 2012 · 12 comments
Closed

get_memory_usage and top under FreeBSD #12828

sagetrac-stephen mannequin opened this issue Apr 11, 2012 · 12 comments

Comments

@sagetrac-stephen
Copy link
Mannequin

sagetrac-stephen mannequin commented Apr 11, 2012

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 attachment: trac_12828.patch.

CC: @jpflori

Component: porting: BSD

Author: Stephen Montgomery-Smith

Reviewer: Karl-Dieter Crisman

Merged: sage-5.9.beta0

Issue created by migration from https://trac.sagemath.org/ticket/12828

@sagetrac-stephen sagetrac-stephen mannequin added this to the sage-5.8 milestone Apr 11, 2012
@kcrisman
Copy link
Member

comment:1

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

@kcrisman
Copy link
Member

Author: Stephen Montgomery-Smith

@kcrisman
Copy link
Member

comment:2

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.

@kcrisman
Copy link
Member

comment:3

I guess it was a patch all along.

@kcrisman
Copy link
Member

comment:4

Attachment: trac_12828.patch.gz

@kcrisman

This comment has been minimized.

@kcrisman
Copy link
Member

Reviewer: Karl-Dieter Crisman

@kcrisman
Copy link
Member

comment:5

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.

@kcrisman
Copy link
Member

comment:6

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.

@kcrisman
Copy link
Member

comment:7

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.

@sagetrac-stephen
Copy link
Mannequin Author

sagetrac-stephen mannequin commented Mar 13, 2013

comment:8

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.

@jdemeyer jdemeyer modified the milestones: sage-5.8, sage-5.9 Mar 13, 2013
@jdemeyer
Copy link
Contributor

Merged: sage-5.9.beta0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants