Skip to content

Commit

Permalink
modules/stats: sample all expiring records
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Vavruša committed Jul 20, 2015
1 parent 37fcd6c commit 93e5c06
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions modules/stats/stats.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 93e5c06

Please sign in to comment.