[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24218 - in gnunet: . src/include src/nse src/statistics sr
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24218 - in gnunet: . src/include src/nse src/statistics src/topology src/util |
Date: |
Sun, 7 Oct 2012 21:02:58 +0200 |
Author: grothoff
Date: 2012-10-07 21:02:58 +0200 (Sun, 07 Oct 2012)
New Revision: 24218
Modified:
gnunet/configure.ac
gnunet/src/include/platform.h
gnunet/src/nse/gnunet-service-nse.c
gnunet/src/statistics/gnunet-service-statistics.c
gnunet/src/statistics/statistics_api.c
gnunet/src/topology/gnunet-daemon-topology.c
gnunet/src/util/gnunet-service-resolver.c
Log:
-add logic to measure heap size for all processes that use statistics, reduce
statistics, topology, nse and resolver heap usage using the same trick we used
for arm
Modified: gnunet/configure.ac
===================================================================
--- gnunet/configure.ac 2012-10-07 18:31:52 UTC (rev 24217)
+++ gnunet/configure.ac 2012-10-07 19:02:58 UTC (rev 24218)
@@ -733,7 +733,7 @@
AC_HEADER_SYS_WAIT
AC_TYPE_OFF_T
AC_TYPE_UID_T
-AC_CHECK_FUNCS([atoll stat64 strnlen mremap setrlimit sysconf initgroups
strndup gethostbyname2 getpeerucred getpeereid setresuid $funcstocheck
getifaddrs freeifaddrs getresgid mallinfo malloc_size malloc_usable_size])
+AC_CHECK_FUNCS([atoll stat64 strnlen mremap setrlimit sysconf initgroups
strndup gethostbyname2 getpeerucred getpeereid setresuid $funcstocheck
getifaddrs freeifaddrs getresgid mallinfo malloc_size malloc_usable_size
getrusage])
# restore LIBS
LIBS=$SAVE_LIBS
Modified: gnunet/src/include/platform.h
===================================================================
--- gnunet/src/include/platform.h 2012-10-07 18:31:52 UTC (rev 24217)
+++ gnunet/src/include/platform.h 2012-10-07 19:02:58 UTC (rev 24218)
@@ -111,6 +111,9 @@
#ifdef WINDOWS
#include <malloc.h> /* for alloca(), on other OSes it's in
stdlib.h */
#endif
+#ifdef HAVE_MALLOC_H
+#include <malloc.h> /* for mallinfo on GNU */
+#endif
#ifndef _MSC_VER
#include <unistd.h> /* KLB_FIX */
#endif
Modified: gnunet/src/nse/gnunet-service-nse.c
===================================================================
--- gnunet/src/nse/gnunet-service-nse.c 2012-10-07 18:31:52 UTC (rev 24217)
+++ gnunet/src/nse/gnunet-service-nse.c 2012-10-07 19:02:58 UTC (rev 24218)
@@ -1519,4 +1519,21 @@
&run, NULL)) ? 0 : 1;
}
+
+#ifdef LINUX
+#include <malloc.h>
+
+/**
+ * MINIMIZE heap size (way below 128k) since this process doesn't need much.
+ */
+void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+{
+ mallopt (M_TRIM_THRESHOLD, 4 * 1024);
+ mallopt (M_TOP_PAD, 1 * 1024);
+ malloc_trim (0);
+}
+#endif
+
+
+
/* end of gnunet-service-nse.c */
Modified: gnunet/src/statistics/gnunet-service-statistics.c
===================================================================
--- gnunet/src/statistics/gnunet-service-statistics.c 2012-10-07 18:31:52 UTC
(rev 24217)
+++ gnunet/src/statistics/gnunet-service-statistics.c 2012-10-07 19:02:58 UTC
(rev 24218)
@@ -849,4 +849,19 @@
GNUNET_SERVICE_OPTION_SOFT_SHUTDOWN, &run,
NULL)) ? 0 : 1;
}
+#ifdef LINUX
+#include <malloc.h>
+
+/**
+ * MINIMIZE heap size (way below 128k) since this process doesn't need much.
+ */
+void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+{
+ mallopt (M_TRIM_THRESHOLD, 4 * 1024);
+ mallopt (M_TOP_PAD, 1 * 1024);
+ malloc_trim (0);
+}
+#endif
+
+
/* end of gnunet-service-statistics.c */
Modified: gnunet/src/statistics/statistics_api.c
===================================================================
--- gnunet/src/statistics/statistics_api.c 2012-10-07 18:31:52 UTC (rev
24217)
+++ gnunet/src/statistics/statistics_api.c 2012-10-07 19:02:58 UTC (rev
24218)
@@ -236,6 +236,16 @@
struct GNUNET_TIME_Relative backoff;
/**
+ * Maximum heap size observed so far (if available).
+ */
+ uint64_t peak_heap_size;
+
+ /**
+ * Maximum resident set side observed so far (if available).
+ */
+ uint64_t peak_rss;
+
+ /**
* Size of the 'watches' array.
*/
unsigned int watches_size;
@@ -255,6 +265,49 @@
/**
+ * Obtain statistics about this process's memory consumption and
+ * report those as well (if they changed).
+ */
+static void
+update_memory_statistics (struct GNUNET_STATISTICS_Handle *h)
+{
+ uint64_t current_heap_size = 0;
+ uint64_t current_rss = 0;
+
+ if (GNUNET_NO != h->do_destroy)
+ return;
+#if HAVE_MALLINFO
+ {
+ struct mallinfo mi;
+
+ mi = mallinfo();
+ current_heap_size = mi.uordblks + mi.fordblks;
+ }
+#endif
+#if HAVE_GETRUSAGE
+ {
+ struct rusage ru;
+
+ if (0 == getrusage (RUSAGE_SELF, &ru))
+ {
+ current_rss = 1024LL * ru.ru_maxrss;
+ }
+ }
+#endif
+ if (current_heap_size > h->peak_heap_size)
+ {
+ h->peak_heap_size = current_heap_size;
+ GNUNET_STATISTICS_set (h, "# peak heap size", current_heap_size,
GNUNET_NO);
+ }
+ if (current_rss > h->peak_rss)
+ {
+ h->peak_rss = current_rss;
+ GNUNET_STATISTICS_set (h, "# peak resident set size", current_rss,
GNUNET_NO);
+ }
+}
+
+
+/**
* Schedule the next action to be performed.
*
* @param h statistics handle to reconnect
@@ -820,6 +873,7 @@
GNUNET_assert (NULL == handle->current->cont);
free_action_item (handle->current);
handle->current = NULL;
+ update_memory_statistics (handle);
return nsize;
}
Modified: gnunet/src/topology/gnunet-daemon-topology.c
===================================================================
--- gnunet/src/topology/gnunet-daemon-topology.c 2012-10-07 18:31:52 UTC
(rev 24217)
+++ gnunet/src/topology/gnunet-daemon-topology.c 2012-10-07 19:02:58 UTC
(rev 24218)
@@ -1367,4 +1367,19 @@
return ret;
}
+
+#ifdef LINUX
+#include <malloc.h>
+
+/**
+ * MINIMIZE heap size (way below 128k) since this process doesn't need much.
+ */
+void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+{
+ mallopt (M_TRIM_THRESHOLD, 4 * 1024);
+ mallopt (M_TOP_PAD, 1 * 1024);
+ malloc_trim (0);
+}
+#endif
+
/* end of gnunet-daemon-topology.c */
Modified: gnunet/src/util/gnunet-service-resolver.c
===================================================================
--- gnunet/src/util/gnunet-service-resolver.c 2012-10-07 18:31:52 UTC (rev
24217)
+++ gnunet/src/util/gnunet-service-resolver.c 2012-10-07 19:02:58 UTC (rev
24218)
@@ -577,4 +577,19 @@
return ret;
}
+#ifdef LINUX
+#include <malloc.h>
+
+/**
+ * MINIMIZE heap size (way below 128k) since this process doesn't need much.
+ */
+void __attribute__ ((constructor)) GNUNET_ARM_memory_init ()
+{
+ mallopt (M_TRIM_THRESHOLD, 4 * 1024);
+ mallopt (M_TOP_PAD, 1 * 1024);
+ malloc_trim (0);
+}
+#endif
+
+
/* end of gnunet-service-resolver.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24218 - in gnunet: . src/include src/nse src/statistics src/topology src/util,
gnunet <=