From: Marek VavruĊĦa Date: Mon, 20 Jul 2015 22:46:53 +0000 (+0200) Subject: modules/stats: sample all expiring records X-Git-Tag: v1.0.0-beta1~72^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=93e5c06f674e5eeb26e9432e086f287411d8baf7;p=thirdparty%2Fknot-resolver.git modules/stats: sample all expiring records --- diff --git a/modules/stats/stats.c b/modules/stats/stats.c index 6c1fdc40e..81263984c 100644 --- a/modules/stats/stats.c +++ b/modules/stats/stats.c @@ -121,12 +121,6 @@ static inline int collect_key(char *key, const knot_dname_t *name, uint16_t type static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_pkt_t *pkt) { - /* Probabilistic sampling of all queries (consider half) */ - unsigned roll = kr_rand_uint(FREQUENT_PSAMPLE); - if (roll > FREQUENT_PSAMPLE / 2) { - return; - } - /* Sample key = {[2] type, [1-255] owner} */ char key[sizeof(uint16_t) + KNOT_DNAME_MAXLEN]; struct kr_query *qry = NULL; @@ -141,7 +135,7 @@ static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_ if (count) *count += 1; /* Consider 1 in N for frequent sampling. */ - } else if (roll <= 1) { + } else if (kr_rand_uint(FREQUENT_PSAMPLE) <= 1) { unsigned *count = lru_set(data->queries.frequent, key, key_len); if (count) *count += 1;