From 7c79495137bcd3989428d65b184038aa71fbae70 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 7 Dec 2006 20:11:30 +0000 Subject: r11468@Kushana: nickm | 2006-12-07 14:56:57 -0500 Revise logic used to flush state to disk. Now, we try to batch non-urgent changes so that we do not do too many writes, and we save very-non-urgent changes every once in a rare while, and we never save more than once per second. svn:r9047 --- src/or/hibernate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/or/hibernate.c') diff --git a/src/or/hibernate.c b/src/or/hibernate.c index 79c51c7184..bd89240e47 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -391,8 +391,8 @@ reset_accounting(time_t now) static INLINE int time_to_record_bandwidth_usage(time_t now) { - /* Note every 60 sec */ -#define NOTE_INTERVAL (60) + /* Note every 600 sec */ +#define NOTE_INTERVAL (600) /* Or every 20 megabytes */ #define NOTE_BYTES 20*(1024*1024) static uint64_t last_read_bytes_noted = 0; @@ -575,7 +575,7 @@ accounting_record_bandwidth_usage(time_t now, or_state_t *state) state->AccountingBytesWrittenInInterval = n_bytes_written_in_interval; state->AccountingSecondsActive = n_seconds_active_in_interval; state->AccountingExpectedUsage = expected_bandwidth_usage; - state->dirty = 1; + or_state_mark_dirty(state, 60); return r; } @@ -760,6 +760,7 @@ hibernate_begin(int new_state, time_t now) hibernate_state = new_state; accounting_record_bandwidth_usage(now, get_or_state()); + or_state_mark_dirty(get_or_state(), 0); } /** Called when we've been hibernating and our timeout is reached. */ @@ -827,6 +828,7 @@ hibernate_go_dormant(time_t now) } accounting_record_bandwidth_usage(now, get_or_state()); + or_state_mark_dirty(get_or_state(), 0); } /** Called when hibernate_end_time has arrived. */ -- cgit v1.2.3-54-g00ecf