diff options
author | Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com> | 2022-05-10 13:33:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-10 13:33:54 +0300 |
commit | 6ad3e612e04cb8ad47839d71d4e9118c5498b907 (patch) | |
tree | d5edf225ec1a80fac970f03876cce235d3152dbd /daemon | |
parent | 88559a49b3309755c15d29af793e8a8a5b3bc11d (diff) |
Initialize the metadata database when performing dbengine stress test (#12861)
* Remove error (no real value)
* Add a parameter to create an in-memory database for stress testing
* Add a new parameter to the stresstest command to set the number of deisred libuv worker threads
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/main.c | 22 | ||||
-rw-r--r-- | daemon/unit_test.c | 1 |
2 files changed, 16 insertions, 7 deletions
diff --git a/daemon/main.c b/daemon/main.c index 74684b7312..da1696c9b3 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -340,12 +340,12 @@ int help(int exitcode) { " -W sqlite-compact Reclaim metadata database unused space and exit.\n\n" #ifdef ENABLE_DBENGINE " -W createdataset=N Create a DB engine dataset of N seconds and exit.\n\n" - " -W stresstest=A,B,C,D,E,F\n" + " -W stresstest=A,B,C,D,E,F,G\n" " Run a DB engine stress test for A seconds,\n" " with B writers and C readers, with a ramp up\n" " time of D seconds for writers, a page cache\n" " size of E MiB, an optional disk space limit\n" - " of F MiB and exit.\n\n" + " of F MiB, G libuv workers (default 16) and exit.\n\n" #endif " -W set section option value\n" " set netdata.conf option from the command line.\n\n" @@ -567,7 +567,7 @@ static void get_netdata_configured_variables() { } -static int load_netdata_conf(char *filename, char overwrite_used) { +int load_netdata_conf(char *filename, char overwrite_used) { errno = 0; int ret = 0; @@ -777,17 +777,17 @@ int main(int argc, char **argv) { char* stresstest_string = "stresstest="; #endif if(strcmp(optarg, "sqlite-check") == 0) { - sql_init_database(DB_CHECK_INTEGRITY); + sql_init_database(DB_CHECK_INTEGRITY, 0); return 0; } if(strcmp(optarg, "sqlite-fix") == 0) { - sql_init_database(DB_CHECK_FIX_DB); + sql_init_database(DB_CHECK_FIX_DB, 0); return 0; } if(strcmp(optarg, "sqlite-compact") == 0) { - sql_init_database(DB_CHECK_RECLAIM_SPACE); + sql_init_database(DB_CHECK_RECLAIM_SPACE, 0); return 0; } @@ -835,7 +835,7 @@ int main(int argc, char **argv) { else if(strncmp(optarg, stresstest_string, strlen(stresstest_string)) == 0) { char *endptr; unsigned test_duration_sec = 0, dset_charts = 0, query_threads = 0, ramp_up_seconds = 0, - page_cache_mb = 0, disk_space_mb = 0; + page_cache_mb = 0, disk_space_mb = 0, workers = 16; optarg += strlen(stresstest_string); test_duration_sec = (unsigned)strtoul(optarg, &endptr, 0); @@ -849,7 +849,15 @@ int main(int argc, char **argv) { page_cache_mb = (unsigned)strtoul(endptr + 1, &endptr, 0); if (',' == *endptr) disk_space_mb = (unsigned)strtoul(endptr + 1, &endptr, 0); + if (',' == *endptr) + workers = (unsigned)strtoul(endptr + 1, &endptr, 0); + + if (workers > 1024) + workers = 1024; + char workers_str[16]; + snprintf(workers_str, 15, "%u", workers); + setenv("UV_THREADPOOL_SIZE", workers_str, 1); dbengine_stress_test(test_duration_sec, dset_charts, query_threads, ramp_up_seconds, page_cache_mb, disk_space_mb); return 0; diff --git a/daemon/unit_test.c b/daemon/unit_test.c index 2fc16e2d07..4e3056e759 100644 --- a/daemon/unit_test.c +++ b/daemon/unit_test.c @@ -2190,6 +2190,7 @@ void dbengine_stress_test(unsigned TEST_DURATION_SEC, unsigned DSET_CHARTS, unsi fprintf(stderr, "Initializing localhost with hostname 'dbengine-stress-test'\n"); + (void) sql_init_database(DB_CHECK_NONE, 1); host = dbengine_rrdhost_find_or_create("dbengine-stress-test"); if (NULL == host) return; |