summaryrefslogtreecommitdiffstats
path: root/daemon
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-02-02 00:14:35 +0200
committerGitHub <noreply@github.com>2023-02-02 00:14:35 +0200
commit55d1f00bb7c2403b451947b2a225b5d1f6be9183 (patch)
tree043e57edb64b319b1eb6a883d6980fa2d9dd2c8e /daemon
parent2e56e2b87622a102aef876d297a3cd80d35028e5 (diff)
DBENGINE v2 - improvements part 12 (#14379)
* parallel initialization of tiers * do not spawn multiple dbengine event loops * user configurable dbengine parallel initialization * size netdata based on the real cpu cores available on the system netdata runs, not on the system monitored * user configurable system cpus * move cpuset parsing to os.c/.h * fix replication of misaligned chart dimensions * give a different path to each tier thread * statically allocate the path into the initialization structure * use aral for reusing dbengine pages * dictionaries uses ARAL for fixed sized values * fix compilation without internal checks * journal v2 index uses aral * test to see judy allocations * judy allocations using aral * Add config option to select if dbengine will use direct I/O (default is yes) * V1 journafiles will use uv_fs_read instead of mmap (respect the direct I/O setting) * Remove sqlite3IsMemdb as it is unused * Fix compilation error when --disable-dbengine is used * use aral for dbengine work_cmds * changed aral API to support new features * pgc and mrg aral overheads * rrdeng opcodes using aral * better structuring and naming * dbegnine query handles using aral * page descriptors using aral * remove obsolete linking * extent io descriptors using aral * aral keeps one last page alive * add missing return value * added judy aral overhead * pdc now uses aral * page_details now use aral * epdl and deol using aral - make sure ARALs are initialized before spawning the event loop * remove unused linking * pgc now uses one aral per partition * aral measure maximum allocation queue * aral to allocate pages in parallel * aral parallel pages allocation when needed * aral cleanup * track page allocation and page population separately --------- Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Diffstat (limited to 'daemon')
-rw-r--r--daemon/common.c35
-rw-r--r--daemon/common.h2
-rw-r--r--daemon/event_loop.c1
-rw-r--r--daemon/event_loop.h1
-rw-r--r--daemon/global_statistics.c28
-rw-r--r--daemon/main.c4
6 files changed, 60 insertions, 11 deletions
diff --git a/daemon/common.c b/daemon/common.c
index 85d6386313..6eae07cffc 100644
--- a/daemon/common.c
+++ b/daemon/common.c
@@ -19,3 +19,38 @@ int32_t netdata_configured_utc_offset = 0;
int netdata_ready;
int netdata_cloud_setting;
+long get_netdata_cpus(void) {
+ static long processors = 0;
+
+ if(processors)
+ return processors;
+
+ long cores_proc_stat = get_system_cpus_with_cache(false, true);
+ long cores_cpuset_v1 = (long)read_cpuset_cpus("/sys/fs/cgroup/cpuset/cpuset.cpus", cores_proc_stat);
+ long cores_cpuset_v2 = (long)read_cpuset_cpus("/sys/fs/cgroup/cpuset.cpus", cores_proc_stat);
+
+ if(cores_cpuset_v2)
+ processors = cores_cpuset_v2;
+ else if(cores_cpuset_v1)
+ processors = cores_cpuset_v1;
+ else
+ processors = cores_proc_stat;
+
+ long cores_user_configured = config_get_number(CONFIG_SECTION_GLOBAL, "cpu cores", processors);
+
+ errno = 0;
+ internal_error(true,
+ "System CPUs: %ld, ("
+ "system: %ld, cgroups cpuset v1: %ld, cgroups cpuset v2: %ld, netdata.conf: %ld"
+ ")"
+ , processors
+ , cores_proc_stat
+ , cores_cpuset_v1
+ , cores_cpuset_v2
+ , cores_user_configured
+ );
+
+ processors = cores_user_configured;
+
+ return processors;
+}
diff --git a/daemon/common.h b/daemon/common.h
index 8a775fb837..ca4d5c9544 100644
--- a/daemon/common.h
+++ b/daemon/common.h
@@ -106,4 +106,6 @@ extern int netdata_anonymous_statistics_enabled;
extern int netdata_ready;
extern int netdata_cloud_setting;
+long get_netdata_cpus(void);
+
#endif /* NETDATA_COMMON_H */
diff --git a/daemon/event_loop.c b/daemon/event_loop.c
index cb101d9143..6f09cd654a 100644
--- a/daemon/event_loop.c
+++ b/daemon/event_loop.c
@@ -24,6 +24,7 @@ void register_libuv_worker_jobs() {
worker_register_job_name(UV_EVENT_DBENGINE_EXTENT_DECOMPRESSION, "extent decompression");
worker_register_job_name(UV_EVENT_DBENGINE_EXTENT_PAGE_LOOKUP, "page lookup");
worker_register_job_name(UV_EVENT_DBENGINE_EXTENT_PAGE_POPULATION, "page populate");
+ worker_register_job_name(UV_EVENT_DBENGINE_EXTENT_PAGE_ALLOCATION, "page allocate");
// flushing related
worker_register_job_name(UV_EVENT_DBENGINE_FLUSH_MAIN_CACHE, "flush main");
diff --git a/daemon/event_loop.h b/daemon/event_loop.h
index a539a39cfa..0d3cc0d07c 100644
--- a/daemon/event_loop.h
+++ b/daemon/event_loop.h
@@ -16,6 +16,7 @@ enum event_loop_job {
UV_EVENT_DBENGINE_EXTENT_DECOMPRESSION,
UV_EVENT_DBENGINE_EXTENT_PAGE_LOOKUP,
UV_EVENT_DBENGINE_EXTENT_PAGE_POPULATION,
+ UV_EVENT_DBENGINE_EXTENT_PAGE_ALLOCATION,
// flushing related
UV_EVENT_DBENGINE_FLUSH_MAIN_CACHE,
diff --git a/daemon/global_statistics.c b/daemon/global_statistics.c
index 6edd4c60ee..0dc3ee6452 100644
--- a/daemon/global_statistics.c
+++ b/daemon/global_statistics.c
@@ -243,9 +243,6 @@ static void global_statistics_charts(void) {
global_statistics_copy(&gs, GLOBAL_STATS_RESET_WEB_USEC_MAX);
getrusage(RUSAGE_SELF, &me);
- size_t aral_structures, aral_malloc_allocated, aral_malloc_used, aral_mmap_allocated, aral_mmap_used;
- aral_get_size_statistics(&aral_structures, &aral_malloc_allocated, &aral_malloc_used, &aral_mmap_allocated, &aral_mmap_used);
-
// ----------------------------------------------------------------
{
@@ -296,6 +293,7 @@ static void global_statistics_charts(void) {
static RRDDIM *rd_buffers = NULL;
static RRDDIM *rd_workers = NULL;
static RRDDIM *rd_aral = NULL;
+ static RRDDIM *rd_judy = NULL;
static RRDDIM *rd_other = NULL;
if (unlikely(!st_memory)) {
@@ -327,6 +325,7 @@ static void global_statistics_charts(void) {
rd_buffers = rrddim_add(st_memory, "buffers", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_workers = rrddim_add(st_memory, "workers", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_aral = rrddim_add(st_memory, "aral", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ rd_judy = rrddim_add(st_memory, "judy", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_other = rrddim_add(st_memory, "other", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
@@ -342,7 +341,9 @@ static void global_statistics_charts(void) {
netdata_buffers_statistics.buffers_streaming +
netdata_buffers_statistics.cbuffers_streaming +
netdata_buffers_statistics.buffers_web +
- replication_allocated_buffers();
+ replication_allocated_buffers() +
+ aral_by_size_overhead() +
+ judy_aral_overhead();
size_t strings = 0;
string_statistics(NULL, NULL, NULL, NULL, NULL, &strings, NULL, NULL);
@@ -360,7 +361,8 @@ static void global_statistics_charts(void) {
rrddim_set_by_pointer(st_memory, rd_replication, (collected_number)dictionary_stats_memory_total(dictionary_stats_category_replication) + (collected_number)replication_allocated_memory());
rrddim_set_by_pointer(st_memory, rd_buffers, (collected_number)buffers);
rrddim_set_by_pointer(st_memory, rd_workers, (collected_number) workers_allocated_memory());
- rrddim_set_by_pointer(st_memory, rd_aral, (collected_number) aral_structures);
+ rrddim_set_by_pointer(st_memory, rd_aral, (collected_number) aral_by_size_structures());
+ rrddim_set_by_pointer(st_memory, rd_judy, (collected_number) judy_aral_structures());
rrddim_set_by_pointer(st_memory, rd_other, (collected_number)dictionary_stats_memory_total(dictionary_stats_category_other));
rrdset_done(st_memory);
@@ -381,6 +383,7 @@ static void global_statistics_charts(void) {
static RRDDIM *rd_buffers_replication = NULL;
static RRDDIM *rd_buffers_web = NULL;
static RRDDIM *rd_buffers_aral = NULL;
+ static RRDDIM *rd_buffers_judy = NULL;
if (unlikely(!st_memory_buffers)) {
st_memory_buffers = rrdset_create_localhost(
@@ -410,6 +413,7 @@ static void global_statistics_charts(void) {
rd_buffers_replication = rrddim_add(st_memory_buffers, "replication", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_buffers_web = rrddim_add(st_memory_buffers, "web", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_buffers_aral = rrddim_add(st_memory_buffers, "aral", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ rd_buffers_judy = rrddim_add(st_memory_buffers, "judy", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
}
rrddim_set_by_pointer(st_memory_buffers, rd_queries, (collected_number)netdata_buffers_statistics.query_targets_size + (collected_number) onewayalloc_allocated_memory());
@@ -424,7 +428,8 @@ static void global_statistics_charts(void) {
rrddim_set_by_pointer(st_memory_buffers, rd_cbuffers_streaming, (collected_number)netdata_buffers_statistics.cbuffers_streaming);
rrddim_set_by_pointer(st_memory_buffers, rd_buffers_replication, (collected_number)replication_allocated_buffers());
rrddim_set_by_pointer(st_memory_buffers, rd_buffers_web, (collected_number)netdata_buffers_statistics.buffers_web);
- rrddim_set_by_pointer(st_memory_buffers, rd_buffers_aral, (collected_number)(aral_malloc_allocated + aral_mmap_allocated) - (collected_number)(aral_malloc_used + aral_mmap_used));
+ rrddim_set_by_pointer(st_memory_buffers, rd_buffers_aral, (collected_number)aral_by_size_overhead());
+ rrddim_set_by_pointer(st_memory_buffers, rd_buffers_judy, (collected_number)judy_aral_overhead());
rrdset_done(st_memory_buffers);
}
@@ -1743,7 +1748,7 @@ static void dbengine2_statistics_charts(void) {
struct rrdeng_buffer_sizes buffers = rrdeng_get_buffer_sizes();
size_t buffers_total_size = buffers.handles + buffers.xt_buf + buffers.xt_io + buffers.pdc + buffers.descriptors +
- buffers.opcodes + buffers.wal + buffers.workers + buffers.epdl + buffers.deol + buffers.pd + buffers.pages;
+ buffers.opcodes + buffers.wal + buffers.workers + buffers.epdl + buffers.deol + buffers.pd + buffers.pgc + buffers.mrg;
#ifdef PDC_USE_JULYL
buffers_total_size += buffers.julyl;
@@ -1796,6 +1801,8 @@ static void dbengine2_statistics_charts(void) {
{
static RRDSET *st_pgc_buffers = NULL;
+ static RRDDIM *rd_pgc_buffers_pgc = NULL;
+ static RRDDIM *rd_pgc_buffers_mrg = NULL;
static RRDDIM *rd_pgc_buffers_opcodes = NULL;
static RRDDIM *rd_pgc_buffers_handles = NULL;
static RRDDIM *rd_pgc_buffers_descriptors = NULL;
@@ -1807,7 +1814,6 @@ static void dbengine2_statistics_charts(void) {
static RRDDIM *rd_pgc_buffers_epdl = NULL;
static RRDDIM *rd_pgc_buffers_deol = NULL;
static RRDDIM *rd_pgc_buffers_pd = NULL;
- static RRDDIM *rd_pgc_buffers_pages = NULL;
#ifdef PDC_USE_JULYL
static RRDDIM *rd_pgc_buffers_julyl = NULL;
#endif
@@ -1827,6 +1833,8 @@ static void dbengine2_statistics_charts(void) {
localhost->rrd_update_every,
RRDSET_TYPE_STACKED);
+ rd_pgc_buffers_pgc = rrddim_add(st_pgc_buffers, "pgc", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
+ rd_pgc_buffers_mrg = rrddim_add(st_pgc_buffers, "mrg", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_opcodes = rrddim_add(st_pgc_buffers, "opcodes", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_handles = rrddim_add(st_pgc_buffers, "query handles", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_descriptors = rrddim_add(st_pgc_buffers, "descriptors", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -1834,7 +1842,6 @@ static void dbengine2_statistics_charts(void) {
rd_pgc_buffers_workers = rrddim_add(st_pgc_buffers, "workers", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_pdc = rrddim_add(st_pgc_buffers, "pdc", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_pd = rrddim_add(st_pgc_buffers, "pd", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
- rd_pgc_buffers_pages = rrddim_add(st_pgc_buffers, "pages", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_xt_io = rrddim_add(st_pgc_buffers, "extent io", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_xt_buf = rrddim_add(st_pgc_buffers, "extent buffers", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
rd_pgc_buffers_epdl = rrddim_add(st_pgc_buffers, "epdl", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
@@ -1845,6 +1852,8 @@ static void dbengine2_statistics_charts(void) {
}
priority++;
+ rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_pgc, (collected_number)buffers.pgc);
+ rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_mrg, (collected_number)buffers.mrg);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_opcodes, (collected_number)buffers.opcodes);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_handles, (collected_number)buffers.handles);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_descriptors, (collected_number)buffers.descriptors);
@@ -1852,7 +1861,6 @@ static void dbengine2_statistics_charts(void) {
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_workers, (collected_number)buffers.workers);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_pdc, (collected_number)buffers.pdc);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_pd, (collected_number)buffers.pd);
- rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_pages, (collected_number)buffers.pages);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_xt_io, (collected_number)buffers.xt_io);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_xt_buf, (collected_number)buffers.xt_buf);
rrddim_set_by_pointer(st_pgc_buffers, rd_pgc_buffers_epdl, (collected_number)buffers.epdl);
diff --git a/daemon/main.c b/daemon/main.c
index 8f51e36c16..7b2076f3fc 100644
--- a/daemon/main.c
+++ b/daemon/main.c
@@ -1801,7 +1801,7 @@ int main(int argc, char **argv) {
#endif
// set libuv worker threads
- libuv_worker_threads = get_system_cpus() * 2;
+ libuv_worker_threads = (int)get_netdata_cpus() * 2;
if(libuv_worker_threads < MIN_LIBUV_WORKER_THREADS)
libuv_worker_threads = MIN_LIBUV_WORKER_THREADS;
@@ -1866,6 +1866,8 @@ int main(int argc, char **argv) {
// initialize the log files
open_all_log_files();
+ aral_judy_init();
+
get_system_timezone();
// --------------------------------------------------------------------