summaryrefslogtreecommitdiffstats
path: root/registry/registry_machine.c
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2022-06-01 20:01:52 +0300
committerGitHub <noreply@github.com>2022-06-01 20:01:52 +0300
commit7784a16cc7af8260bb8877873a60d7dc6d2c9e73 (patch)
tree28964e18f97bfee01977240981fb53333f95bc7e /registry/registry_machine.c
parentc261a771cc0c93fe4e9fbb83e1be141406d314be (diff)
Dictionary with JudyHS and double linked list (#13032)
* dictionary internals isolation * more dictionary cleanups * added unit test * we should use DICT internally * disable cups in cmake * implement DICTIONARY with Judy arrays * operational JUDY implementation * JUDY cleanup * JUDY summary added * JudyHS implementation with double linked list * test negative searches too * optimize destruction * optimize set to insert first without lookup * updated stats * code cleanup; better organization; updated info * more code cleanup and commenting * more cleanup, renames and comments * fix rename * more cleanups * use Judy.h from system paths * added foreach traversal; added flag to add item in front; isolated locks to their own functions; destruction returns the number of bytes freed * more comments; flags are now 16-bit * completed unittesting * addressed comments and added reference counters maintainance * added unittest in main; tested removal of items in front, back and middle * added read/write walkthrough and foreach; allowed walkthrough and foreach in write mode to delete the current element (used by cups.plugin); referenced counters removed from the API * DICTFE.name should be const too * added API calls for exposing all statistics * dictionary flags as enum and reference counters as atomic operations * more comments; improved error handling at unit tests * added functions to allow unsafe access while traversing the dictionary with locks in place * check for libcups in cmake * added delete callback; implemented statsd with this dictionary * added missing dfe_done() * added alternative implementation with AVL * added documentation * added comments and warning about AVL * dictionary walktrhough on new code * simplified foreach; updated docs * updated docs * AVL is much faster without hashes * AVL should follow DBENGINE
Diffstat (limited to 'registry/registry_machine.c')
-rw-r--r--registry/registry_machine.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/registry/registry_machine.c b/registry/registry_machine.c
index bd1d243a01..fb345aea22 100644
--- a/registry/registry_machine.c
+++ b/registry/registry_machine.c
@@ -24,7 +24,10 @@ REGISTRY_MACHINE_URL *registry_machine_url_allocate(REGISTRY_MACHINE *m, REGISTR
registry.machines_urls_memory += sizeof(REGISTRY_MACHINE_URL);
debug(D_REGISTRY, "registry_machine_url_allocate('%s', '%s'): indexing URL in machine", m->guid, u->url);
+
+ registry.machines_urls_memory -= dictionary_stats_allocated_memory(m->machine_urls);
dictionary_set(m->machine_urls, u->url, mu, sizeof(REGISTRY_MACHINE_URL));
+ registry.machines_urls_memory += dictionary_stats_allocated_memory(m->machine_urls);
registry_url_link(u);
@@ -39,15 +42,17 @@ REGISTRY_MACHINE *registry_machine_allocate(const char *machine_guid, time_t whe
strncpyz(m->guid, machine_guid, GUID_LEN);
debug(D_REGISTRY, "Registry: registry_machine_allocate('%s'): creating dictionary of urls", machine_guid);
- m->machine_urls = dictionary_create(DICTIONARY_FLAGS);
+ m->machine_urls = dictionary_create(REGISTRY_DICTIONARY_FLAGS);
m->first_t = m->last_t = (uint32_t)when;
m->usages = 0;
registry.machines_memory += sizeof(REGISTRY_MACHINE);
-
registry.machines_count++;
+
+ registry.machines_urls_memory -= dictionary_stats_allocated_memory(m->machine_urls);
dictionary_set(registry.machines, m->guid, m, sizeof(REGISTRY_MACHINE));
+ registry.machines_urls_memory += dictionary_stats_allocated_memory(m->machine_urls);
return m;
}