__atomic_add_fetch (&task->worker->srv->stat->messages_scanned,
1, __ATOMIC_RELEASE);
#endif
+
+ /* Set average processing time */
+ guint32 slot;
+ float processing_time = task->time_real_finish - task->task_timestamp;
+
+#ifndef HAVE_ATOMIC_BUILTINS
+ slot = task->worker->srv->stat->avg_time.cur_slot++;
+#else
+ slot = __atomic_add_fetch (&task->worker->srv->stat->avg_time.cur_slot,
+ 1, __ATOMIC_RELEASE);
+#endif
+ slot = slot % MAX_AVG_TIME_SLOTS;
+ /* TODO: this should be atomic but it is not supported in C */
+ task->worker->srv->stat->avg_time.avg_time[slot] = processing_time;
+
}
}
#ifdef HAVE_OPENSSL
#include <openssl/err.h>
#include <openssl/evp.h>
+#include <math.h>
+
#endif
#include "sqlite3.h"
cur_stat.actions_stat[METRIC_ACTION_REWRITE_SUBJECT];
gdouble new_ham = cur_stat.actions_stat[METRIC_ACTION_NOACTION];
+ /* Kahan sum */
+ float sum = 0.0f;
+ volatile float c = 0.0f; /* We don't want any optimisations around c */
+ int cnt = 0;
+
+ for (int i = 0; i < MAX_AVG_TIME_SLOTS; i ++) {
+ if (!isnan(cur_stat.avg_time.avg_time[i])) {
+ cnt ++;
+ float y = cur_stat.avg_time.avg_time[i] - c;
+ float t = sum + y;
+ c = (t - sum) - y;
+ sum = t;
+ }
+ }
+
rspamd_snprintf (proctitle, sizeof (proctitle),
- "main process; %.1f msg/sec, %.1f msg/sec spam, %.1f msg/sec ham",
+ "main process; %.1f msg/sec, %.1f msg/sec spam, %.1f msg/sec ham; %.2fs avg processing time",
rate,
(new_spam - old_spam) / w->repeat,
- (new_ham - old_ham) / w->repeat);
+ (new_ham - old_ham) / w->repeat,
+ cnt > 0 ? sum : 0);
setproctitle (proctitle);
}