summaryrefslogtreecommitdiffstats
path: root/libnetdata/config
diff options
context:
space:
mode:
authorMarkos Fountoulakis <44345837+mfundul@users.noreply.github.com>2020-03-16 13:39:00 +0200
committerGitHub <noreply@github.com>2020-03-16 13:39:00 +0200
commit161ba1592f5412bd378ace104979ddb66cd33973 (patch)
tree3d278844c5a94b67661312f7138516d725ea6e0e /libnetdata/config
parent87fd050461eac9e69f78a075ed896a1eaeabcd04 (diff)
Fix streaming scaling (#8375)
* Disallow multiple streaming connections to the same master agent * Reject multiple streaming connections quickly without blocking * Increase timeout for systemd service shutdown to give time to flush the db. * Optimize page correlation ID to use atomic counter instead of locks * Reduce contention in global configuration mutex * Optimize complexity of inserting configuration sections from O(N) to O(1) * Reduce overhead of clockgettime() by utilizing CLOCK_MONOTONIC_COARSE when applicable. * Fix unit test compile errors
Diffstat (limited to 'libnetdata/config')
-rw-r--r--libnetdata/config/appconfig.c9
-rw-r--r--libnetdata/config/appconfig.h3
2 files changed, 7 insertions, 5 deletions
diff --git a/libnetdata/config/appconfig.c b/libnetdata/config/appconfig.c
index c77cf34ec3..2fb21f1837 100644
--- a/libnetdata/config/appconfig.c
+++ b/libnetdata/config/appconfig.c
@@ -169,12 +169,13 @@ static inline struct section *appconfig_section_create(struct config *root, cons
error("INTERNAL ERROR: indexing of section '%s', already exists.", co->name);
appconfig_wrlock(root);
- struct section *co2 = root->sections;
+ struct section *co2 = root->last_section;
if(co2) {
- while (co2->next) co2 = co2->next;
co2->next = co;
+ } else {
+ root->first_section = co;
}
- else root->sections = co;
+ root->last_section = co;
appconfig_unlock(root);
return co;
@@ -678,7 +679,7 @@ void appconfig_generate(struct config *root, BUFFER *wb, int only_changed)
}
appconfig_wrlock(root);
- for(co = root->sections; co ; co = co->next) {
+ for(co = root->first_section; co ; co = co->next) {
if(!strcmp(co->name, CONFIG_SECTION_GLOBAL)
|| !strcmp(co->name, CONFIG_SECTION_WEB)
|| !strcmp(co->name, CONFIG_SECTION_STATSD)
diff --git a/libnetdata/config/appconfig.h b/libnetdata/config/appconfig.h
index 4688760514..d448205b63 100644
--- a/libnetdata/config/appconfig.h
+++ b/libnetdata/config/appconfig.h
@@ -141,7 +141,8 @@ struct section {
};
struct config {
- struct section *sections;
+ struct section *first_section;
+ struct section *last_section; // optimize inserting at the end
netdata_mutex_t mutex;
avl_tree_lock index;
};