[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Dump bytes held to store descriptors.
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv11230/src/or
Modified Files:
main.c or.h routerlist.c
Log Message:
Dump bytes held to store descriptors.
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.592
retrieving revision 1.593
diff -u -d -r1.592 -r1.593
--- main.c 19 Nov 2005 06:57:44 -0000 1.592
+++ main.c 23 Nov 2005 06:00:58 -0000 1.593
@@ -1221,6 +1221,7 @@
nfds);
log(severity, LD_GENERAL, "In rephist: "U64_FORMAT" used by %d Tors.",
U64_PRINTF_ARG(rephist_total_alloc), rephist_total_num);
+ dump_routerlist_mem_usage(severity);
}
/** Write all statistics to the log, with log level 'severity'. Called
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.739
retrieving revision 1.740
diff -u -d -r1.739 -r1.740
--- or.h 23 Nov 2005 05:47:51 -0000 1.739
+++ or.h 23 Nov 2005 06:00:58 -0000 1.740
@@ -883,8 +883,6 @@
/** List of signed_descriptor_t for older router descriptors we're
* caching. */
smartlist_t *old_routers;
- /** For debugging: tracks RAM usage in signed descriptors. */
- uint32_t signed_descriptor_bytes;
} routerlist_t;
/** Information on router used when extending a circuit. (We don't need a
@@ -2163,6 +2161,7 @@
routerlist_t *router_get_routerlist(void);
void routerlist_reset_warnings(void);
void routerlist_free(routerlist_t *routerlist);
+void dump_routerlist_mem_usage(int severity);
void routerlist_remove(routerlist_t *rl, routerinfo_t *ri, int idx,
int make_old);
void routerinfo_free(routerinfo_t *router);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.376
retrieving revision 1.377
diff -u -d -r1.376 -r1.377
--- routerlist.c 23 Nov 2005 05:47:51 -0000 1.376
+++ routerlist.c 23 Nov 2005 06:00:58 -0000 1.377
@@ -1127,6 +1127,25 @@
tor_free(rl);
}
+void
+dump_routerlist_mem_usage(int severity)
+{
+ uint64_t livedescs = 0;
+ uint64_t olddescs = 0;
+ if (!routerlist)
+ return;
+ SMARTLIST_FOREACH(routerlist->routers, routerinfo_t *, r,
+ livedescs += r->cache_info.signed_descriptor_len);
+ SMARTLIST_FOREACH(routerlist->old_routers, signed_descriptor_t *, sd,
+ livedescs += sd->signed_descriptor_len);
+
+ log(severity, LD_GENERAL,
+ "In %d live descriptors: "U64_FORMAT" bytes. "
+ "In %d old descriptors: "U64_FORMAT" bytes.",
+ smartlist_len(routerlist->routers), U64_PRINTF_ARG(livedescs),
+ smartlist_len(routerlist->old_routers), U64_PRINTF_ARG(olddescs));
+}
+
static INLINE int
_routerlist_find_elt(smartlist_t *sl, void *ri, int idx)
{
@@ -1150,7 +1169,6 @@
digestmap_set(rl->desc_digest_map, ri->cache_info.signed_descriptor_digest,
&(ri->cache_info));
smartlist_add(rl->routers, ri);
- rl->signed_descriptor_bytes += ri->cache_info.signed_descriptor_len;
// routerlist_assert_ok(rl);
}
@@ -1161,7 +1179,6 @@
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri);
digestmap_set(rl->desc_digest_map, sd->signed_descriptor_digest, sd);
smartlist_add(rl->old_routers, sd);
- rl->signed_descriptor_bytes += sd->signed_descriptor_len;
} else {
routerinfo_free(ri);
}
@@ -1190,7 +1207,6 @@
} else {
ri_tmp = digestmap_remove(rl->desc_digest_map,
ri->cache_info.signed_descriptor_digest);
- rl->signed_descriptor_bytes -= ri->cache_info.signed_descriptor_len;
tor_assert(ri_tmp == ri);
routerinfo_free(ri);
}
@@ -1207,7 +1223,6 @@
smartlist_del(rl->old_routers, idx);
sd_tmp = digestmap_remove(rl->desc_digest_map,
sd->signed_descriptor_digest);
- rl->signed_descriptor_bytes -= sd->signed_descriptor_len;
tor_assert(sd_tmp == sd);
signed_descriptor_free(sd);
routerlist_assert_ok(rl);
@@ -1229,7 +1244,6 @@
} else {
warn(LD_BUG, "Appending entry from routerlist_replace.");
routerlist_insert(rl, ri_new);
- rl->signed_descriptor_bytes += ri_new->cache_info.signed_descriptor_len;
return;
}
if (memcmp(ri_old->cache_info.identity_digest, ri_new->cache_info.identity_digest, DIGEST_LEN)) {
@@ -1238,7 +1252,6 @@
}
digestmap_set(rl->identity_map, ri_new->cache_info.identity_digest, ri_new);
digestmap_set(rl->desc_digest_map, ri_new->cache_info.signed_descriptor_digest, &(ri_new->cache_info));
- rl->signed_descriptor_bytes += ri_new->cache_info.signed_descriptor_len;
if (make_old && get_options()->DirPort) {
signed_descriptor_t *sd = signed_descriptor_from_routerinfo(ri_old);
@@ -1251,7 +1264,6 @@
/* digests don't match; digestmap_set didn't replace */
digestmap_remove(rl->desc_digest_map, ri_old->cache_info.signed_descriptor_digest);
}
- rl->signed_descriptor_bytes -= ri_old->cache_info.signed_descriptor_len;
routerinfo_free(ri_old);
}
// routerlist_assert_ok(rl);
@@ -3264,7 +3276,6 @@
tor_assert(r == r2);
sd2 = digestmap_get(rl->desc_digest_map, r->cache_info.signed_descriptor_digest);
tor_assert(&(r->cache_info) == sd2);
- bytes += r->cache_info.signed_descriptor_len;
});
SMARTLIST_FOREACH(rl->old_routers, signed_descriptor_t *, sd,
{
@@ -3272,9 +3283,7 @@
tor_assert(sd != &(r2->cache_info));
sd2 = digestmap_get(rl->desc_digest_map, sd->signed_descriptor_digest);
tor_assert(sd == sd2);
- bytes += sd->signed_descriptor_len;
});
- tor_assert(bytes == rl->signed_descriptor_bytes);
iter = digestmap_iter_init(rl->identity_map);
while (!digestmap_iter_done(iter)) {
const char *d;