[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r12996: Exciting new entries in buf_dump_freelist_sizes() to make su (in tor/trunk: . src/or)
Author: nickm
Date: 2007-12-27 09:20:30 -0500 (Thu, 27 Dec 2007)
New Revision: 12996
Modified:
tor/trunk/
tor/trunk/src/or/buffers.c
Log:
r17410@catbus: nickm | 2007-12-27 09:20:27 -0500
Exciting new entries in buf_dump_freelist_sizes() to make sure our freelist sizes are reasonable.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r17410] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/src/or/buffers.c
===================================================================
--- tor/trunk/src/or/buffers.c 2007-12-27 05:18:36 UTC (rev 12995)
+++ tor/trunk/src/or/buffers.c 2007-12-27 14:20:30 UTC (rev 12996)
@@ -105,11 +105,14 @@
int cur_length; /**< How many chunks on the freelist now? */
int lowest_length; /**< What's the smallest value of cur_length since the
* last time we cleaned this freelist? */
+ uint64_t n_alloc;
+ uint64_t n_free;
+ uint64_t n_hit;
chunk_t *head; /**< First chunk on the freelist. */
} chunk_freelist_t;
/** Macro to help define freelists. */
-#define FL(a,m,s) { a, m, s, 0, 0, NULL }
+#define FL(a,m,s) { a, m, s, 0, 0, 0, 0, 0, NULL }
/** Static array of freelists, sorted by alloc_len, terminated by an entry
* with alloc_size of 0. */
@@ -119,6 +122,7 @@
FL(8192, 128, 4), FL(16384, 64, 4), FL(0, 0, 0)
};
#undef FL
+static uint64_t n_freelist_miss = 0;
static void assert_freelist_ok(chunk_freelist_t *fl);
@@ -147,6 +151,8 @@
freelist->head = chunk;
++freelist->cur_length;
} else {
+ if (freelist)
+ ++freelist->n_free;
tor_free(chunk);
}
}
@@ -166,8 +172,13 @@
freelist->head = ch->next;
if (--freelist->cur_length < freelist->lowest_length)
freelist->lowest_length = freelist->cur_length;
+ ++freelist->n_hit;
} else {
/* XXXX020 take advantage of tor_malloc_roundup. */
+ if (freelist)
+ ++freelist->n_alloc;
+ else
+ ++n_freelist_miss;
ch = tor_malloc(alloc);
}
ch->next = NULL;
@@ -247,6 +258,7 @@
tor_free(chunk);
chunk = next;
--n_to_free;
+ ++freelists[i].n_free;
}
tor_assert(!n_to_free);
freelists[i].cur_length = new_length;
@@ -267,9 +279,16 @@
uint64_t total = ((uint64_t)freelists[i].cur_length) *
freelists[i].alloc_size;
log(severity, LD_MM,
- U64_FORMAT" bytes in %d %d-byte chunks", U64_PRINTF_ARG(total),
- freelists[i].cur_length, (int)freelists[i].alloc_size);
+ U64_FORMAT" bytes in %d %d-byte chunks ["U64_FORMAT
+ " misses; "U64_FORMAT" frees; "U64_FORMAT" hits]",
+ U64_PRINTF_ARG(total),
+ freelists[i].cur_length, (int)freelists[i].alloc_size,
+ U64_PRINTF_ARG(freelists[i].n_alloc),
+ U64_PRINTF_ARG(freelists[i].n_free),
+ U64_PRINTF_ARG(freelists[i].n_hit));
}
+ log(severity, LD_MM, U64_FORMAT" allocations in non-freelist sizes",
+ U64_PRINTF_ARG(n_freelist_miss));
}
/** Magic value for buf_t.magic, to catch pointer errors. */