diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-01-26 18:05:15 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-01-26 18:05:42 +0000 |
commit | 112b5b91647c3dea45cc1c9bc364df526c8012f1 (patch) | |
tree | 450af925135ec664c4310a1eb28b69481094ee2a /database/engine | |
parent | Releasing debian version 1.32.1-2. (diff) | |
download | netdata-112b5b91647c3dea45cc1c9bc364df526c8012f1.tar.xz netdata-112b5b91647c3dea45cc1c9bc364df526c8012f1.zip |
Merging upstream version 1.33.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'database/engine')
-rw-r--r-- | database/engine/README.md | 6 | ||||
-rw-r--r-- | database/engine/pagecache.c | 6 | ||||
-rw-r--r-- | database/engine/rrdengine.c | 18 | ||||
-rwxr-xr-x | database/engine/rrdengineapi.c | 12 | ||||
-rw-r--r-- | database/engine/rrdenginelib.h | 40 |
5 files changed, 21 insertions, 61 deletions
diff --git a/database/engine/README.md b/database/engine/README.md index 191366a46..a782716f0 100644 --- a/database/engine/README.md +++ b/database/engine/README.md @@ -44,7 +44,7 @@ section for details. The `dbengine multihost disk space` option determines the amount of disk space in **MiB** that is dedicated to storing Netdata metric values and all related metadata describing them. You can use the [**database engine -calculator**](/docs/store/change-metrics-storage.md#calculate-the-system-resources-RAM-disk-space-needed-to-store-metrics) +calculator**](/docs/store/change-metrics-storage.md#calculate-the-system-resources-ram-disk-space-needed-to-store-metrics) to correctly set `dbengine multihost disk space` based on your metrics retention policy. The calculator gives an accurate estimate based on how many child nodes you have, how many metrics your Agent collects, and more. @@ -62,7 +62,7 @@ Netdata metric values per legacy database engine instance (see [details on the l When using the multihost database engine, all parent and child nodes share the same `page cache size` and `dbengine multihost disk space` in a single dbengine instance. The [**database engine -calculator**](/docs/store/change-metrics-storage.md#calculate-the-system-resources-RAM-disk-space-needed-to-store-metrics) +calculator**](/docs/store/change-metrics-storage.md#calculate-the-system-resources-ram-disk-space-needed-to-store-metrics) helps you properly set `page cache size` and `dbengine multihost disk space` on your parent node to allocate enough resources based on your metrics retention policy and how many child nodes you have. @@ -112,7 +112,7 @@ An important observation is that RAM usage depends on both the `page cache size` options. You can use our [database engine -calculator](/docs/store/change-metrics-storage.md#calculate-the-system-resources-RAM-disk-space-needed-to-store-metrics) +calculator](/docs/store/change-metrics-storage.md#calculate-the-system-resources-ram-disk-space-needed-to-store-metrics) to validate the memory requirements for your particular system(s) and configuration (**out-of-date**). ### Disk space requirements diff --git a/database/engine/pagecache.c b/database/engine/pagecache.c index 90423176c..40e24b321 100644 --- a/database/engine/pagecache.c +++ b/database/engine/pagecache.c @@ -289,14 +289,14 @@ static void pg_cache_reserve_pages(struct rrdengine_instance *ctx, unsigned numb ++failures; uv_rwlock_wrunlock(&pg_cache->pg_cache_rwlock); - init_completion(&compl); + completion_init(&compl); cmd.opcode = RRDENG_FLUSH_PAGES; cmd.completion = &compl; rrdeng_enq_cmd(&ctx->worker_config, &cmd); /* wait for some pages to be flushed */ debug(D_RRDENGINE, "%s: waiting for pages to be written to disk before evicting.", __func__); - wait_for_completion(&compl); - destroy_completion(&compl); + completion_wait_for(&compl); + completion_destroy(&compl); if (unlikely(failures > 1)) { unsigned long slots, usecs_to_sleep; diff --git a/database/engine/rrdengine.c b/database/engine/rrdengine.c index 54a9cdf8d..a975cfa6e 100644 --- a/database/engine/rrdengine.c +++ b/database/engine/rrdengine.c @@ -207,7 +207,7 @@ void read_cached_extent_cb(struct rrdengine_worker_config* wc, unsigned idx, str } } if (xt_io_descr->completion) - complete(xt_io_descr->completion); + completion_mark_complete(xt_io_descr->completion); freez(xt_io_descr); } @@ -360,7 +360,7 @@ after_crc_check: freez(uncompressed_buf); } if (xt_io_descr->completion) - complete(xt_io_descr->completion); + completion_mark_complete(xt_io_descr->completion); uv_fs_req_cleanup(req); free(xt_io_descr->buf); freez(xt_io_descr); @@ -634,7 +634,7 @@ void flush_pages_cb(uv_fs_t* req) rrdeng_page_descr_mutex_unlock(ctx, descr); } if (xt_io_descr->completion) - complete(xt_io_descr->completion); + completion_mark_complete(xt_io_descr->completion); uv_fs_req_cleanup(req); free(xt_io_descr->buf); freez(xt_io_descr); @@ -712,7 +712,7 @@ static int do_flush_pages(struct rrdengine_worker_config* wc, int force, struct if (!count) { debug(D_RRDENGINE, "%s: no pages eligible for flushing.", __func__); if (completion) - complete(completion); + completion_mark_complete(completion); return 0; } wc->inflight_dirty_pages += count; @@ -975,7 +975,7 @@ static void rrdeng_cleanup_finished_threads(struct rrdengine_worker_config* wc) } if (unlikely(SET_QUIESCE == ctx->quiesce && !rrdeng_threads_alive(wc))) { ctx->quiesce = QUIESCED; - complete(&ctx->rrdengine_completion); + completion_mark_complete(&ctx->rrdengine_completion); } } @@ -1171,7 +1171,7 @@ void rrdeng_worker(void* arg) wc->error = 0; /* wake up initialization thread */ - complete(&ctx->rrdengine_completion); + completion_mark_complete(&ctx->rrdengine_completion); fatal_assert(0 == uv_timer_start(&timer_req, timer_cb, TIMER_PERIOD_MS, TIMER_PERIOD_MS)); shutdown = 0; @@ -1211,7 +1211,7 @@ void rrdeng_worker(void* arg) wal_flush_transaction_buffer(wc); if (!rrdeng_threads_alive(wc)) { ctx->quiesce = QUIESCED; - complete(&ctx->rrdengine_completion); + completion_mark_complete(&ctx->rrdengine_completion); } break; case RRDENG_READ_PAGE: @@ -1226,7 +1226,7 @@ void rrdeng_worker(void* arg) case RRDENG_FLUSH_PAGES: { if (wc->now_invalidating_dirty_pages) { /* Do not flush if the disk cannot keep up */ - complete(cmd.completion); + completion_mark_complete(cmd.completion); } else { (void)do_flush_pages(wc, 1, cmd.completion); } @@ -1276,7 +1276,7 @@ error_after_loop_init: wc->error = UV_EAGAIN; /* wake up initialization thread */ - complete(&ctx->rrdengine_completion); + completion_mark_complete(&ctx->rrdengine_completion); } /* C entry point for development purposes diff --git a/database/engine/rrdengineapi.c b/database/engine/rrdengineapi.c index d81b95805..6ebee1459 100755 --- a/database/engine/rrdengineapi.c +++ b/database/engine/rrdengineapi.c @@ -944,11 +944,11 @@ int rrdeng_init(RRDHOST *host, struct rrdengine_instance **ctxp, char *dbfiles_p goto error_after_init_rrd_files; } - init_completion(&ctx->rrdengine_completion); + completion_init(&ctx->rrdengine_completion); fatal_assert(0 == uv_thread_create(&ctx->worker_config.thread, rrdeng_worker, &ctx->worker_config)); /* wait for worker thread to initialize */ - wait_for_completion(&ctx->rrdengine_completion); - destroy_completion(&ctx->rrdengine_completion); + completion_wait_for(&ctx->rrdengine_completion); + completion_destroy(&ctx->rrdengine_completion); uv_thread_set_name_np(ctx->worker_config.thread, "DBENGINE"); if (ctx->worker_config.error) { goto error_after_rrdeng_worker; @@ -1009,13 +1009,13 @@ void rrdeng_prepare_exit(struct rrdengine_instance *ctx) return; } - init_completion(&ctx->rrdengine_completion); + completion_init(&ctx->rrdengine_completion); cmd.opcode = RRDENG_QUIESCE; rrdeng_enq_cmd(&ctx->worker_config, &cmd); /* wait for dbengine to quiesce */ - wait_for_completion(&ctx->rrdengine_completion); - destroy_completion(&ctx->rrdengine_completion); + completion_wait_for(&ctx->rrdengine_completion); + completion_destroy(&ctx->rrdengine_completion); //metalog_prepare_exit(ctx->metalog_ctx); } diff --git a/database/engine/rrdenginelib.h b/database/engine/rrdenginelib.h index 8b6751f00..32eebf103 100644 --- a/database/engine/rrdenginelib.h +++ b/database/engine/rrdenginelib.h @@ -14,9 +14,6 @@ struct rrdengine_instance; #define BITS_PER_ULONG (sizeof(unsigned long) * 8) -/* Taken from linux kernel */ -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) - #define ALIGN_BYTES_FLOOR(x) (((x) / RRDENG_BLOCK_SIZE) * RRDENG_BLOCK_SIZE) #define ALIGN_BYTES_CEILING(x) ((((x) + RRDENG_BLOCK_SIZE - 1) / RRDENG_BLOCK_SIZE) * RRDENG_BLOCK_SIZE) @@ -76,43 +73,6 @@ static inline unsigned long ulong_compare_and_swap(volatile unsigned long *ptr, #define O_DIRECT (0) #endif -struct completion { - uv_mutex_t mutex; - uv_cond_t cond; - volatile unsigned completed; -}; - -static inline void init_completion(struct completion *p) -{ - p->completed = 0; - fatal_assert(0 == uv_cond_init(&p->cond)); - fatal_assert(0 == uv_mutex_init(&p->mutex)); -} - -static inline void destroy_completion(struct completion *p) -{ - uv_cond_destroy(&p->cond); - uv_mutex_destroy(&p->mutex); -} - -static inline void wait_for_completion(struct completion *p) -{ - uv_mutex_lock(&p->mutex); - while (0 == p->completed) { - uv_cond_wait(&p->cond, &p->mutex); - } - fatal_assert(1 == p->completed); - uv_mutex_unlock(&p->mutex); -} - -static inline void complete(struct completion *p) -{ - uv_mutex_lock(&p->mutex); - p->completed = 1; - uv_mutex_unlock(&p->mutex); - uv_cond_broadcast(&p->cond); -} - static inline int crc32cmp(void *crcp, uLong crc) { return (*(uint32_t *)crcp != crc); |