Looking at code before r16603: double wu_est = result->estimated_duration(for_work_fetch); //seconds
double frac_est = (elapsed_time / fraction_done) - elapsed_time; //seconds double fraction_left = 1-fraction_done; //0..1 double x = fraction_done*frac_est + fraction_left*fraction_left*wu_est; frac_est is the time remaining if we just do a linear calculation based on elapsed time and fraction done. wu_est is the total time the task will take according to the project server and local benchmarks. In the assignment of 'x', fraction_left is multiplied squared, and fraction_done is multiplied only once. Looks like a bug. But in fact it's correct. An interpolation looks like this: a*(1-fraction) + b*fraction; And what did we really want to calculate, again? est_using_flops * (1-done) + est_using_elapsed * done Back to the original calculation. Let's swap the sum to make it match the above example. fraction_left*fraction_left*wu_est + fraction_done*frac_est; wu_est is the _total_ time for the WU, fraction_left*wu_est is how you calculate how much time is _left_, based on the total. Replacing that with something more readable we get: fraction_left*wu_est_left + fraction_done*frac_est; And fraction_left is (1-fraction_done), so now it looks like a correct linear interpolation. So there's no bug, just written in a confusing way. I don't know if there is a bug in the current code (didn't bother to look yet); but the real solution is to abstract linear or quadratic interpolation into an inline function (or variable assignment!) that does that and *only* that. The main problem was that we are getting a remaining estimate from a total estimate in the same line of code that is doing interpolation. I shouldn't need to do this lengthy analysis just to prove the code is correct; if it's not easy to check for correctness, then it should be rewritten... _______________________________________________ boinc_dev mailing list [email protected] http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev To unsubscribe, visit the above URL and (near bottom of page) enter your email address.
