@cryptotaxi247 / netdata-1 / commits / a88c968b9

Revert "Optimizations Part 2" (#15279)

Revert "Optimizations Part 2 (#15267)" This reverts commit b52a989497f68cddeeb0282f5fd650c4e373e477.

Costa Tsaousis committed Jun 29, 2023 at 01:06 UTC a88c968b9c53f477193b1e17570c6c79639beba4
9 files changed +190 -272
collectors/plugins.d/gperf-config.txt
+29 -38
@@ -1,52 +1,43 @@
1 -%struct-type
2 -%omit-struct-type
3 -%define hash-function-name gperf_keyword_hash_function
4 -%define lookup-function-name gperf_lookup_keyword
5 -%define word-array-name gperf_keywords
6 -%define constants-prefix GPERF_PARSER_
7 -%define slot-name keyword
8 -%global-table
9 -%null-strings
1 PARSER_KEYWORD;
2 %%
3 #
4 # Plugins Only Keywords
5 #
15 -FLUSH, 97, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 1
16 -DISABLE, 98, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 2
17 -EXIT, 99, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 3
18 -HOST, 71, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 4
19 -HOST_DEFINE, 72, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 5
20 -HOST_DEFINE_END, 73, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 6
21 -HOST_LABEL, 74, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 7
6 +FLUSH, pluginsd_flush, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 1
7 +DISABLE, pluginsd_disable, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 2
8 +EXIT, pluginsd_exit, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 3
9 +HOST, pluginsd_host, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 4
10 +HOST_DEFINE, pluginsd_host_define, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 5
11 +HOST_DEFINE_END, pluginsd_host_define_end, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 6
12 +HOST_LABEL, pluginsd_host_labels, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 7
13 #
14 # Common keywords
15 #
25 -BEGIN, 12, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 8
26 -CHART, 32, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 9
27 -CLABEL, 34, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 10
28 -CLABEL_COMMIT, 35, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 11
29 -DIMENSION, 31, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 12
30 -END, 13, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 13
31 -FUNCTION, 41, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 14
32 -FUNCTION_RESULT_BEGIN, 42, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 15
33 -LABEL, 51, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 16
34 -OVERWRITE, 52, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 17
35 -SET, 11, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 18
36 -VARIABLE, 53, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 19
16 +BEGIN, pluginsd_begin, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 8
17 +CHART, pluginsd_chart, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 9
18 +CLABEL, pluginsd_clabel, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 10
19 +CLABEL_COMMIT, pluginsd_clabel_commit, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 11
20 +DIMENSION, pluginsd_dimension, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 12
21 +END, pluginsd_end, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 13
22 +FUNCTION, pluginsd_function, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 14
23 +FUNCTION_RESULT_BEGIN, pluginsd_function_result_begin, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 15
24 +LABEL, pluginsd_label, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 16
25 +OVERWRITE, pluginsd_overwrite, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 17
26 +SET, pluginsd_set, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 18
27 +VARIABLE, pluginsd_variable, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 19
28 #
29 # Streaming only keywords
30 #
40 -CLAIMED_ID, 61, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 20
41 -BEGIN2, 2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 21
42 -SET2, 1, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 22
43 -END2, 3, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 23
31 +CLAIMED_ID, streaming_claimed_id, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 20
32 +BEGIN2, pluginsd_begin_v2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 21
33 +SET2, pluginsd_set_v2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 22
34 +END2, pluginsd_end_v2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 23
35 #
36 # Streaming Replication keywords
37 #
47 -CHART_DEFINITION_END, 33, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 24
48 -RBEGIN, 22, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 25
49 -RDSTATE, 23, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 26
50 -REND, 25, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 27
51 -RSET, 21, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 28
52 -RSSTATE, 24, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 29
38 +CHART_DEFINITION_END, pluginsd_chart_definition_end, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 24
39 +RBEGIN, pluginsd_replay_begin, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 25
40 +RDSTATE, pluginsd_replay_rrddim_collection_state, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 26
41 +REND, pluginsd_replay_end, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 27
42 +RSET, pluginsd_replay_set, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 28
43 +RSSTATE, pluginsd_replay_rrdset_collection_state, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 29
collectors/plugins.d/gperf-hashtable.h
+56 -55
@@ -1,5 +1,6 @@
1 +// SPDX-License-Identifier: GPL-3.0-or-later
2 /* ANSI-C code produced by gperf version 3.1 */
2 -/* Command-line: gperf --multiple-iterations=1000 --output-file=gperf-hashtable.h gperf-config.txt */
3 +/* Command-line: gperf --multiple-iterations=1000 --hash-function-name=gperf_keyword_hash_function --lookup-function-name=gperf_lookup_keyword --word-array-name=gperf_keywords --constants-prefix=GPERF_PARSER_ --struct-type --slot-name=keyword --global-table --null-strings --omit-struct-type --output-file=gperf-hashtable.h gperf-config.txt */
4 /* Computed positions: -k'1-2' */
5
6 #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -82,66 +83,66 @@ gperf_keyword_hash_function (register const char *str, register size_t len)
83 static PARSER_KEYWORD gperf_keywords[] =
84 {
85 {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
85 -#line 18 "gperf-config.txt"
86 - {"HOST", 71, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 4},
87 -#line 51 "gperf-config.txt"
88 - {"RSET", 21, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 28},
89 -#line 26 "gperf-config.txt"
90 - {"CHART", 32, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 9},
91 - {(char*)0},
92 -#line 52 "gperf-config.txt"
93 - {"RSSTATE", 24, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 29},
94 -#line 49 "gperf-config.txt"
95 - {"RDSTATE", 23, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 26},
96 -#line 21 "gperf-config.txt"
97 - {"HOST_LABEL", 74, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 7},
98 -#line 19 "gperf-config.txt"
99 - {"HOST_DEFINE", 72, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 5},
100 -#line 35 "gperf-config.txt"
101 - {"SET", 11, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 18},
86 +#line 9 "gperf-config.txt"
87 + {"HOST", pluginsd_host, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 4},
88 #line 42 "gperf-config.txt"
103 - {"SET2", 1, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 22},
104 -#line 50 "gperf-config.txt"
105 - {"REND", 25, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 27},
106 -#line 20 "gperf-config.txt"
107 - {"HOST_DEFINE_END", 73, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 6},
108 -#line 27 "gperf-config.txt"
109 - {"CLABEL", 34, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 10},
110 -#line 48 "gperf-config.txt"
111 - {"RBEGIN", 22, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 25},
112 -#line 15 "gperf-config.txt"
113 - {"FLUSH", 97, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 1},
114 -#line 31 "gperf-config.txt"
115 - {"FUNCTION", 41, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 14},
89 + {"RSET", pluginsd_replay_set, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 28},
90 +#line 17 "gperf-config.txt"
91 + {"CHART", pluginsd_chart, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 9},
92 + {(char*)0},
93 +#line 43 "gperf-config.txt"
94 + {"RSSTATE", pluginsd_replay_rrdset_collection_state, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 29},
95 #line 40 "gperf-config.txt"
117 - {"CLAIMED_ID", 61, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 20},
118 -#line 47 "gperf-config.txt"
119 - {"CHART_DEFINITION_END", 33, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 24},
120 -#line 34 "gperf-config.txt"
121 - {"OVERWRITE", 52, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 17},
122 -#line 28 "gperf-config.txt"
123 - {"CLABEL_COMMIT", 35, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 11},
124 -#line 25 "gperf-config.txt"
125 - {"BEGIN", 12, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 8},
96 + {"RDSTATE", pluginsd_replay_rrddim_collection_state, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 26},
97 +#line 12 "gperf-config.txt"
98 + {"HOST_LABEL", pluginsd_host_labels, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 7},
99 +#line 10 "gperf-config.txt"
100 + {"HOST_DEFINE", pluginsd_host_define, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 5},
101 +#line 26 "gperf-config.txt"
102 + {"SET", pluginsd_set, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 18},
103 +#line 33 "gperf-config.txt"
104 + {"SET2", pluginsd_set_v2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 22},
105 #line 41 "gperf-config.txt"
127 - {"BEGIN2", 2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 21},
128 -#line 30 "gperf-config.txt"
129 - {"END", 13, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 13},
130 -#line 43 "gperf-config.txt"
131 - {"END2", 3, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 23},
106 + {"REND", pluginsd_replay_end, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 27},
107 +#line 11 "gperf-config.txt"
108 + {"HOST_DEFINE_END", pluginsd_host_define_end, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 6},
109 +#line 18 "gperf-config.txt"
110 + {"CLABEL", pluginsd_clabel, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 10},
111 +#line 39 "gperf-config.txt"
112 + {"RBEGIN", pluginsd_replay_begin, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 25},
113 +#line 6 "gperf-config.txt"
114 + {"FLUSH", pluginsd_flush, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 1},
115 +#line 22 "gperf-config.txt"
116 + {"FUNCTION", pluginsd_function, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 14},
117 +#line 31 "gperf-config.txt"
118 + {"CLAIMED_ID", streaming_claimed_id, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 20},
119 +#line 38 "gperf-config.txt"
120 + {"CHART_DEFINITION_END", pluginsd_chart_definition_end, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 24},
121 +#line 25 "gperf-config.txt"
122 + {"OVERWRITE", pluginsd_overwrite, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 17},
123 +#line 19 "gperf-config.txt"
124 + {"CLABEL_COMMIT", pluginsd_clabel_commit, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 11},
125 #line 16 "gperf-config.txt"
133 - {"DISABLE", 98, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 2},
134 -#line 33 "gperf-config.txt"
135 - {"LABEL", 51, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 16},
136 -#line 29 "gperf-config.txt"
137 - {"DIMENSION", 31, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 12},
138 -#line 17 "gperf-config.txt"
139 - {"EXIT", 99, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 3},
126 + {"BEGIN", pluginsd_begin, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 8},
127 #line 32 "gperf-config.txt"
141 - {"FUNCTION_RESULT_BEGIN", 42, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 15},
128 + {"BEGIN2", pluginsd_begin_v2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 21},
129 +#line 21 "gperf-config.txt"
130 + {"END", pluginsd_end, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 13},
131 +#line 34 "gperf-config.txt"
132 + {"END2", pluginsd_end_v2, PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 23},
133 +#line 7 "gperf-config.txt"
134 + {"DISABLE", pluginsd_disable, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 2},
135 +#line 24 "gperf-config.txt"
136 + {"LABEL", pluginsd_label, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 16},
137 +#line 20 "gperf-config.txt"
138 + {"DIMENSION", pluginsd_dimension, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 12},
139 +#line 8 "gperf-config.txt"
140 + {"EXIT", pluginsd_exit, PARSER_INIT_PLUGINSD, WORKER_PARSER_FIRST_JOB + 3},
141 +#line 23 "gperf-config.txt"
142 + {"FUNCTION_RESULT_BEGIN", pluginsd_function_result_begin, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 15},
143 {(char*)0}, {(char*)0}, {(char*)0},
143 -#line 36 "gperf-config.txt"
144 - {"VARIABLE", 53, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 19}
144 +#line 27 "gperf-config.txt"
145 + {"VARIABLE", pluginsd_variable, PARSER_INIT_PLUGINSD|PARSER_INIT_STREAMING, WORKER_PARSER_FIRST_JOB + 19}
146 };
147
148 PARSER_KEYWORD *
collectors/plugins.d/pluginsd_parser.c
-94
@@ -2026,100 +2026,6 @@ PARSER *parser_init(struct parser_user_object *user, FILE *fp_input, FILE *fp_ou
2026 return parser;
2027 }
2028
2029 -PARSER_RC parser_execute(PARSER *parser, PARSER_KEYWORD *keyword, char **words, size_t num_words) {
2030 - switch(keyword->id) {
2031 - case 1:
2032 - return pluginsd_set_v2(words, num_words, parser);
2033 -
2034 - case 2:
2035 - return pluginsd_begin_v2(words, num_words, parser);
2036 -
2037 - case 3:
2038 - return pluginsd_end_v2(words, num_words, parser);
2039 -
2040 - case 11:
2041 - return pluginsd_set(words, num_words, parser);
2042 -
2043 - case 12:
2044 - return pluginsd_begin(words, num_words, parser);
2045 -
2046 - case 13:
2047 - return pluginsd_end(words, num_words, parser);
2048 -
2049 - case 21:
2050 - return pluginsd_replay_set(words, num_words, parser);
2051 -
2052 - case 22:
2053 - return pluginsd_replay_begin(words, num_words, parser);
2054 -
2055 - case 23:
2056 - return pluginsd_replay_rrddim_collection_state(words, num_words, parser);
2057 -
2058 - case 24:
2059 - return pluginsd_replay_rrdset_collection_state(words, num_words, parser);
2060 -
2061 - case 25:
2062 - return pluginsd_replay_end(words, num_words, parser);
2063 -
2064 - case 31:
2065 - return pluginsd_dimension(words, num_words, parser);
2066 -
2067 - case 32:
2068 - return pluginsd_chart(words, num_words, parser);
2069 -
2070 - case 33:
2071 - return pluginsd_chart_definition_end(words, num_words, parser);
2072 -
2073 - case 34:
2074 - return pluginsd_clabel(words, num_words, parser);
2075 -
2076 - case 35:
2077 - return pluginsd_clabel_commit(words, num_words, parser);
2078 -
2079 - case 41:
2080 - return pluginsd_function(words, num_words, parser);
2081 -
2082 - case 42:
2083 - return pluginsd_function_result_begin(words, num_words, parser);
2084 -
2085 - case 51:
2086 - return pluginsd_label(words, num_words, parser);
2087 -
2088 - case 52:
2089 - return pluginsd_overwrite(words, num_words, parser);
2090 -
2091 - case 53:
2092 - return pluginsd_variable(words, num_words, parser);
2093 -
2094 - case 61:
2095 - return streaming_claimed_id(words, num_words, parser);
2096 -
2097 - case 71:
2098 - return pluginsd_host(words, num_words, parser);
2099 -
2100 - case 72:
2101 - return pluginsd_host_define(words, num_words, parser);
2102 -
2103 - case 73:
2104 - return pluginsd_host_define_end(words, num_words, parser);
2105 -
2106 - case 74:
2107 - return pluginsd_host_labels(words, num_words, parser);
2108 -
2109 - case 97:
2110 - return pluginsd_flush(words, num_words, parser);
2111 -
2112 - case 98:
2113 - return pluginsd_disable(words, num_words, parser);
2114 -
2115 - case 99:
2116 - return pluginsd_exit(words, num_words, parser);
2117 -
2118 - default:
2119 - fatal("Unknown keyword '%s' with id %zu", keyword->keyword, keyword->id);
2120 - }
2121 -}
2122 -
2029 #include "gperf-hashtable.h"
2030
2031 void parser_init_repertoire(PARSER *parser, PARSER_REPERTOIRE repertoire) {
collectors/plugins.d/pluginsd_parser.h
+9 -11
@@ -32,7 +32,7 @@ typedef PARSER_RC (*keyword_function)(char **words, size_t num_words, struct par
32
33 typedef struct parser_keyword {
34 char *keyword;
35 - size_t id;
35 + keyword_function func;
36 PARSER_REPERTOIRE repertoire;
37 size_t worker_job_id;
38 } PARSER_KEYWORD;
@@ -113,14 +113,6 @@ typedef struct parser {
113
114 } PARSER;
115
116 -PARSER *parser_init(struct parser_user_object *user, FILE *fp_input, FILE *fp_output, int fd, PARSER_INPUT_TYPE flags, void *ssl);
117 -void parser_init_repertoire(PARSER *parser, PARSER_REPERTOIRE repertoire);
118 -void parser_destroy(PARSER *working_parser);
119 -void pluginsd_cleanup_v2(PARSER *parser);
120 -void inflight_functions_init(PARSER *parser);
121 -void pluginsd_keywords_init(PARSER *parser, PARSER_REPERTOIRE repertoire);
122 -PARSER_RC parser_execute(PARSER *parser, PARSER_KEYWORD *keyword, char **words, size_t num_words);
123 -
116 static inline int find_first_keyword(const char *src, char *dst, int dst_size, bool *isspace_map) {
117 const char *s = src, *keyword_start;
118
@@ -189,8 +181,7 @@ static inline int parser_action(PARSER *parser, char *input) {
181 PARSER_KEYWORD *t = parser_find_keyword(parser, command);
182 if(likely(t)) {
183 worker_is_busy(t->worker_job_id);
192 - rc = parser_execute(parser, t, words, num_words);
193 - // rc = (*t->func)(words, num_words, parser);
184 + rc = (*t->func)(words, num_words, parser);
185 worker_is_idle();
186 }
187 else
@@ -216,4 +207,11 @@ static inline int parser_action(PARSER *parser, char *input) {
207 return (rc == PARSER_RC_ERROR || rc == PARSER_RC_STOP);
208 }
209
210 +PARSER *parser_init(struct parser_user_object *user, FILE *fp_input, FILE *fp_output, int fd, PARSER_INPUT_TYPE flags, void *ssl);
211 +void parser_init_repertoire(PARSER *parser, PARSER_REPERTOIRE repertoire);
212 +void parser_destroy(PARSER *working_parser);
213 +void pluginsd_cleanup_v2(PARSER *parser);
214 +void inflight_functions_init(PARSER *parser);
215 +void pluginsd_keywords_init(PARSER *parser, PARSER_REPERTOIRE repertoire);
216 +
217 #endif //NETDATA_PLUGINSD_PARSER_H
daemon/common.c
-3
@@ -58,9 +58,6 @@ long get_netdata_cpus(void) {
58
59 processors = cores_user_configured;
60
61 - if(processors < 1)
62 - processors = 1;
63 -
61 return processors;
62 }
63
database/engine/metric.c
+86 -61
@@ -28,16 +28,27 @@ struct metric {
28 static struct aral_statistics mrg_aral_statistics;
29
30 struct mrg {
31 - size_t partitions;
31 + ARAL *aral[MRG_PARTITIONS];
32
33 - struct mrg_partition {
34 - ARAL *aral; // not protected by our spinlock - it has its own
33 + struct pgc_index {
34 + MRG_CACHE_LINE_PADDING(0);
35
36 RW_SPINLOCK rw_spinlock;
37 - Pvoid_t uuid_judy; // JudyHS: each UUID has a JudyL of sections (tiers)
37 +
38 + MRG_CACHE_LINE_PADDING(1);
39 +
40 + Pvoid_t uuid_judy; // each UUID has a JudyL of sections (tiers)
41 +
42 + MRG_CACHE_LINE_PADDING(2);
43
44 struct mrg_statistics stats;
40 - } index[];
45 +
46 + MRG_CACHE_LINE_PADDING(3);
47 + } index[MRG_PARTITIONS];
48 +
49 +#ifdef NETDATA_INTERNAL_CHECKS
50 + size_t entries_per_partition[MRG_PARTITIONS];
51 +#endif
52 };
53
54 static inline void MRG_STATS_DUPLICATE_ADD(MRG *mrg, size_t partition) {
@@ -48,12 +59,20 @@ static inline void MRG_STATS_ADDED_METRIC(MRG *mrg, size_t partition) {
59 mrg->index[partition].stats.entries++;
60 mrg->index[partition].stats.additions++;
61 mrg->index[partition].stats.size += sizeof(METRIC);
62 +
63 +#ifdef NETDATA_INTERNAL_CHECKS
64 + __atomic_add_fetch(&mrg->entries_per_partition[partition], 1, __ATOMIC_RELAXED);
65 +#endif
66 }
67
68 static inline void MRG_STATS_DELETED_METRIC(MRG *mrg, size_t partition) {
69 mrg->index[partition].stats.entries--;
70 mrg->index[partition].stats.size -= sizeof(METRIC);
71 mrg->index[partition].stats.deletions++;
72 +
73 +#ifdef NETDATA_INTERNAL_CHECKS
74 + __atomic_sub_fetch(&mrg->entries_per_partition[partition], 1, __ATOMIC_RELAXED);
75 +#endif
76 }
77
78 static inline void MRG_STATS_SEARCH_HIT(MRG *mrg, size_t partition) {
@@ -68,13 +87,18 @@ static inline void MRG_STATS_DELETE_MISS(MRG *mrg, size_t partition) {
87 mrg->index[partition].stats.delete_misses++;
88 }
89
71 -#define mrg_index_read_lock(mrg, partition) rw_spinlock_read_lock(&(mrg)->index[partition].rw_spinlock)
72 -#define mrg_index_read_unlock(mrg, partition) rw_spinlock_read_unlock(&(mrg)->index[partition].rw_spinlock)
73 -#define mrg_index_write_lock(mrg, partition) rw_spinlock_write_lock(&(mrg)->index[partition].rw_spinlock)
74 -#define mrg_index_write_unlock(mrg, partition) rw_spinlock_write_unlock(&(mrg)->index[partition].rw_spinlock)
75 -
76 -#define metric_lock(metric) spinlock_lock(&(metric)->spinlock)
77 -#define metric_unlock(metric) spinlock_unlock(&(metric)->spinlock)
90 +static inline void mrg_index_read_lock(MRG *mrg, size_t partition) {
91 + rw_spinlock_read_lock(&mrg->index[partition].rw_spinlock);
92 +}
93 +static inline void mrg_index_read_unlock(MRG *mrg, size_t partition) {
94 + rw_spinlock_read_unlock(&mrg->index[partition].rw_spinlock);
95 +}
96 +static inline void mrg_index_write_lock(MRG *mrg, size_t partition) {
97 + rw_spinlock_write_lock(&mrg->index[partition].rw_spinlock);
98 +}
99 +static inline void mrg_index_write_unlock(MRG *mrg, size_t partition) {
100 + rw_spinlock_write_unlock(&mrg->index[partition].rw_spinlock);
101 +}
102
103 static inline void mrg_stats_size_judyl_change(MRG *mrg, size_t mem_before_judyl, size_t mem_after_judyl, size_t partition) {
104 if(mem_after_judyl > mem_before_judyl)
@@ -93,8 +117,7 @@ static inline void mrg_stats_size_judyhs_removed_uuid(MRG *mrg, size_t partition
117
118 static inline size_t uuid_partition(MRG *mrg __maybe_unused, uuid_t *uuid) {
119 uint8_t *u = (uint8_t *)uuid;
96 - size_t *n = (size_t *)&u[UUID_SZ - sizeof(size_t)];
97 - return *n % mrg->partitions;
120 + return u[UUID_SZ - 1] % MRG_PARTITIONS;
121 }
122
123 static inline bool metric_has_retention_unsafe(MRG *mrg __maybe_unused, METRIC *metric) {
@@ -119,7 +142,7 @@ static inline REFCOUNT metric_acquire(MRG *mrg __maybe_unused, METRIC *metric, b
142 REFCOUNT refcount;
143
144 if(!having_spinlock)
122 - metric_lock(metric);
145 + spinlock_lock(&metric->spinlock);
146
147 if(unlikely(metric->refcount < 0))
148 fatal("METRIC: refcount is %d (negative) during acquire", metric->refcount);
@@ -130,7 +153,7 @@ static inline REFCOUNT metric_acquire(MRG *mrg __maybe_unused, METRIC *metric, b
153 metric_has_retention_unsafe(mrg, metric);
154
155 if(!having_spinlock)
133 - metric_unlock(metric);
156 + spinlock_unlock(&metric->spinlock);
157
158 if(refcount == 1)
159 __atomic_add_fetch(&mrg->index[partition].stats.entries_referenced, 1, __ATOMIC_RELAXED);
@@ -145,7 +168,7 @@ static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, ME
168 size_t partition = metric->partition;
169 REFCOUNT refcount;
170
148 - metric_lock(metric);
171 + spinlock_lock(&metric->spinlock);
172
173 if(unlikely(metric->refcount <= 0))
174 fatal("METRIC: refcount is %d (zero or negative) during release", metric->refcount);
@@ -155,7 +178,7 @@ static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, ME
178 if(likely(metric_has_retention_unsafe(mrg, metric) || refcount != 0))
179 ret = false;
180
158 - metric_unlock(metric);
181 + spinlock_unlock(&metric->spinlock);
182
183 if(unlikely(!refcount))
184 __atomic_sub_fetch(&mrg->index[partition].stats.entries_referenced, 1, __ATOMIC_RELAXED);
@@ -168,7 +191,7 @@ static inline bool metric_release_and_can_be_deleted(MRG *mrg __maybe_unused, ME
191 static inline METRIC *metric_add_and_acquire(MRG *mrg, MRG_ENTRY *entry, bool *ret) {
192 size_t partition = uuid_partition(mrg, &entry->uuid);
193
171 - METRIC *allocation = aral_mallocz(mrg->index[partition].aral);
194 + METRIC *allocation = aral_mallocz(mrg->aral[partition]);
195
196 mrg_index_write_lock(mrg, partition);
197
@@ -201,7 +224,7 @@ static inline METRIC *metric_add_and_acquire(MRG *mrg, MRG_ENTRY *entry, bool *r
224 if(ret)
225 *ret = false;
226
204 - aral_freez(mrg->index[partition].aral, allocation);
227 + aral_freez(mrg->aral[partition], allocation);
228
229 return metric;
230 }
@@ -303,7 +326,7 @@ static inline bool acquired_metric_del(MRG *mrg, METRIC *metric) {
326
327 mrg_index_write_unlock(mrg, partition);
328
306 - aral_freez(mrg->index[partition].aral, metric);
329 + aral_freez(mrg->aral[partition], metric);
330
331 return true;
332 }
@@ -311,20 +334,22 @@ static inline bool acquired_metric_del(MRG *mrg, METRIC *metric) {
334 // ----------------------------------------------------------------------------
335 // public API
336
314 -inline MRG *mrg_create(size_t partitions) {
315 - if(partitions < 1)
316 - partitions = get_netdata_cpus();
317 -
318 - MRG *mrg = callocz(1, sizeof(MRG) + sizeof(struct mrg_partition) * partitions);
319 - mrg->partitions = partitions;
337 +inline MRG *mrg_create(void) {
338 + MRG *mrg = callocz(1, sizeof(MRG));
339
321 - for(size_t i = 0; i < mrg->partitions ; i++) {
340 + for(size_t i = 0; i < MRG_PARTITIONS ; i++) {
341 rw_spinlock_init(&mrg->index[i].rw_spinlock);
342
343 char buf[ARAL_MAX_NAME + 1];
344 snprintfz(buf, ARAL_MAX_NAME, "mrg[%zu]", i);
345
327 - mrg->index[i].aral = aral_create(buf, sizeof(METRIC), 0, 16384, &mrg_aral_statistics, NULL, NULL, false, false);
346 + mrg->aral[i] = aral_create(buf,
347 + sizeof(METRIC),
348 + 0,
349 + 16384,
350 + &mrg_aral_statistics,
351 + NULL, NULL, false,
352 + false);
353 }
354
355 return mrg;
@@ -390,10 +415,10 @@ inline bool mrg_metric_set_first_time_s(MRG *mrg __maybe_unused, METRIC *metric,
415 if(unlikely(first_time_s < 0))
416 return false;
417
393 - metric_lock(metric);
418 + spinlock_lock(&metric->spinlock);
419 metric->first_time_s = first_time_s;
420 metric_has_retention_unsafe(mrg, metric);
396 - metric_unlock(metric);
421 + spinlock_unlock(&metric->spinlock);
422
423 return true;
424 }
@@ -418,7 +443,7 @@ inline void mrg_metric_expand_retention(MRG *mrg __maybe_unused, METRIC *metric,
443 if(unlikely(!first_time_s && !last_time_s && !update_every_s))
444 return;
445
421 - metric_lock(metric);
446 + spinlock_lock(&metric->spinlock);
447
448 if(unlikely(first_time_s && (!metric->first_time_s || first_time_s < metric->first_time_s)))
449 metric->first_time_s = first_time_s;
@@ -433,7 +458,7 @@ inline void mrg_metric_expand_retention(MRG *mrg __maybe_unused, METRIC *metric,
458 metric->latest_update_every_s = (uint32_t) update_every_s;
459
460 metric_has_retention_unsafe(mrg, metric);
436 - metric_unlock(metric);
461 + spinlock_unlock(&metric->spinlock);
462 }
463
464 inline bool mrg_metric_set_first_time_s_if_bigger(MRG *mrg __maybe_unused, METRIC *metric, time_t first_time_s) {
@@ -441,13 +466,13 @@ inline bool mrg_metric_set_first_time_s_if_bigger(MRG *mrg __maybe_unused, METRI
466
467 bool ret = false;
468
444 - metric_lock(metric);
469 + spinlock_lock(&metric->spinlock);
470 if(first_time_s > metric->first_time_s) {
471 metric->first_time_s = first_time_s;
472 ret = true;
473 }
474 metric_has_retention_unsafe(mrg, metric);
450 - metric_unlock(metric);
475 + spinlock_unlock(&metric->spinlock);
476
477 return ret;
478 }
@@ -455,7 +480,7 @@ inline bool mrg_metric_set_first_time_s_if_bigger(MRG *mrg __maybe_unused, METRI
480 inline time_t mrg_metric_get_first_time_s(MRG *mrg __maybe_unused, METRIC *metric) {
481 time_t first_time_s;
482
458 - metric_lock(metric);
483 + spinlock_lock(&metric->spinlock);
484
485 if(unlikely(!metric->first_time_s)) {
486 if(metric->latest_time_s_clean)
@@ -467,13 +492,13 @@ inline time_t mrg_metric_get_first_time_s(MRG *mrg __maybe_unused, METRIC *metri
492
493 first_time_s = metric->first_time_s;
494
470 - metric_unlock(metric);
495 + spinlock_unlock(&metric->spinlock);
496
497 return first_time_s;
498 }
499
500 inline void mrg_metric_get_retention(MRG *mrg __maybe_unused, METRIC *metric, time_t *first_time_s, time_t *last_time_s, time_t *update_every_s) {
476 - metric_lock(metric);
501 + spinlock_lock(&metric->spinlock);
502
503 if(unlikely(!metric->first_time_s)) {
504 if(metric->latest_time_s_clean)
@@ -487,7 +512,7 @@ inline void mrg_metric_get_retention(MRG *mrg __maybe_unused, METRIC *metric, ti
512 *last_time_s = MAX(metric->latest_time_s_clean, metric->latest_time_s_hot);
513 *update_every_s = metric->latest_update_every_s;
514
490 - metric_unlock(metric);
515 + spinlock_unlock(&metric->spinlock);
516 }
517
518 inline bool mrg_metric_set_clean_latest_time_s(MRG *mrg __maybe_unused, METRIC *metric, time_t latest_time_s) {
@@ -496,7 +521,7 @@ inline bool mrg_metric_set_clean_latest_time_s(MRG *mrg __maybe_unused, METRIC *
521 if(unlikely(latest_time_s < 0))
522 return false;
523
499 - metric_lock(metric);
524 + spinlock_lock(&metric->spinlock);
525
526 // internal_fatal(latest_time_s > max_acceptable_collected_time(),
527 // "DBENGINE METRIC: metric latest time is in the future");
@@ -510,7 +535,7 @@ inline bool mrg_metric_set_clean_latest_time_s(MRG *mrg __maybe_unused, METRIC *
535 metric->first_time_s = latest_time_s;
536
537 metric_has_retention_unsafe(mrg, metric);
513 - metric_unlock(metric);
538 + spinlock_unlock(&metric->spinlock);
539 return true;
540 }
541
@@ -548,7 +573,7 @@ inline bool mrg_metric_zero_disk_retention(MRG *mrg __maybe_unused, METRIC *metr
573 if (min_first_time_s == LONG_MAX)
574 min_first_time_s = 0;
575
551 - metric_lock(metric);
576 + spinlock_lock(&metric->spinlock);
577 if (--countdown && !min_first_time_s && metric->latest_time_s_hot)
578 do_again = true;
579 else {
@@ -560,7 +585,7 @@ inline bool mrg_metric_zero_disk_retention(MRG *mrg __maybe_unused, METRIC *metr
585
586 ret = metric_has_retention_unsafe(mrg, metric);
587 }
563 - metric_unlock(metric);
588 + spinlock_unlock(&metric->spinlock);
589 } while(do_again);
590
591 return ret;
@@ -575,22 +600,22 @@ inline bool mrg_metric_set_hot_latest_time_s(MRG *mrg __maybe_unused, METRIC *me
600 if(unlikely(latest_time_s < 0))
601 return false;
602
578 - metric_lock(metric);
603 + spinlock_lock(&metric->spinlock);
604 metric->latest_time_s_hot = latest_time_s;
605
606 if(unlikely(!metric->first_time_s))
607 metric->first_time_s = latest_time_s;
608
609 metric_has_retention_unsafe(mrg, metric);
585 - metric_unlock(metric);
610 + spinlock_unlock(&metric->spinlock);
611 return true;
612 }
613
614 inline time_t mrg_metric_get_latest_time_s(MRG *mrg __maybe_unused, METRIC *metric) {
615 time_t max;
591 - metric_lock(metric);
616 + spinlock_lock(&metric->spinlock);
617 max = MAX(metric->latest_time_s_clean, metric->latest_time_s_hot);
593 - metric_unlock(metric);
618 + spinlock_unlock(&metric->spinlock);
619 return max;
620 }
621
@@ -600,9 +625,9 @@ inline bool mrg_metric_set_update_every(MRG *mrg __maybe_unused, METRIC *metric,
625 if(update_every_s <= 0)
626 return false;
627
603 - metric_lock(metric);
628 + spinlock_lock(&metric->spinlock);
629 metric->latest_update_every_s = (uint32_t) update_every_s;
605 - metric_unlock(metric);
630 + spinlock_unlock(&metric->spinlock);
631
632 return true;
633 }
@@ -613,10 +638,10 @@ inline bool mrg_metric_set_update_every_s_if_zero(MRG *mrg __maybe_unused, METRI
638 if(update_every_s <= 0)
639 return false;
640
616 - metric_lock(metric);
641 + spinlock_lock(&metric->spinlock);
642 if(!metric->latest_update_every_s)
643 metric->latest_update_every_s = (uint32_t) update_every_s;
619 - metric_unlock(metric);
644 + spinlock_unlock(&metric->spinlock);
645
646 return true;
647 }
@@ -624,16 +649,16 @@ inline bool mrg_metric_set_update_every_s_if_zero(MRG *mrg __maybe_unused, METRI
649 inline time_t mrg_metric_get_update_every_s(MRG *mrg __maybe_unused, METRIC *metric) {
650 time_t update_every_s;
651
627 - metric_lock(metric);
652 + spinlock_lock(&metric->spinlock);
653 update_every_s = metric->latest_update_every_s;
629 - metric_unlock(metric);
654 + spinlock_unlock(&metric->spinlock);
655
656 return update_every_s;
657 }
658
659 inline bool mrg_metric_set_writer(MRG *mrg, METRIC *metric) {
660 bool done = false;
636 - metric_lock(metric);
661 + spinlock_lock(&metric->spinlock);
662 if(!metric->writer) {
663 metric->writer = gettid();
664 __atomic_add_fetch(&mrg->index[metric->partition].stats.writers, 1, __ATOMIC_RELAXED);
@@ -641,19 +666,19 @@ inline bool mrg_metric_set_writer(MRG *mrg, METRIC *metric) {
666 }
667 else
668 __atomic_add_fetch(&mrg->index[metric->partition].stats.writers_conflicts, 1, __ATOMIC_RELAXED);
644 - metric_unlock(metric);
669 + spinlock_unlock(&metric->spinlock);
670 return done;
671 }
672
673 inline bool mrg_metric_clear_writer(MRG *mrg, METRIC *metric) {
674 bool done = false;
650 - metric_lock(metric);
675 + spinlock_lock(&metric->spinlock);
676 if(metric->writer) {
677 metric->writer = 0;
678 __atomic_sub_fetch(&mrg->index[metric->partition].stats.writers, 1, __ATOMIC_RELAXED);
679 done = true;
680 }
656 - metric_unlock(metric);
681 + spinlock_unlock(&metric->spinlock);
682 return done;
683 }
684
@@ -709,7 +734,7 @@ inline void mrg_update_metric_retention_and_granularity_by_uuid(
734 inline void mrg_get_statistics(MRG *mrg, struct mrg_statistics *s) {
735 memset(s, 0, sizeof(struct mrg_statistics));
736
712 - for(size_t i = 0; i < mrg->partitions ;i++) {
737 + for(int i = 0; i < MRG_PARTITIONS ;i++) {
738 s->entries += __atomic_load_n(&mrg->index[i].stats.entries, __ATOMIC_RELAXED);
739 s->entries_referenced += __atomic_load_n(&mrg->index[i].stats.entries_referenced, __ATOMIC_RELAXED);
740 s->entries_with_retention += __atomic_load_n(&mrg->index[i].stats.entries_with_retention, __ATOMIC_RELAXED);
@@ -726,7 +751,7 @@ inline void mrg_get_statistics(MRG *mrg, struct mrg_statistics *s) {
751 s->writers_conflicts += __atomic_load_n(&mrg->index[i].stats.writers_conflicts, __ATOMIC_RELAXED);
752 }
753
729 - s->size += sizeof(MRG) + sizeof(struct mrg_partition) * mrg->partitions;
754 + s->size += sizeof(MRG);
755 }
756
757 // ----------------------------------------------------------------------------
@@ -783,7 +808,7 @@ static void *mrg_stress(void *ptr) {
808 }
809
810 int mrg_unittest(void) {
786 - MRG *mrg = mrg_create(0);
811 + MRG *mrg = mrg_create();
812 METRIC *m1_t0, *m2_t0, *m3_t0, *m4_t0;
813 METRIC *m1_t1, *m2_t1, *m3_t1, *m4_t1;
814 bool ret;
@@ -864,7 +889,7 @@ int mrg_unittest(void) {
889 fatal("DBENGINE METRIC: invalid entries counter");
890
891 size_t entries = 1000000;
867 - size_t threads = mrg->partitions / 3 + 1;
892 + size_t threads = MRG_PARTITIONS / 3 + 1;
893 size_t tiers = 3;
894 size_t run_for_secs = 5;
895 info("preparing stress test of %zu entries...", entries);
database/engine/metric.h
+7 -7
@@ -3,6 +3,8 @@
3
4 #include "../rrd.h"
5
6 +#define MRG_PARTITIONS 10
7 +
8 #define MRG_CACHE_LINE_PADDING(x) uint8_t padding##x[64]
9
10 typedef struct metric METRIC;
@@ -17,10 +19,9 @@ typedef struct mrg_entry {
19 } MRG_ENTRY;
20
21 struct mrg_statistics {
20 - // --- non-atomic --- under a write lock
21 -
22 + // non-atomic - under a write lock
23 size_t entries;
23 - size_t size; // total memory used, with indexing
24 + size_t size; // total memory used, with indexing
25
26 size_t additions;
27 size_t additions_duplicate;
@@ -29,10 +30,9 @@ struct mrg_statistics {
30 size_t delete_having_retention_or_referenced;
31 size_t delete_misses;
32
32 - MRG_CACHE_LINE_PADDING(0);
33 -
34 - // --- atomic --- multiple readers / writers
33 + // atomic - multiple readers / writers
34
35 + MRG_CACHE_LINE_PADDING(0);
36 size_t entries_referenced;
37
38 MRG_CACHE_LINE_PADDING(1);
@@ -50,7 +50,7 @@ struct mrg_statistics {
50 size_t writers_conflicts;
51 };
52
53 -MRG *mrg_create(size_t partitions);
53 +MRG *mrg_create(void);
54 void mrg_destroy(MRG *mrg);
55
56 METRIC *mrg_metric_dup(MRG *mrg, METRIC *metric);
database/engine/pagecache.c
+1 -1
@@ -1083,7 +1083,7 @@ size_t dynamic_extent_cache_size(void) {
1083
1084 void pgc_and_mrg_initialize(void)
1085 {
1086 - main_mrg = mrg_create(0);
1086 + main_mrg = mrg_create();
1087
1088 size_t target_cache_size = (size_t)default_rrdeng_page_cache_mb * 1024ULL * 1024ULL;
1089 size_t main_cache_size = (target_cache_size / 100) * 95;
database/engine/rrdengineapi.c
+2 -2
@@ -1079,8 +1079,8 @@ static void rrdeng_populate_mrg(struct rrdengine_instance *ctx) {
1079 if(cpus > (size_t)libuv_worker_threads)
1080 cpus = (size_t)libuv_worker_threads;
1081
1082 - if(cpus >= (size_t)get_netdata_cpus() / 2)
1083 - cpus = get_netdata_cpus()/ 2 - 1;
1082 + if(cpus >= MRG_PARTITIONS / 2)
1083 + cpus = MRG_PARTITIONS / 2 - 1;
1084
1085 if(cpus < 1)
1086 cpus = 1;