Changeset: 191e5f0c892f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=191e5f0c892f
Modified Files:
MonetDB5/src/modules/kernel/status.mx
MonetDB5/src/modules/mal/Tests/inspect05.stable.out
Branch: default
Log Message:
Clean-up status module, fixes segfault from bug #2556 as side-effect.
diffs (truncated from 646 to 300 lines):
diff -r 0d837ee9c142 -r 191e5f0c892f MonetDB5/src/modules/kernel/status.mx
--- a/MonetDB5/src/modules/kernel/status.mx Mon Jun 14 12:53:09 2010 +0200
+++ b/MonetDB5/src/modules/kernel/status.mx Mon Jun 14 14:52:23 2010 +0200
@@ -31,7 +31,7 @@
@mal
module status;
-command cpuStatistics() :bat[:str,:int]
+command cpuStatistics():bat[:str,:int]
address SYScpuStatistics
comment "Global cpu usage information";
command memStatistics():bat[:str,:wrd]
@@ -40,53 +40,12 @@
command ioStatistics():bat[:str,:int]
address SYSioStatistics
comment "Global IO activity information";
-...@-
-#command memMap() :void
-#address SYSmemMap
-#comment "Print a map of all memory that is in use";
-...@-
-
-For each 64KB block in the first 3GB of the virtual memory
@emph{mem_printmap()}
-prints a character:
-...@multitable @columnfractions 0.05 0.7
-...@item 0-9
-...@tab - thread stack space of thread <num>
-...@item B
-...@tab - in use for a large BAT heap
- (i.e. anonymous virtual memory).
-...@item b
-...@tab - free (last usage was B)
-...@item S
-...@tab - in use for a malloc block
-...@item s
-...@tab - free (last usage was S)
-...@item P
-...@tab - in use for the BBP array
- (i.e. anonymous virtual memory)
-...@item p
-...@tab - free (last usage was P)
-...@item M
-...@tab - in use as memory mapped region
-...@item m
-...@tab - free (last usage was M)
-...@item C
-...@tab - in use as MIL context buffer
- (i.e. anonymous virtual memory)
-...@item c
-...@tab - free (last usage was M)
-...@end multitable
-
-On Linux, the malloc library appears to be using anonymous virtual memory,
-which goes undetected. If you want to see all your memory in the map,
-lower the gdk_mmap threshold in monetdb5.conf to a low value (say 64KB).
-...@-
-...@mal
-command vmStatistics(minsize:lng) :bat[:str,:lng]
+command vmStatistics(minsize:lng):bat[:str,:lng]
address SYSvm_usage
-comment "Get a split-up of how much virtual memory blocks are in use.";
-command memUsage(minsize:lng) :bat[:str,:lng]
+comment "Get a split-up of how much virtual memory blocks are in use";
+command memUsage(minsize:lng):bat[:str,:lng]
address SYSmem_usage
-comment "Get a split-up of how much memory blocks are in use.";
+comment "Get a split-up of how much memory blocks are in use";
@-
Some explanation of what mem_usage() and vm_usage() display:
@verbatim
@@ -126,44 +85,37 @@
@end verbatim
@+ MAL runtime status
@mal
-command batStatistics( ):bat[:str,:str]
+command batStatistics():bat[:str,:str]
address SYSgdkEnv
comment "Show distribution of bats by kind";
-command getThreads( ):bat[:int,:str]
+command getThreads():bat[:int,:str]
address SYSgdkThread
-comment "Produce overview of active threads.";
+comment "Produce overview of active threads";
-command mem_cursize() :lng
+command mem_cursize():lng
address SYSgetmem_cursize
-comment "The amount of physical swapspace in KB that is currently in use.";
+comment "The amount of physical swapspace in KB that is currently in use";
-command mem_maxsize() :lng
+command mem_maxsize():lng
address SYSgetmem_maxsize
-comment "The maximum usable amount of physical swapspace in KB (target only).";
+comment "The maximum usable amount of physical swapspace in KB (target only)";
-command mem_maxsize(v:lng) :void
-address set_mem_maxsize
-comment "Set the maximum usable amount of physical swapspace in KB.";
+command mem_maxsize(v:lng):void
+address SYSsetmem_maxsize
+comment "Set the maximum usable amount of physical swapspace in KB";
-command vm_cursize() :lng
+command vm_cursize():lng
address SYSgetvm_cursize
-comment "the amount of logical VM space in KB that is currently in use";
+comment "The amount of logical VM space in KB that is currently in use";
-command vm_maxsize() :lng
+command vm_maxsize():lng
address SYSgetvm_maxsize
-comment "the maximum usable amount of logical VM space in KB (target only)";
+comment "The maximum usable amount of logical VM space in KB (target only)";
-command vm_maxsize(v:lng) :void
+command vm_maxsize(v:lng):void
address SYSsetvm_maxsize
-comment "set the maximum usable amount of physical swapspace in KB";
+comment "Set the maximum usable amount of physical swapspace in KB";
-command getDatabases():bat[:str,:str]
-address SYSgetDatabases
-comment "Produce a list of known databases in the current dbfarm";
-
-command getPorts(lang:str):bat[:str,:int]
-address SYSgetPorts
-comment "Produce a list of default ports for a specific language";
@+ Implementation Code
@h
#ifndef _SYS_H_
@@ -179,9 +131,6 @@
#define status_export extern
#endif
-status_export str SYSgetDatabases(int *ret);
-status_export str SYSgetPorts(int *ret, str *lang);
-status_export int set_mem_maxsize(lng *num);
#endif
@-
@@ -195,19 +144,20 @@
#include "mal_exception.h"
#include "status.h"
#ifdef HAVE_UNISTD_H
-#include <unistd.h>
+# include <unistd.h>
#endif
#ifdef HAVE_SYS_TIMES_H
-#include <sys/times.h>
+# include <sys/times.h>
#endif
-#if defined(_MSC_VER) && _MSC_VER >= 1400
-#define access _access
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
#endif
-extern lng GDKcur_cursize(void);
+...@h
status_export str SYSgetmem_cursize(lng *num);
+...@c
str
SYSgetmem_cursize(lng *num)
{
@@ -215,7 +165,9 @@
return MAL_SUCCEED;
}
+...@h
status_export str SYSgetmem_maxsize(lng *num);
+...@c
str
SYSgetmem_maxsize(lng *num)
{
@@ -223,8 +175,32 @@
return MAL_SUCCEED;
}
+...@h
+status_export str SYSsetmem_maxsize(int *ret, lng *num);
+...@c
+str
+SYSsetmem_maxsize(int *ret, lng *num)
+{
+ size_t sze = 0;
+ *ret = 0;
+ if (*num < 0)
+ throw(ILLARG, "status.mem_maxsize", "new size must not be < 0");
+#if SIZEOF_SIZE_T == SIZEOF_INT
+ {
+ lng size_t_max = 2 * (lng)INT_MAX;
+ if (*num > size_t_max)
+ throw(ILLARG, "status.mem_maxsize", "new size must not
be > " LLFMT, size_t_max);
+ }
+#endif
+ if (sze < GDK_mem_bigsize)
+ GDK_mem_bigsize = MAX(32768, sze);
+ GDK_mem_maxsize = MAX(GDK_mem_bigsize, sze);
+ return MAL_SUCCEED;
+}
+...@h
status_export str SYSgetvm_cursize(lng *num);
+...@c
str
SYSgetvm_cursize(lng *num)
{
@@ -232,7 +208,9 @@
return MAL_SUCCEED;
}
+...@h
status_export str SYSgetvm_maxsize(lng *num);
+...@c
str
SYSgetvm_maxsize(lng *num)
{
@@ -240,7 +218,9 @@
return MAL_SUCCEED;
}
+...@h
status_export str SYSsetvm_maxsize(lng *num);
+...@c
str
SYSsetvm_maxsize(lng *num)
{
@@ -248,12 +228,6 @@
return MAL_SUCCEED;
}
-/*
-str memMap() {
- MT_alloc_print();
- return MAL_SUCCEED;
-}
-*/
@- Performance
To obtain a good impression of the Monet performance we need timing
information.
The most detailed information is best obtained with the system profiler.
@@ -272,7 +246,9 @@
static struct tms state;
#endif
+...@h
status_export str SYScpuStatistics(int *ret);
+...@c
str
SYScpuStatistics(int *ret)
{
@@ -280,22 +256,22 @@
BAT *b;
#ifdef HAVE_TIMES
struct tms newst;
-#ifndef HZ
+# ifndef HZ
static int HZ;
if (HZ == 0) {
-#if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
+# if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
HZ = sysconf(_SC_CLK_TCK);
-#else
+# else
HZ = CLK_TCK;
-#endif
+# endif
}
-#endif
+# endif
#endif
b = BATnew(TYPE_str, TYPE_int, 32);
if (b == 0)
- throw(MAL, "catalog.gdkCpu", MAL_MALLOC_FAIL);
+ throw(MAL, "status.cpuStatistics", MAL_MALLOC_FAIL);
#ifdef HAVE_TIMES
if (clk == 0) {
clk = time(0);
@@ -328,11 +304,10 @@
return MAL_SUCCEED;
}
-...@-
-Same observations as to SYScpuStatistics()
+...@h
+status_export str SYSmemStatistics(int *ret);
@c
static char *memincr = NULL;
-status_export str SYSmemStatistics(int *ret);
str
SYSmemStatistics(int *ret)
{
@@ -344,12 +319,12 @@
b = BATnew(TYPE_str, TYPE_wrd, 32);
if (b == 0)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list