John Cremona wrote:
>> I stand correct - Micheal does say where 'top' is called - it is in
>> sage/rings/tests.py
>>
>> It's important to understand that on a stardard Solaris distribution,
>> top is not included. Sun have 'prstat' which does similar things, but
>> I'd never think of calling that to get information in the way it appears
>> it might be used in Sage.
>>
>
> Using search_src("top") I found that there is a top() function in
> sage/misc/get_usage.py. It makes an attempts to do the right thing on
> different architectures. Perhaps there would be a version which would
> work on Solaris?
>
> John
Yes, I finally found it myself. I like this bit of code:
elif U == 'sunos':
# An evil and ugly workaround some Solaris race condition.
while True:
try:
m = float(top().split()[-5].strip('M'))
break
except:
pass
else:
It is probably that 'evil and ugly' code which is screwing up on my
system, as it is probably repeatedly trying to get something from 'top'.
It would appear to me the code is attempting to read the 5th column of
'top' which is marked 'SIZE'. I'm not sure if that is a very useful
thing to get, as the number returned includes that memory that is shared
with other processes. I would have thought the 6th column, which is the
memory used by that process alone (i.e. resident size) was more useful.
Sometimes these differ by an order of magnitude or more. Anyway, my main
concern is to fix the code so:
* It does not rely on someone having installed 'top'
* It is fast. Micheal's comment it is is taking 1 second/call, and when
its called thousands of times, it causes the doctests to time out. This
could explain some timeouts I see on Solaris.
The following bit of C code finds the memory used by process 1877 (I
have hard-coded that for now, but I'll change it later). It reports data
in bytes. It's based on code at
http://getthegood.com/TechNotes/Papers/ProcStatistics.html
but has been modified so it actually compiles!
#include <sys/procfs.h>
#include <sys/fcntl.h>
#include <stdio.h>
#include <stdlib.h>
int
main(int argc, char*argv[])
{
int fd;
prpsinfo_t psbuff;
char procbuf[50];
(void)sprintf(procbuf, "/proc/%d", 1877);
if ((fd = open(procbuf, O_RDONLY)) == -1)
perror("open of /proc"), exit(-1);
if (ioctl(fd, PIOCPSINFO, &psbuff) == -1)
perror("ioctl(PIOCPSINFO)"), close(fd), exit(-1);
(void)printf("Process size = %lu, resident size = %lu\n",
(void)printf("Process size = %lu, resident size = %lu\n",
psbuff.pr_bysize, psbuff.pr_byrssize);
}
drkir...@smudge:[~] $ gcc mem.c
drkir...@smudge:[~] $ ./a.out
Process size = 277037056, resident size = 190406656
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---