Skip to content
Snippets Groups Projects
Verified Commit 36810cd3 authored by Libor Peltan's avatar Libor Peltan Committed by Petr Špaček
Browse files

kr_cache_gc: randomized deleting of parts of huge categories

parent a5dfd1ba
No related branches found
No related tags found
1 merge request!817cache garbage collector
......@@ -16,6 +16,11 @@ static bool rrtype_is_infrastructure(uint16_t r)
}
}
static int get_random(int to)
{
return rand() % to;
}
// TODO this is just an example, make this more clever
category_t kr_gc_categorize(gc_record_info_t *info)
{
......@@ -23,25 +28,26 @@ category_t kr_gc_categorize(gc_record_info_t *info)
switch (info->no_labels) {
case 0:
return 1;
res = 5;
break;
case 1:
return 2;
res = 10;
break;
case 2:
return (rrtype_is_infrastructure(info->rrtype) ? 3 : 20);
res = (rrtype_is_infrastructure(info->rrtype) ? 15 : 20);
break;
}
if (info->entry_size > 300) {
return 90;
res += 30;
}
if (rrtype_is_infrastructure(info->rrtype)) {
if (info->expires_in > 0) {
res = 30;
} else {
res = 45;
res = res > 40 ? 40 : res;
}
}
return res;
return res + get_random(5);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment