summaryrefslogtreecommitdiffstats
path: root/libnetdata/dictionary
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2022-09-06 19:02:39 +0300
committerGitHub <noreply@github.com>2022-09-06 19:02:39 +0300
commit58c79fd329df7d2187e4aee56fb4a58a9c02c3ae (patch)
treeb48bde3c183e1fa7b164e35a12e5ad87c73e001e /libnetdata/dictionary
parent64a6920038d5f185710154790ff49e4913caac83 (diff)
Faster rrdcontext (#13629)
* moved rrdcontexts processing to worker thread * added loggings * check for aclk deeper in the code * removed unessesary logs * code re-organization; cleanup; more comments; better error handling; rrdcontext locks optimization; more clarity * updated 2 comments * make instances walkthrough reentrant; move context lock to the place is really needed * created macro for reentrant dictionary walkthrough * incremental updates on instances and metrics * renamed family of rrdcontext workers * prevent crash in case RRDINSTANCE or RRDMETRIC is freed during shutdown * prevent crash during rrddim save, on out of memory fatal() * always post-process contexts * added tracing for tracking the caller that trigger updates * more details on tracing info * fix for charts that are collected without metrics
Diffstat (limited to 'libnetdata/dictionary')
-rw-r--r--libnetdata/dictionary/dictionary.c9
-rw-r--r--libnetdata/dictionary/dictionary.h3
2 files changed, 11 insertions, 1 deletions
diff --git a/libnetdata/dictionary/dictionary.c b/libnetdata/dictionary/dictionary.c
index 6e37554ea4..4af2c391a3 100644
--- a/libnetdata/dictionary/dictionary.c
+++ b/libnetdata/dictionary/dictionary.c
@@ -121,30 +121,39 @@ void dictionary_register_react_callback(DICTIONARY *dict, void (*react_callback)
// dictionary statistics maintenance
long int dictionary_stats_allocated_memory(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->memory;
}
long int dictionary_stats_entries(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->entries;
}
size_t dictionary_stats_version(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->version;
}
size_t dictionary_stats_searches(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->searches;
}
size_t dictionary_stats_inserts(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->inserts;
}
size_t dictionary_stats_deletes(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->deletes;
}
size_t dictionary_stats_resets(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->resets;
}
size_t dictionary_stats_walkthroughs(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return dict->walkthroughs;
}
size_t dictionary_stats_referenced_items(DICTIONARY *dict) {
+ if(unlikely(!dict)) return 0;
return __atomic_load_n(&dict->referenced_items, __ATOMIC_SEQ_CST);
}
diff --git a/libnetdata/dictionary/dictionary.h b/libnetdata/dictionary/dictionary.h
index 9c2ea72e41..3cda4baf8e 100644
--- a/libnetdata/dictionary/dictionary.h
+++ b/libnetdata/dictionary/dictionary.h
@@ -198,10 +198,11 @@ typedef DICTFE_CONST struct dictionary_foreach {
#define dfe_start_read(dict, value) dfe_start_rw(dict, value, DICTIONARY_LOCK_READ)
#define dfe_start_write(dict, value) dfe_start_rw(dict, value, DICTIONARY_LOCK_WRITE)
+#define dfe_start_reentrant(dict, value) dfe_start_rw(dict, value, DICTIONARY_LOCK_REENTRANT)
#define dfe_start_rw(dict, value, mode) \
do { \
DICTFE value ## _dfe = {}; \
- const char *value ## _name; (void)(value ## _name); (void)value; \
+ const char *value ## _name; (void)(value ## _name); (void)(value); \
for((value) = dictionary_foreach_start_rw(&value ## _dfe, (dict), (mode)), ( value ## _name ) = value ## _dfe.name; \
(value ## _dfe.name) ;\
(value) = dictionary_foreach_next(&value ## _dfe), ( value ## _name ) = value ## _dfe.name) \