@cryptotaxi247 / netdata-1 / commits / 4c8107308

* Add a parameter for the libuv worker threads to pre-initialize (#12814)

* Set the thread name for libuv threads to LIBUV_WORKER * Make sure the dbengine thread has the correct name

Stelios Fragkakis committed May 4, 2022 at 17:30 UTC 4c8107308e344098f99523bd680f8cf0eb4d3117
3 files changed +7 -1
daemon/main.c
+1
@@ -1097,6 +1097,7 @@ int main(int argc, char **argv) {
1097
1098 // prepare configuration environment variables for the plugins
1099
1100 + setenv("UV_THREADPOOL_SIZE", config_get(CONFIG_SECTION_GLOBAL, "libuv worker threads", "16"), 1);
1101 get_netdata_configured_variables();
1102 set_global_environment();
1103
database/engine/rrdengine.c
+5
@@ -1186,6 +1186,7 @@ void rrdeng_worker(void* arg)
1186
1187 fatal_assert(0 == uv_timer_start(&timer_req, timer_cb, TIMER_PERIOD_MS, TIMER_PERIOD_MS));
1188 shutdown = 0;
1189 + int set_name = 0;
1190 while (likely(shutdown == 0 || rrdeng_threads_alive(wc))) {
1191 uv_run(loop, UV_RUN_DEFAULT);
1192 rrdeng_cleanup_finished_threads(wc);
@@ -1230,6 +1231,10 @@ void rrdeng_worker(void* arg)
1231 break;
1232 case RRDENG_READ_EXTENT:
1233 do_read_extent(wc, cmd.read_extent.page_cache_descr, cmd.read_extent.page_count, 1);
1234 + if (unlikely(!set_name)) {
1235 + set_name = 1;
1236 + uv_thread_set_name_np(ctx->worker_config.thread, "DBENGINE");
1237 + }
1238 break;
1239 case RRDENG_COMMIT_PAGE:
1240 do_commit_transaction(wc, STORE_DATA, NULL);
database/engine/rrdengineapi.c
+1 -1
@@ -946,7 +946,7 @@ int rrdeng_init(RRDHOST *host, struct rrdengine_instance **ctxp, char *dbfiles_p
946 /* wait for worker thread to initialize */
947 completion_wait_for(&ctx->rrdengine_completion);
948 completion_destroy(&ctx->rrdengine_completion);
949 - uv_thread_set_name_np(ctx->worker_config.thread, "DBENGINE");
949 + uv_thread_set_name_np(ctx->worker_config.thread, "LIBUV_WORKER");
950 if (ctx->worker_config.error) {
951 goto error_after_rrdeng_worker;
952 }