diff --git a/src/server/stats.c b/src/server/stats.c index ac79c851173a20682a6c726d0d03f173f59b7a2d..f328aabf5ef8da5add11c483901f80a0656e3267 100644 --- a/src/server/stats.c +++ b/src/server/stats.c @@ -36,6 +36,8 @@ #include <string.h> #include <stdio.h> #include <setjmp.h> +#include <float.h> +#include <math.h> #include "stats.h" #include "log.h" @@ -292,6 +294,16 @@ update_stat(enum stat_type st, update_one_stat(st, VT_DESCEND, -delta, now); } +static int +is_nonzero(double val) +{ +#ifdef FP_ZERO + return fpclassify(val) != FP_ZERO; +#else + return val >= DBL_MIN || val <= -DBL_MIN; +#endif +} + static int check_one_stat(enum stat_type st, enum value_type vt, @@ -326,12 +338,18 @@ check_one_stat(enum stat_type st, if ((acc < 1 && err > 1e5 * acc) || (acc >= 1 && err / acc > 1e-5)) { - kom_log("Accumulated rounding errors fixed (%s) after" - " %ld updates (st=%d, vt=%d, f=%d, factor=%d): %g => %g\n", - when, - s->updates[f], st, vt, f, factors[f], s->avenrun[f], acc); + /* Don't bother logging assignments to 0. */ + if (is_nonzero(acc) || err > 1e-10) + { + kom_log("Accumulated rounding errors fixed (%s) after" + " %ld updates (st=%d, vt=%d, f=%d, factor=%d):" + " %g => %g\n", + when, + s->updates[f], st, vt, f, factors[f], + s->avenrun[f], acc); + s->updates[f] = 0; + } s->avenrun[f] = acc; - s->updates[f] = 0; changes++; } }