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

kr_cache_gc: implemented dry-run (only occupation watching mode)

parent b77c6aad
Branches
Tags
1 merge request!817cache garbage collector
......@@ -153,7 +153,7 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg)
return ret;
}
if (db_usage < MAX_OK_PERCENT_USAGE) {
if (cfg->dry_run || db_usage < MAX_OK_PERCENT_USAGE) {
kr_gc_cache_close(&kres_db, db);
return KNOT_EOK;
}
......
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
......@@ -20,6 +21,8 @@ typedef struct {
size_t rw_txn_items; // maximum number of deleted records per RW transaction (0 = unlimited)
unsigned long rw_txn_duration; // maximum duration of RW transaction in usecs (0 = unlimited)
unsigned long rw_txn_delay; // waiting time between two RW transactions in usecs
bool dry_run;
} kr_cache_gc_cfg_t;
......
......@@ -35,6 +35,7 @@ static void print_help()
printf(" -m <rw_txn_duration(usecs)>\n");
printf(" -w <wait_next_rw_txn(usecs)>\n");
printf(" -t <temporary_memory(MBytes)>\n");
printf(" -n (= dry run)\n");
}
int main(int argc, char *argv[])
......@@ -50,7 +51,7 @@ int main(int argc, char *argv[])
kr_cache_gc_cfg_t cfg = { 0 };
int o;
while ((o = getopt(argc, argv, "hc:d:l:m:w:t:")) != -1) {
while ((o = getopt(argc, argv, "hnc:d:l:m:w:t:")) != -1) {
switch (o) {
case 'c':
cfg.cache_path = optarg;
......@@ -74,6 +75,9 @@ int main(int argc, char *argv[])
cfg.temp_keys_space *= 1048576;
break;
#undef get_nonneg_optarg
case 'n':
cfg.dry_run = true;
break;
case ':':
case '?':
case 'h':
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment