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;
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;