[or-cvs] dump periodic memory usage stats

arma at seul.org arma at seul.org
Wed Jun 8 17:25:00 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	main.c 
Log Message:
dump periodic memory usage stats


Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.511
retrieving revision 1.512
diff -u -d -r1.511 -r1.512
--- main.c	8 Jun 2005 04:55:06 -0000	1.511
+++ main.c	8 Jun 2005 17:24:58 -0000	1.512
@@ -34,6 +34,7 @@
 
 /********* PROTOTYPES **********/
 
+static void dumpmemusage(int severity);
 static void dumpstats(int severity); /* log stats */
 static void conn_read_callback(int fd, short event, void *_conn);
 static void conn_write_callback(int fd, short event, void *_conn);
@@ -831,6 +832,9 @@
 
   current_second = now.tv_sec; /* remember which second it is, for next time */
 
+  if (current_second % 60 == 0)
+    dumpmemusage(get_min_log_level()<LOG_INFO ? get_min_log_level() : LOG_INFO);
+
   if (evtimer_add(timeout_event, &one_second))
     log_fn(LOG_ERR,
            "Error from libevent when setting one-second timeout event");
@@ -1046,6 +1050,19 @@
   }
 }
 
+static void
+dumpmemusage(int severity) {
+  extern uint64_t buf_total_used;
+  extern uint64_t buf_total_alloc;
+  extern uint64_t rephist_total_alloc;
+
+  log(severity, "In buffers: "U64_FORMAT" used/"U64_FORMAT" allocated (%d conns).",
+      U64_PRINTF_ARG(buf_total_used), U64_PRINTF_ARG(buf_total_alloc),
+      nfds);
+  log(severity, "In rephist: "U64_FORMAT" used.",
+      U64_PRINTF_ARG(rephist_total_alloc));
+}
+
 /** Write all statistics to the log, with log level 'severity'.  Called
  * in response to a SIGUSR1. */
 static void
@@ -1054,9 +1071,6 @@
   connection_t *conn;
   time_t now = time(NULL);
   time_t elapsed;
-  extern uint64_t buf_total_used;
-  extern uint64_t buf_total_alloc;
-  extern uint64_t rephist_total_alloc;
 
   log(severity, "Dumping stats:");
 
@@ -1121,10 +1135,7 @@
   }
 
   log(severity, "--------------- Dumping memory information:");
-  log(severity, "In buffers: "U64_FORMAT" used/"U64_FORMAT" allocated.",
-      U64_PRINTF_ARG(buf_total_used), U64_PRINTF_ARG(buf_total_alloc));
-  log(severity, "In rephist: "U64_FORMAT" used.",
-      U64_PRINTF_ARG(rephist_total_alloc));
+  dumpmemusage(severity);
 
   rep_hist_dump_stats(now,severity);
   rend_service_dump_stats(severity);



More information about the tor-commits mailing list