From 279c3a2b3792a514d7e883dc2e6b24e7d78af934 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 8 Oct 2011 05:17:44 +0000 Subject: [PATCH] - scheduler: problem: in the daily quota mechanism, the boundary between days is 00:00 in server local time. This creates a spike of jobs being dispatched (and files being downloaded) after that time. Solution: distribute the boundary uniformly, using a random number determined by the host ID. (Make sure to save/restore the seed around this, so we don't destroy the randomness of other things) svn path=/trunk/boinc/; revision=24353 --- checkin_notes | 14 ++++++++++++++ sched/handle_request.cpp | 13 +++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/checkin_notes b/checkin_notes index 7a2069d618..65fd21c591 100644 --- a/checkin_notes +++ b/checkin_notes @@ -6969,3 +6969,17 @@ Charlie 7 Oct 2011 coproc_detect.cpp lib/ coproc.cpp,h + +David 7 Oct 2011 + - scheduler: problem: in the daily quota mechanism, + the boundary between days is 00:00 in server local time. + This creates a spike of jobs being dispatched + (and files being downloaded) after that time. + + Solution: distribute the boundary uniformly, + using a random number determined by the host ID. + (Make sure to save/restore the seed around this, + so we don't destroy the randomness of other things) + + sched/ + handle_request.cpp diff --git a/sched/handle_request.cpp b/sched/handle_request.cpp index 01d7d3012b..e3e826ae82 100644 --- a/sched/handle_request.cpp +++ b/sched/handle_request.cpp @@ -1075,7 +1075,7 @@ static inline bool requesting_work() { void process_request(char* code_sign_key) { PLATFORM* platform; int retval; - double last_rpc_time; + double last_rpc_time, x; struct tm *rpc_time_tm; bool ok_to_send_work = !config.dont_send_jobs; bool have_no_work = false; @@ -1195,13 +1195,22 @@ void process_request(char* code_sign_key) { } } + // in deciding whether it's a new day, + // add a random factor (based on host ID) + // to smooth out network traffic over the day + // + retval = rand(); + srand(g_reply->host.id); + x = drand()*86400; + srand(retval); last_rpc_time = g_reply->host.rpc_time; - t = g_reply->host.rpc_time; + t = g_reply->host.rpc_time + x; rpc_time_tm = localtime(&t); g_request->last_rpc_dayofyear = rpc_time_tm->tm_yday; t = time(0); g_reply->host.rpc_time = t; + t += x; rpc_time_tm = localtime(&t); g_request->current_rpc_dayofyear = rpc_time_tm->tm_yday;