Changeset: a20ad202ae28 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a20ad202ae28
Added Files:
        monetdb5/modules/kernel/metrics.c
        monetdb5/modules/kernel/metrics.h
Modified Files:
        monetdb5/modules/kernel/Makefile.ag
Branch: configurable_working_set
Log Message:

First draft of a MAL interface to various system metrics.


diffs (92 lines):

diff --git a/monetdb5/modules/kernel/Makefile.ag 
b/monetdb5/modules/kernel/Makefile.ag
--- a/monetdb5/modules/kernel/Makefile.ag
+++ b/monetdb5/modules/kernel/Makefile.ag
@@ -26,7 +26,8 @@ lib_kernel = {
                logger.c \
                microbenchmark.c microbenchmark.h \
                mmath.c mmath.h \
-               status.c status.h 
+               status.c status.h \
+               metrics.c metrics.h
 }
 
 headers_mal = {
diff --git a/monetdb5/modules/kernel/metrics.c 
b/monetdb5/modules/kernel/metrics.c
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/metrics.c
@@ -0,0 +1,47 @@
+
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2018 MonetDB B.V.
+ */
+
+#include "metrics.h"
+#include "gdk.h"
+#include "mal.h"
+#include "mal_client.h"
+#include "mal_instruction.h"
+#include "mal_interpreter.h"
+
+#include "gdk_posix.h"
+
+mal_export str METRICSrsssize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
+{
+    (void) cntxt;
+    (void) mb;
+    lng *res = getArgReference_lng(stk, pci, 0);
+    *res = (lng)MT_getrss();
+
+    return MAL_SUCCEED;
+}
+
+mal_export str METRICSgetvmsize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
+{
+    (void) cntxt;
+    (void) mb;
+    lng *res = getArgReference_lng(stk, pci, 0);
+
+#ifdef WIN32
+       MEMORYSTATUSEX psvmemCounters;
+       psvmemCounters.dwLength = sizeof(MEMORYSTATUSEX); 
+       
+       GlobalMemoryStatusEx(&psvmemCounters);
+
+       *res = psvmemCounters.ullTotalVirtual - psvmemCounters.ullAvailVirtual;
+#else
+    *res = 0;
+#endif
+
+    return MAL_SUCCEED;
+}
diff --git a/monetdb5/modules/kernel/metrics.h 
b/monetdb5/modules/kernel/metrics.h
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/kernel/metrics.h
@@ -0,0 +1,22 @@
+/*
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0.  If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * Copyright 1997 - July 2008 CWI, August 2008 - 2018 MonetDB B.V.
+ */
+
+#ifndef METRICS_H
+#define METRICS_H
+
+#include "monetdb_config.h"
+
+#include "mal.h"
+#include "mal_client.h"
+#include "mal_instruction.h"
+
+mal_export str METRICSrsssize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+
+mal_export str METRICSgetvmsize(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+
+#endif
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to