Module: kamailio
Branch: master
Commit: b728cb30810ef44b821a93335cdd34f954f2029c
URL:
https://github.com/kamailio/kamailio/commit/b728cb30810ef44b821a93335cdd34f…
Author: Julien Chavanton <jchavanton(a)gmail.com>
Committer: Julien Chavanton <jchavanton(a)gmail.com>
Date: 2020-09-28T13:02:44-07:00
dispatcher: fix an error in initialisation /
training of the latency estimator
---
Modified: src/modules/dispatcher/dispatch.c
---
Diff:
https://github.com/kamailio/kamailio/commit/b728cb30810ef44b821a93335cdd34f…
Patch:
https://github.com/kamailio/kamailio/commit/b728cb30810ef44b821a93335cdd34f…
---
diff --git a/src/modules/dispatcher/dispatch.c b/src/modules/dispatcher/dispatch.c
index 4066bc39d7..8e798a871b 100644
--- a/src/modules/dispatcher/dispatch.c
+++ b/src/modules/dispatcher/dispatch.c
@@ -2588,6 +2588,8 @@ int ds_mark_dst(struct sip_msg *msg, int state)
}
static inline void latency_stats_update(ds_latency_stats_t *latency_stats, int latency)
{
+ int training_count = 10000;
+
/* after 2^21 ~24 days at 1s interval, the average becomes a weighted average */
if (latency_stats->count < 2097152) {
latency_stats->count++;
@@ -2602,8 +2604,10 @@ static inline void latency_stats_update(ds_latency_stats_t
*latency_stats, int l
latency_stats->average = latency;
latency_stats->estimate = latency;
}
- /* train the average if stable after 10 samples */
- if (latency_stats->count > 10 && latency_stats->stdev < 0.5)
latency_stats->count = 500000;
+ /* stabilize-train the estimator if the average is stable after 10 samples */
+ if (latency_stats->count > 10 && latency_stats->count <
training_count
+ && latency_stats->stdev < 0.5)
+ latency_stats->count = training_count;
if (latency_stats->min > latency)
latency_stats->min = latency;
if (latency_stats->max < latency)