summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorVladimír Čunát <vladimir.cunat@nic.cz>2017-07-27 15:00:39 +0200
committerPetr Špaček <petr.spacek@nic.cz>2018-02-15 16:41:06 +0100
commitafbe6d8a708d846e409293187b70df2e776039ee (patch)
tree6225b5f735b2d5df8bd9ca8ab8ed5f9153e11203 /modules
parentcache: fix broken refresh of insecure records (diff)
downloadknot-resolver-afbe6d8a708d846e409293187b70df2e776039ee.tar.xz
knot-resolver-afbe6d8a708d846e409293187b70df2e776039ee.zip
stats: remove tracking of expiring records
The predict module doesn't use this way since 965bab926f (v1.3.2), and there seems to be no other likely use case.
Diffstat (limited to 'modules')
-rw-r--r--modules/stats/README.rst8
-rw-r--r--modules/stats/stats.c40
2 files changed, 11 insertions, 37 deletions
diff --git a/modules/stats/README.rst b/modules/stats/README.rst
index 8f528064..29d23d8b 100644
--- a/modules/stats/README.rst
+++ b/modules/stats/README.rst
@@ -86,14 +86,6 @@ and include subrequests. The list maximum size is 5000 entries, make diffs if yo
Clear the list of most frequent iterative queries.
-.. function:: stats.expiring()
-
-Outputs list of soon-to-expire records as a JSON array.
-The list maximum size is 5000 entries, make diffs if you want to track it over time.
-
-.. function:: stats.clear_expiring()
-
-Clear the list of soon expiring records.
Built-in statistics
^^^^^^^^^^^^^^^^^^^
diff --git a/modules/stats/stats.c b/modules/stats/stats.c
index f0a517f8..8a593ca5 100644
--- a/modules/stats/stats.c
+++ b/modules/stats/stats.c
@@ -84,7 +84,6 @@ struct stat_data {
map_t map;
struct {
namehash_t *frequent;
- namehash_t *expiring;
} queries;
struct {
addrlist_t q;
@@ -124,10 +123,10 @@ static inline int collect_key(char *key, const knot_dname_t *name, uint16_t type
{
memcpy(key, &type, sizeof(type));
int key_len = knot_dname_to_wire((uint8_t *)key + sizeof(type), name, KNOT_DNAME_MAXLEN);
- if (key_len > 0) {
- return key_len + sizeof(type);
+ if (key_len < 0) {
+ return kr_error(key_len);
}
- return key_len;
+ return key_len + sizeof(type);
}
static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_pkt_t *pkt)
@@ -135,18 +134,18 @@ static void collect_sample(struct stat_data *data, struct kr_rplan *rplan, knot_
/* Sample key = {[2] type, [1-255] owner} */
char key[sizeof(uint16_t) + KNOT_DNAME_MAXLEN];
for (size_t i = 0; i < rplan->resolved.len; ++i) {
- /* Sample queries leading to iteration or expiring */
+ /* Sample queries leading to iteration */
struct kr_query *qry = rplan->resolved.at[i];
- if ((qry->flags.CACHED) && !(qry->flags.EXPIRING)) {
+ if (qry->flags.CACHED) {
continue;
}
- int key_len = collect_key(key, qry->sname, qry->stype);
- if (qry->flags.EXPIRING) {
- unsigned *count = lru_get_new(data->queries.expiring, key, key_len);
- if (count)
- *count += 1;
/* Consider 1 in N for frequent sampling. */
- } else if (kr_rand_uint(FREQUENT_PSAMPLE) <= 1) {
+ if (kr_rand_uint(FREQUENT_PSAMPLE) <= 1) {
+ int key_len = collect_key(key, qry->sname, qry->stype);
+ if (key_len < 0) {
+ assert(false);
+ continue;
+ }
unsigned *count = lru_get_new(data->queries.frequent, key, key_len);
if (count)
*count += 1;
@@ -370,19 +369,6 @@ static char* clear_frequent(void *env, struct kr_module *module, const char *arg
return NULL;
}
-static char* dump_expiring(void *env, struct kr_module *module, const char *args)
-{
- struct stat_data *data = module->data;
- return dump_list(env, module, args, data->queries.expiring);
-}
-
-static char* clear_expiring(void *env, struct kr_module *module, const char *args)
-{
- struct stat_data *data = module->data;
- lru_reset(data->queries.expiring);
- return NULL;
-}
-
static char* dump_upstreams(void *env, struct kr_module *module, const char *args)
{
struct stat_data *data = module->data;
@@ -447,7 +433,6 @@ int stats_init(struct kr_module *module)
data->map = map_make();
module->data = data;
lru_create(&data->queries.frequent, FREQUENT_COUNT, NULL, NULL);
- lru_create(&data->queries.expiring, FREQUENT_COUNT, NULL, NULL);
/* Initialize ring buffer of recently visited upstreams */
array_init(data->upstreams.q);
if (array_reserve(data->upstreams.q, UPSTREAMS_COUNT) != 0) {
@@ -467,7 +452,6 @@ int stats_deinit(struct kr_module *module)
if (data) {
map_clear(&data->map);
lru_free(data->queries.frequent);
- lru_free(data->queries.expiring);
array_clear(data->upstreams.q);
free(data);
}
@@ -483,8 +467,6 @@ struct kr_prop *stats_props(void)
{ &stats_list, "list", "List observed metrics.", },
{ &dump_frequent, "frequent", "List most frequent queries.", },
{ &clear_frequent,"clear_frequent", "Clear frequent queries log.", },
- { &dump_expiring, "expiring", "List expiring records.", },
- { &clear_expiring,"clear_expiring", "Clear expiring records log.", },
{ &dump_upstreams, "upstreams", "List recently seen authoritatives.", },
{ NULL, NULL, NULL }
};