#8391: Temporary ugly fix: Change 'top' to 'prstat' on Solaris for 'getusage.py'
------------------------+---------------------------------------------------
   Reporter:  drkirkby  |       Owner:  drkirkby
       Type:  defect    |      Status:  new     
   Priority:  major     |   Milestone:          
  Component:  solaris   |    Keywords:          
     Author:            |    Upstream:  N/A     
   Reviewer:            |      Merged:          
Work_issues:            |  
------------------------+---------------------------------------------------

Comment(by drkirkby):

 Here is the output of an modified version of Sage 4.4.3, where top is not
 installed. The modifications were only to get Sage to build at this point.
 The hardware is a Sun Blade 1000 with 2 GB RAM.

 top() reports that 'top' is not found, and get_memory_usage() goes into an
 infinite loop. If you look at the source code, you can see why the
 infinite loop exists.

 {{{
 -bash-3.00$ ./sage
 ----------------------------------------------------------------------
 | Sage Version 4.3.3, Release Date: 2010-02-21                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: top()
 sh: top: not found
 ''
 sage: get_memory_usage()
 sh: top: not found
 sh: top: not found
 sh: top: not found
 sh: top: not found
 }}}

 Here is the output of the same two commands with the changes I will soon
 attach.

 {{{
 drkir...@redstart:~/fresh/sage-4.3.3$ ./sage
 ----------------------------------------------------------------------
 | Sage Version 4.3.3, Release Date: 2010-02-21                       |
 | Type notebook() for the GUI, and license() for information.        |
 ----------------------------------------------------------------------
 sage: top()
 '25519 drkirkby  164M   91M sleep   59    0   0:00:07 9.2% python/1'
 sage: get_memory_usage()
 91.0
 }}}

 The program 'top' is not installed - instead prstat is used to get the
 information. I also expanded the information someone gets when using
 help(top) or help(get_usage_message) - see below.

 {{{
 sage: help(top)
 Help on function top in module sage.misc.getusage:

 top()
     Return the 'top' or 'prstat' line that contains this running
     Sage process.

     EXAMPLES:
         sage: top()              # random output
         '72373 python       0.0%  0:01.36   1    14+  1197   39M+   34M+
 55M+  130M+'

     NOTES:
     The external command 'top' (http://www.unixtop.org/) is called on
 Linux,
     and most other operating systems. The output format of 'top' is not
     consistent across all platforms and all versions of 'top'. If the
     top() function does not work in Sage, you may need to install 'top'.

     The external command 'prstat' is called on the Solaris and OpenSolaris
     systems. That is part of Solaris, and will not need to be installed.
 The
     columns used in the 'prstat' output are:
     PID USERNAME  SIZE   RSS STATE  PRI NICE      TIME  CPU PROCESS/NLWP

 sage: help(get_memory_usage)
 Help on function get_memory_usage in module sage.misc.getusage:

 get_memory_usage(t=None)
     Return memory usage.

     INPUT:

     -  ``t`` - None or output of previous call; (only used
        on Linux)

     OUTPUT:

     - ``Linux`` - Returns float number (in megabytes)

     - ``OS X`` - Returns float number (in megabytes) that matches VSIZE
 column of 'top'

     - ``Solaris or OpenSolaris`` - Returns float number (in megabytes)
 that matches RSS
         column of 'prstat'. Depending on the memory 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.


     - ``other`` - not implemented for any other operating systems

     EXAMPLES:

     We test that memory usage doesn't change instantly::

         sage: t = get_memory_usage()
         sage: get_memory_usage(t)          # amount of memory more than
 when we defined t.
         0.0

     NOTES:

     Currently get_memory_usage() calls ''prstat' (Solaris and
     OpenSolaris) to get the data it requires. In the long term,
     a better solution would be to use Solaris system calls.

     In some instances, 'top' may be used on OS X. This may break
     if the memory usage is greater than 9999 MB. However, normally
     'top' is not used on OS X.

 sage:

 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8391#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to