[or-cvs] r10947: When dumping memory usage, list bytes used in buffer memory (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Jul 27 18:33:38 UTC 2007


Author: nickm
Date: 2007-07-27 14:33:37 -0400 (Fri, 27 Jul 2007)
New Revision: 10947

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/buffers.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
Log:
 r13939 at catbus:  nickm | 2007-07-27 14:33:22 -0400
 When dumping memory usage, list bytes used in buffer memory free-lists.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13939] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2007-07-27 18:33:34 UTC (rev 10946)
+++ tor/trunk/ChangeLog	2007-07-27 18:33:37 UTC (rev 10947)
@@ -12,6 +12,7 @@
       write-protects the authority identity key.
     - New ConstrainedSockets option to set SO_SNDBUF and SO_RCVBUF on TCP
       sockets.  (Patch from coderman.)
+    - When dumping memory usage, list bytes used in buffer memory free-lists.
 
   o Minor features (directory authority):
     - Fail quickly and (relatively) harmlessly if we generate a network

Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c	2007-07-27 18:33:34 UTC (rev 10946)
+++ tor/trunk/src/or/buffers.c	2007-07-27 18:33:37 UTC (rev 10947)
@@ -196,6 +196,25 @@
   }
 }
 
+/** Write the sizes of the buffer freelists at log level <b>severity</b> */
+void
+buf_dump_freelist_sizes(int severity)
+{
+  size_t sz;
+  log(severity, LD_MM, "======= Buffer freelists.");
+  for (sz = 4096; sz <= 16384; sz *= 2) {
+    uint64_t total_size;
+    free_mem_list_t *lst;
+    if (!IS_FREELIST_SIZE(sz))
+      continue;
+    lst = get_free_mem_list(sz);
+    total_size = ((uint64_t)sz)*lst->len;
+    log(severity, LD_MM,
+        U64_FORMAT" bytes in %d %d-byte buffers. (low-water: %d)",
+        U64_PRINTF_ARG(total_size), lst->len, (int)sz, lst->lowwater);
+  }
+}
+
 /** Throw the memory from <b>buf</b> onto the appropriate freelist.
  * Return true if we added the memory, 0 if the freelist was full. */
 static int

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2007-07-27 18:33:34 UTC (rev 10946)
+++ tor/trunk/src/or/main.c	2007-07-27 18:33:37 UTC (rev 10947)
@@ -1542,6 +1542,7 @@
       U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
   dump_routerlist_mem_usage(severity);
   dump_cell_pool_usage(severity);
+  buf_dump_freelist_sizes(severity);
 }
 
 /** Write all statistics to the log, with log level 'severity'.  Called

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-07-27 18:33:34 UTC (rev 10946)
+++ tor/trunk/src/or/or.h	2007-07-27 18:33:37 UTC (rev 10947)
@@ -2170,6 +2170,7 @@
 void buf_clear(buf_t *buf);
 void buf_shrink(buf_t *buf);
 void buf_shrink_freelists(int free_all);
+void buf_dump_freelist_sizes(int severity);
 
 size_t buf_datalen(const buf_t *buf);
 size_t buf_capacity(const buf_t *buf);



More information about the tor-commits mailing list