aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2017-04-15 11:31:09 -0400
committerNick Mathewson <nickm@torproject.org>2017-04-24 10:59:25 -0400
commit6c86e63029ed1f5d32955f2c3e793942fd19e172 (patch)
tree590d5491a64834a1da9999710716fed192cc884d /src/or
parent82bb8afb6067005f52f656b658ca1a1a6501b22d (diff)
downloadtor-6c86e63029ed1f5d32955f2c3e793942fd19e172.tar.gz
tor-6c86e63029ed1f5d32955f2c3e793942fd19e172.zip
Consdiffmgr: use aggressive-release flag on consensuses
This conscache flag tells conscache that it should munmap the document as soon as reasonably possible, since its usage pattern is expected to not have a lot of time-locality.
Diffstat (limited to 'src/or')
-rw-r--r--src/or/consdiffmgr.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c
index df9c5b9e08..a9938d2f8b 100644
--- a/src/or/consdiffmgr.c
+++ b/src/or/consdiffmgr.c
@@ -68,7 +68,7 @@ static consdiff_cfg_t consdiff_cfg = {
static int consensus_diff_queue_diff_work(consensus_cache_entry_t *diff_from,
consensus_cache_entry_t *diff_to);
-
+static void consdiffmgr_set_cache_flags(void);
/**
* Helper: initialize <b>cons_diff_cache</b>.
*/
@@ -84,6 +84,8 @@ cdm_cache_init(void)
log_err(LD_FS, "Error: Couldn't open storage for consensus diffs.");
tor_assert_unreached();
// LCOV_EXCL_STOP
+ } else {
+ consdiffmgr_set_cache_flags();
}
cdm_cache_dirty = 1;
}
@@ -210,8 +212,10 @@ consdiffmgr_add_consensus(const char *consensus,
config_free_lines(labels);
}
- if (entry)
+ if (entry) {
+ consensus_cache_entry_mark_for_aggressive_release(entry);
consensus_cache_entry_decref(entry);
+ }
cdm_cache_dirty = 1;
return entry ? 0 : -1;
@@ -498,6 +502,23 @@ consdiffmgr_rescan(void)
}
/**
+ * Set consensus cache flags on the objects in this consdiffmgr.
+ */
+static void
+consdiffmgr_set_cache_flags(void)
+{
+ /* Right now, we just mark the consensus objects for aggressive release,
+ * so that they get mmapped for as little time as possible. */
+ smartlist_t *objects = smartlist_new();
+ consensus_cache_find_all(objects, cdm_cache_get(), LABEL_DOCTYPE,
+ DOCTYPE_CONSENSUS);
+ SMARTLIST_FOREACH_BEGIN(objects, consensus_cache_entry_t *, ent) {
+ consensus_cache_entry_mark_for_aggressive_release(ent);
+ } SMARTLIST_FOREACH_END(ent);
+ smartlist_free(objects);
+}
+
+/**
* Called before shutdown: drop all storage held by the consdiffmgr.c module.
*/
void