commit 6c86e63029ed1f5d32955f2c3e793942fd19e172 Author: Nick Mathewson nickm@torproject.org Date: Sat Apr 15 11:31:09 2017 -0400
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. --- src/or/consdiffmgr.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/or/consdiffmgr.c b/src/or/consdiffmgr.c index df9c5b9..a9938d2 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