]> arthur.barton.de Git - netdata.git/commitdiff
disabled dictionary statistics to save memory
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 19 May 2016 20:39:17 +0000 (23:39 +0300)
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>
Thu, 19 May 2016 20:39:17 +0000 (23:39 +0300)
src/dictionary.c
src/dictionary.h

index 1543f4d0e7334bce5ad63e2b5469e5b47b0dffb8..d3576412b5dc1264a1068db2eeb1c1adca7a0542 100644 (file)
@@ -46,15 +46,15 @@ static int name_value_compare(void* a, void* b) {
        else return strcmp(((NAME_VALUE *)a)->name, ((NAME_VALUE *)b)->name);
 }
 
-#define dictionary_name_value_index_add_nolock(dict, nv) do { (dict)->inserts++; avl_insert(&((dict)->values_index), (avl *)(nv)); } while(0)
-#define dictionary_name_value_index_del_nolock(dict, nv) do { (dict)->deletes++; avl_remove(&(dict->values_index), (avl *)(nv)); } while(0)
+#define dictionary_name_value_index_add_nolock(dict, nv) do { NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict); avl_insert(&((dict)->values_index), (avl *)(nv)); } while(0)
+#define dictionary_name_value_index_del_nolock(dict, nv) do { NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict); avl_remove(&(dict->values_index), (avl *)(nv)); } while(0)
 
 static inline NAME_VALUE *dictionary_name_value_index_find_nolock(DICTIONARY *dict, const char *name, uint32_t hash) {
        NAME_VALUE tmp;
        tmp.hash = (hash)?hash:simple_hash(name);
        tmp.name = (char *)name;
 
-       dict->searches++;
+       NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict);
        return (NAME_VALUE *)avl_search(&(dict->values_index), (avl *) &tmp);
 }
 
@@ -89,7 +89,7 @@ static NAME_VALUE *dictionary_name_value_create_nolock(DICTIONARY *dict, const c
 
        // index it
        dictionary_name_value_index_add_nolock(dict, nv);
-       dict->entries++;
+       NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict);
 
        return nv;
 }
@@ -99,7 +99,7 @@ static void dictionary_name_value_destroy_nolock(DICTIONARY *dict, NAME_VALUE *n
 
        dictionary_name_value_index_del_nolock(dict, nv);
 
-       dict->entries--;
+       NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict);
 
        if(!(dict->flags & DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE)) {
                debug(D_REGISTRY, "Dictionary freeing value of '%s'", nv->name);
index 575f2827105c443644bfe6349769383bab58db47..fe44d8146093f3c3e2fe0dc472b04880b14bbce1 100644 (file)
@@ -21,14 +21,30 @@ typedef struct dictionary {
 
        uint8_t flags;
 
+#ifdef NETDATA_DICTIONARY_WITH_STATISTICS
        unsigned long long inserts;
        unsigned long long deletes;
        unsigned long long searches;
        unsigned long long entries;
+#endif /* NETDATA_DICTIONARY_WITH_STATISTICS */
 
        pthread_rwlock_t rwlock;
 } DICTIONARY;
 
+#ifdef NETDATA_DICTIONARY_WITH_STATISTICS
+#define NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict) (dict)->inserts++
+#define NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict) (dict)->deletes++
+#define NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict) (dict)->searches++
+#define NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict) (dict)->entries++
+#define NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict) (dict)->entries--
+#else /* NETDATA_DICTIONARY_WITH_STATISTICS */
+#define NETDATA_DICTIONARY_STATS_INSERTS_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_DELETES_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_SEARCHES_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_ENTRIES_PLUS1(dict)
+#define NETDATA_DICTIONARY_STATS_ENTRIES_MINUS1(dict)
+#endif /* NETDATA_DICTIONARY_WITH_STATISTICS */
+
 #define DICTIONARY_FLAG_DEFAULT                                        0x00000000
 #define DICTIONARY_FLAG_SINGLE_THREADED                        0x00000001
 #define DICTIONARY_FLAG_VALUE_LINK_DONT_CLONE  0x00000002