summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-07-27 18:33:37 +0000
committerNick Mathewson <nickm@torproject.org>2007-07-27 18:33:37 +0000
commitbc9a7be9432c779a4e47c8a58a33b5cfbc23e58e (patch)
treec2d1c59dabb1325804725e1f8e3931c7b94082d8
parent65cdda20b30c29b1b2d53c1025dcb5856dbc3288 (diff)
downloadtor-bc9a7be9432c779a4e47c8a58a33b5cfbc23e58e.tar.gz
tor-bc9a7be9432c779a4e47c8a58a33b5cfbc23e58e.zip
r13939@catbus: nickm | 2007-07-27 14:33:22 -0400
When dumping memory usage, list bytes used in buffer memory free-lists. svn:r10947
-rw-r--r--ChangeLog1
-rw-r--r--src/or/buffers.c19
-rw-r--r--src/or/main.c1
-rw-r--r--src/or/or.h1
4 files changed, 22 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 71243bcf53..de4b86fafe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@ Changes in version 0.2.0.3-alpha - 2007-??-??
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
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 99271de7f9..1087a7a6fa 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -196,6 +196,25 @@ get_free_mem_list(size_t sz)
}
}
+/** 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
diff --git a/src/or/main.c b/src/or/main.c
index e252383074..8bedd71b86 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1542,6 +1542,7 @@ dumpmemusage(int severity)
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
diff --git a/src/or/or.h b/src/or/or.h
index b4dffb2c81..d2f103ec74 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -2170,6 +2170,7 @@ void buf_free(buf_t *buf);
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);