Changeset: 0070777a2d70 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0070777a2d70
Modified Files:
configure.ag
gdk/ChangeLog.Apr2012
gdk/gdk_posix.c
sql/backends/monet5/sql_scenario.c
Branch: Apr2012
Log Message:
merging
diffs (122 lines):
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2323,6 +2323,8 @@ AC_CHECK_HEADERS([crypt.h \
limits.h \
locale.h \
mach-o/dyld.h \
+ mach/mach_init.h \
+ mach/task.h \
malloc.h \
netdb.h \
netinet/in.h \
@@ -2605,6 +2607,8 @@ AC_CHECK_FUNCS([\
strtoll \
strtoull \
sysconf \
+ task_for_pid \
+ task_info \
times \
trunc \
uname \
diff --git a/gdk/ChangeLog.Apr2012 b/gdk/ChangeLog.Apr2012
--- a/gdk/ChangeLog.Apr2012
+++ b/gdk/ChangeLog.Apr2012
@@ -1,3 +1,7 @@
# ChangeLog file for MonetDB
# This file is updated with Maddlog
+* Fri Apr 27 2012 Fabian Groffen <[email protected]>
+- Implemented MT_getrss for Mac OS X systems, this allows the server to
+ know about how much memory is currently in use.
+
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -47,6 +47,12 @@ extern char *sbrk(int);
#ifdef HAVE_PROCFS_H
# include <procfs.h>
#endif
+#ifdef HAVE_MACH_TASK_H
+# include <mach/task.h>
+#endif
+#ifdef HAVE_MACH_MACH_INIT_H
+# include <mach/mach_init.h>
+#endif
#if defined(DEBUG_ALLOC) && SIZEOF_VOID_P > 4
#undef DEBUG_ALLOC
@@ -732,6 +738,7 @@ MT_init_posix(void)
MT_mmap_init();
}
+/* return RSS in bytes */
size_t
MT_getrss(void)
{
@@ -758,8 +765,17 @@ MT_getrss(void)
}
close(fd);
}
+#elif defined(HAVE_TASK_INFO) && defined(HAVE_TASK_FOR_PID)
+ /* Darwin/MACH call for process' RSS */
+ task_t task = MACH_PORT_NULL;
+ struct task_basic_info t_info;
+ mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
+
+ if (task_for_pid(current_task(), getpid(), &task) == KERN_SUCCESS &&
+ task_info(task, TASK_BASIC_INFO, (task_info_t)&t_info,
&t_info_count) != KERN_INVALID_POLICY)
+ return t_info.resident_size * 1024;
#else
- /* get RSS -- linux only for the moment */
+ /* get RSS on Linux */
static char MT_mmap_procfile[128] = { 0 };
int fd;
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -427,6 +427,22 @@ sql_update_apr2012(Client c)
pos += snprintf(buf+pos, bufsize-pos, "create aggregate corr(e1 REAL,
e2 REAL) returns REAL external name \"aggr\".\"corr\";\n");
pos += snprintf(buf+pos, bufsize-pos, "create aggregate corr(e1 DOUBLE,
e2 DOUBLE) returns DOUBLE external name \"aggr\".\"corr\";\n");
+ pos += snprintf(buf + pos, bufsize-pos, "insert into
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where
f.name in ('median', 'corr') and f.type = %d and f.schema_id = s.id and s.name
= 'sys');\n", F_AGGR);
+
+ assert(pos < 2048);
+
+ printf("Running database upgrade commands:\n%s\n", buf);
+ err = SQLstatementIntern(c, &buf, "update", 1, 0);
+ GDKfree(buf);
+ return err; /* usually MAL_SUCCEED */
+}
+
+static str
+sql_update_apr2012_sp1(Client c)
+{
+ char *buf = GDKmalloc(2048), *err = NULL;
+ size_t bufsize = 2048, pos = 0;
+
/* changes in createdb/25_debug.sql */
pos += snprintf(buf+pos, bufsize-pos, "drop function storage;\n");
pos += snprintf(buf+pos, bufsize-pos, "create function storage()
returns table (\"schema\" string, \"table\" string, \"column\" string, location
string, \"count\" bigint, capacity bigint, width int, size bigint, hashsize
bigint, sorted boolean) external name sql.storage;\n");
@@ -434,7 +450,6 @@ sql_update_apr2012(Client c)
pos += snprintf(buf+pos, bufsize-pos, "drop procedure ra;\n");
pos += snprintf(buf+pos, bufsize-pos, "create procedure evalAlgebra(
ra_stmt string, opt bool) external name sql.\"evalAlgebra\";\n");
- pos += snprintf(buf + pos, bufsize-pos, "insert into
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where
f.name in ('median', 'corr') and f.type = %d and f.schema_id = s.id and s.name
= 'sys');\n", F_AGGR);
pos += snprintf(buf + pos, bufsize-pos, "insert into
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where
f.name in ('storage', 'optimizers') and f.type = %d and f.schema_id = s.id and
s.name = 'sys');\n", F_FUNC);
pos += snprintf(buf + pos, bufsize-pos, "insert into
sys.systemfunctions (select f.id from sys.functions f, sys.schemas s where
f.name in ('evalalgebra') and f.type = %d and f.schema_id = s.id and s.name =
'sys');\n", F_PROC);
@@ -577,6 +592,12 @@ SQLinitClient(Client c)
if ((err = sql_update_apr2012(c)) != NULL)
fprintf(stderr, "!%s\n", err);
}
+ /* if function sys.optimizers() does not exist, we
+ * need to update */
+ if (!sql_bind_func(m->sa, mvc_bind_schema(m,"sys"),
"optimizers", NULL, NULL, F_FUNC )) {
+ if ((err = sql_update_apr2012_sp1(c)) != NULL)
+ fprintf(stderr, "!%s\n", err);
+ }
}
fflush(stdout);
fflush(stderr);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list