From 864ee7e3a3bdd57eee2efb72381e35dad9a3957f Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 9 Dec 2010 00:32:50 +0000 Subject: [PATCH] - scheduler: in some cases the system may have a too-low estimate of the performance of an app version on a host. It will then stop using that app version, so the estimate never has a chance to converge to its correct value. Fix: multiply by a random factor (mean 1, stddev .1) when comparing the FLOPS estimates of app versions. svn path=/trunk/boinc/; revision=22837 --- checkin_notes | 15 +++++++++++++++ client/sim_util.cpp | 23 +---------------------- lib/util.cpp | 19 +++++++++++++++++++ lib/util.h | 1 + sched/sched_version.cpp | 6 ++++-- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/checkin_notes b/checkin_notes index 4ec354ba31..159b0537ec 100644 --- a/checkin_notes +++ b/checkin_notes @@ -8682,3 +8682,18 @@ David 8 Dec 2010 api/ ttffont.cpp,h + +David 8 Dec 2010 + - scheduler: in some cases the system may have a too-low estimate + of the performance of an app version on a host. + It will then stop using that app version, + so the estimate never has a chance to converge to its correct value. + Fix: multiply by a random factor (mean 1, stddev .1) + when comparing the FLOPS estimates of app versions. + + client/ + sim_util.cpp + lib/ + util.cpp,h + sched/ + sched_version.cpp diff --git a/client/sim_util.cpp b/client/sim_util.cpp index ba2f01924b..7d205f1b1b 100644 --- a/client/sim_util.cpp +++ b/client/sim_util.cpp @@ -124,30 +124,9 @@ int ACTIVE_TASK::init(RESULT* rp) { //////////////// OTHER -// http://www.cs.wm.edu/~va/software/park/rvgs.c double NORMAL_DIST::sample() { if (!std_dev) return mean; - - const double p0 = 0.322232431088; const double q0 = 0.099348462606; - const double p1 = 1.0; const double q1 = 0.588581570495; - const double p2 = 0.342242088547; const double q2 = 0.531103462366; - const double p3 = 0.204231210245e-1; const double q3 = 0.103537752850; - const double p4 = 0.453642210148e-4; const double q4 = 0.385607006340e-2; - double u, t, p, q, z; - - u = drand(); - if (u < 0.5) - t = sqrt(-2.0 * log(u)); - else - t = sqrt(-2.0 * log(1.0 - u)); - p = p0 + t * (p1 + t * (p2 + t * (p3 + t * p4))); - q = q0 + t * (q1 + t * (q2 + t * (q3 + t * q4))); - if (u < 0.5) - z = (p / q) - t; - else - z = t - (p / q); - return (mean + std_dev * z); - + return (mean + std_dev * rand_normal()); } inline double exponential(double mean) { diff --git a/lib/util.cpp b/lib/util.cpp index 7462810751..4c0f7b5ae4 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -551,3 +551,22 @@ bool boinc_is_finite(double x) { #endif } +#define PI2 (2*3.1415926) + +// generate normal random numbers using Box-Muller. +// this generates 2 at a time, so cache the other one +// +double rand_normal() { + static bool cached; + static double cached_value; + if (cached) { + cached = false; + return cached_value; + } + double u1 = drand(); + double u2 = drand(); + double z = sqrt(-2*log(u1)); + cached_value = z*sin(PI2*u2); + cached = true; + return z*cos(PI2*u2); +} diff --git a/lib/util.h b/lib/util.h index 4a4b7e114c..6b7093d82f 100644 --- a/lib/util.h +++ b/lib/util.h @@ -42,6 +42,7 @@ extern void push_unique(std::string, std::vector&); static inline double drand() { return (double)rand()/(double)RAND_MAX; } +extern double rand_normal(); #ifdef _WIN32 #include diff --git a/sched/sched_version.cpp b/sched/sched_version.cpp index 3caff9aff3..e8c728abea 100644 --- a/sched/sched_version.cpp +++ b/sched/sched_version.cpp @@ -659,9 +659,11 @@ BEST_APP_VERSION* get_app_version( estimate_flops(host_usage, av); - // pick the fastest version + // pick the fastest version. + // Throw in a random factor in case the estimates are off. // - if (host_usage.projected_flops > bavp->host_usage.projected_flops) { + double r = 1 + .1*rand_normal(); + if (r*host_usage.projected_flops > bavp->host_usage.projected_flops) { bavp->host_usage = host_usage; bavp->avp = &av; bavp->reliable = app_version_is_reliable(av.id);