summaryrefslogtreecommitdiffstats
path: root/collectors/plugins.d
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2023-06-19 23:19:36 +0300
committerGitHub <noreply@github.com>2023-06-19 23:19:36 +0300
commit43c749b07d07e79dae8111dcdb7bc1a46c3dda1b (patch)
tree4c3a270652787c91ef15c7ef8e29915769fc1fd4 /collectors/plugins.d
parent0b4f820e9d42d10f64c3305d9c084261bc9880cf (diff)
Obvious memory reductions (#15204)
* remove rd->update_every * reduce amount of memory for RRDDIM * reorgnize rrddim->db entries * optimize rrdset and statsd * optimize dictionaries * RW_SPINLOCK for dictionaries * fix codeql warning * rw_spinlock improvements * remove obsolete assertion * fix crash on health_alarm_log_process() * use RW_SPINLOCK for AVL trees * add RW_SPINLOCK read/write trylock * pgc and mrg now use rw_spinlocks; cache line optimizations for mrg * thread tag of dbegnine init * append created datafile, lockless * make DOUBLE_LINKED_LIST_APPEND_ITEM_UNSAFE friendly for lockless use * thread cancelability in spinlocks; optimize thread cancelability management * introduce a JudyL to index datafiles and use it during queries to quickly find the relevant files * use the last timestamp of each journal file for indexing * when the previous cannot be found, start from the beginning * add more stats to PDC to trace routing easier * rename spinlock functions * fix for spinlock renames * revert statsd socket statistics to size_t * turn fatal into internal_fatal() * show candidates always * show connected status and connection attempts
Diffstat (limited to 'collectors/plugins.d')
-rw-r--r--collectors/plugins.d/plugins_d.c24
-rw-r--r--collectors/plugins.d/pluginsd_parser.c32
2 files changed, 28 insertions, 28 deletions
diff --git a/collectors/plugins.d/plugins_d.c b/collectors/plugins.d/plugins_d.c
index da5226a5c8..d6605602f4 100644
--- a/collectors/plugins.d/plugins_d.c
+++ b/collectors/plugins.d/plugins_d.c
@@ -22,28 +22,28 @@ inline size_t pluginsd_initialize_plugin_directories()
}
static inline void plugin_set_disabled(struct plugind *cd) {
- netdata_spinlock_lock(&cd->unsafe.spinlock);
+ spinlock_lock(&cd->unsafe.spinlock);
cd->unsafe.enabled = false;
- netdata_spinlock_unlock(&cd->unsafe.spinlock);
+ spinlock_unlock(&cd->unsafe.spinlock);
}
bool plugin_is_enabled(struct plugind *cd) {
- netdata_spinlock_lock(&cd->unsafe.spinlock);
+ spinlock_lock(&cd->unsafe.spinlock);
bool ret = cd->unsafe.enabled;
- netdata_spinlock_unlock(&cd->unsafe.spinlock);
+ spinlock_unlock(&cd->unsafe.spinlock);
return ret;
}
static inline void plugin_set_running(struct plugind *cd) {
- netdata_spinlock_lock(&cd->unsafe.spinlock);
+ spinlock_lock(&cd->unsafe.spinlock);
cd->unsafe.running = true;
- netdata_spinlock_unlock(&cd->unsafe.spinlock);
+ spinlock_unlock(&cd->unsafe.spinlock);
}
static inline bool plugin_is_running(struct plugind *cd) {
- netdata_spinlock_lock(&cd->unsafe.spinlock);
+ spinlock_lock(&cd->unsafe.spinlock);
bool ret = cd->unsafe.running;
- netdata_spinlock_unlock(&cd->unsafe.spinlock);
+ spinlock_unlock(&cd->unsafe.spinlock);
return ret;
}
@@ -53,7 +53,7 @@ static void pluginsd_worker_thread_cleanup(void *arg)
worker_unregister();
- netdata_spinlock_lock(&cd->unsafe.spinlock);
+ spinlock_lock(&cd->unsafe.spinlock);
cd->unsafe.running = false;
cd->unsafe.thread = 0;
@@ -61,7 +61,7 @@ static void pluginsd_worker_thread_cleanup(void *arg)
pid_t pid = cd->unsafe.pid;
cd->unsafe.pid = 0;
- netdata_spinlock_unlock(&cd->unsafe.spinlock);
+ spinlock_unlock(&cd->unsafe.spinlock);
if (pid) {
siginfo_t info;
@@ -190,14 +190,14 @@ static void pluginsd_main_cleanup(void *data) {
struct plugind *cd;
for (cd = pluginsd_root; cd; cd = cd->next) {
- netdata_spinlock_lock(&cd->unsafe.spinlock);
+ spinlock_lock(&cd->unsafe.spinlock);
if (cd->unsafe.enabled && cd->unsafe.running && cd->unsafe.thread != 0) {
info("PLUGINSD: 'host:%s', stopping plugin thread: %s",
rrdhost_hostname(cd->host), cd->id);
netdata_thread_cancel(cd->unsafe.thread);
}
- netdata_spinlock_unlock(&cd->unsafe.spinlock);
+ spinlock_unlock(&cd->unsafe.spinlock);
}
info("PLUGINSD: cleanup completed.");
diff --git a/collectors/plugins.d/pluginsd_parser.c b/collectors/plugins.d/pluginsd_parser.c
index 1bca604b4f..b5356b33dc 100644
--- a/collectors/plugins.d/pluginsd_parser.c
+++ b/collectors/plugins.d/pluginsd_parser.c
@@ -11,7 +11,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
return 0;
errno = 0;
- netdata_spinlock_lock(&parser->writer.spinlock);
+ spinlock_lock(&parser->writer.spinlock);
ssize_t bytes = -1;
#ifdef ENABLE_HTTPS
@@ -24,7 +24,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
else
error("PLUGINSD: cannot send command (SSL)");
- netdata_spinlock_unlock(&parser->writer.spinlock);
+ spinlock_unlock(&parser->writer.spinlock);
return bytes;
}
#endif
@@ -39,7 +39,7 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
else
fflush(parser->fp_output);
- netdata_spinlock_unlock(&parser->writer.spinlock);
+ spinlock_unlock(&parser->writer.spinlock);
return bytes;
}
@@ -52,18 +52,18 @@ static ssize_t send_to_plugin(const char *txt, void *data) {
sent = write(parser->fd, &txt[bytes], total - bytes);
if(sent <= 0) {
error("PLUGINSD: cannot send command (fd)");
- netdata_spinlock_unlock(&parser->writer.spinlock);
+ spinlock_unlock(&parser->writer.spinlock);
return -3;
}
bytes += sent;
}
while(bytes < total);
- netdata_spinlock_unlock(&parser->writer.spinlock);
+ spinlock_unlock(&parser->writer.spinlock);
return (int)bytes;
}
- netdata_spinlock_unlock(&parser->writer.spinlock);
+ spinlock_unlock(&parser->writer.spinlock);
error("PLUGINSD: cannot send command (no output socket/pipe/file given to plugins.d parser)");
return -4;
}
@@ -93,7 +93,7 @@ static inline RRDSET *pluginsd_get_chart_from_parent(void *user) {
static inline void pluginsd_lock_rrdset_data_collection(void *user) {
PARSER_USER_OBJECT *u = (PARSER_USER_OBJECT *) user;
if(u->st && !u->v2.locked_data_collection) {
- netdata_spinlock_lock(&u->st->data_collection_lock);
+ spinlock_lock(&u->st->data_collection_lock);
u->v2.locked_data_collection = true;
}
}
@@ -101,7 +101,7 @@ static inline void pluginsd_lock_rrdset_data_collection(void *user) {
static inline bool pluginsd_unlock_rrdset_data_collection(void *user) {
PARSER_USER_OBJECT *u = (PARSER_USER_OBJECT *) user;
if(u->st && u->v2.locked_data_collection) {
- netdata_spinlock_unlock(&u->st->data_collection_lock);
+ spinlock_unlock(&u->st->data_collection_lock);
u->v2.locked_data_collection = false;
return true;
}
@@ -1233,9 +1233,9 @@ PARSER_RC pluginsd_replay_begin(char **words, size_t num_words, void *user) {
st->counter_done++;
// these are only needed for db mode RAM, SAVE, MAP, ALLOC
- st->current_entry++;
- if(st->current_entry >= st->entries)
- st->current_entry -= st->entries;
+ st->db.current_entry++;
+ if(st->db.current_entry >= st->db.entries)
+ st->db.current_entry -= st->db.entries;
((PARSER_USER_OBJECT *) user)->replay.start_time = start_time;
((PARSER_USER_OBJECT *) user)->replay.end_time = end_time;
@@ -1660,9 +1660,9 @@ PARSER_RC pluginsd_begin_v2(char **words, size_t num_words, void *user) {
st->counter_done++;
// these are only needed for db mode RAM, SAVE, MAP, ALLOC
- st->current_entry++;
- if(st->current_entry >= st->entries)
- st->current_entry -= st->entries;
+ st->db.current_entry++;
+ if(st->db.current_entry >= st->db.entries)
+ st->db.current_entry -= st->db.entries;
timing_step(TIMING_STEP_BEGIN2_STORE);
@@ -1774,7 +1774,7 @@ PARSER_RC pluginsd_set_v2(char **words, size_t num_words, void *user) {
rd->last_stored_value = value;
rd->last_calculated_value = value;
rd->collections_counter++;
- rd->updated = true;
+ rrddim_set_updated(rd);
timing_step(TIMING_STEP_SET2_STORE);
@@ -1831,7 +1831,7 @@ PARSER_RC pluginsd_end_v2(char **words __maybe_unused, size_t num_words __maybe_
rrddim_foreach_read(rd, st) {
rd->calculated_value = 0;
rd->collected_value = 0;
- rd->updated = false;
+ rrddim_clear_updated(rd);
}
rrddim_foreach_done(rd);