speed improvements in various internal plugins
Costa Tsaousis (ktsaou) committed
Sep 9, 2017 at 23:06 UTC
7f8149b65614f1a4e94186641fe3af52e720be8e
5 files changed
+286
-126
src/proc_interrupts.c
+65
-27
@@ -18,10 +18,10 @@ struct interrupt {
18
19
// since each interrupt is variable in size
20
// we use this to calculate its record size
21
-#define recordsize(cpus) (sizeof(struct interrupt) + (cpus * sizeof(struct cpu_interrupt)))
21
+#define recordsize(cpus) (sizeof(struct interrupt) + ((cpus) * sizeof(struct cpu_interrupt)))
22
23
// given a base, get a pointer to each record
24
-#define irrindex(base, line, cpus) ((struct interrupt *)&((char *)(base))[line * recordsize(cpus)])
24
+#define irrindex(base, line, cpus) ((struct interrupt *)&((char *)(base))[(line) * recordsize(cpus)])
25
26
static inline struct interrupt *get_interrupts_array(size_t lines, int cpus) {
27
static struct interrupt *irrs = NULL;
@@ -142,68 +142,106 @@ int do_proc_interrupts(int update_every, usec_t dt) {
142
irr->used = 1;
143
}
144
145
- RRDSET *st;
146
-
145
// --------------------------------------------------------------------
146
149
- st = rrdset_find_bytype_localhost("system", "interrupts");
150
- if(unlikely(!st)) st = rrdset_create_localhost("system", "interrupts", NULL, "interrupts", NULL, "System interrupts"
151
- , "interrupts/s", 1000, update_every, RRDSET_TYPE_STACKED);
152
- else rrdset_next(st);
147
+ static RRDSET *st_system_interrupts = NULL;
148
+ if(unlikely(!st_system_interrupts))
149
+ st_system_interrupts = rrdset_create_localhost(
150
+ "system"
151
+ , "interrupts"
152
+ , NULL
153
+ , "interrupts"
154
+ , NULL
155
+ , "System interrupts"
156
+ , "interrupts/s"
157
+ , 1000
158
+ , update_every
159
+ , RRDSET_TYPE_STACKED
160
+ );
161
+ else
162
+ rrdset_next(st_system_interrupts);
163
164
for(l = 0; l < lines ;l++) {
165
struct interrupt *irr = irrindex(irrs, l, cpus);
166
if(unlikely(!irr->used)) continue;
167
+
168
// some interrupt may have changed without changing the total number of lines
169
// if the same number of interrupts have been added and removed between two
170
// calls of this function.
171
if(unlikely(!irr->rd || strncmp(irr->rd->name, irr->name, MAX_INTERRUPT_NAME) != 0)) {
161
- irr->rd = rrddim_find(st, irr->id);
172
+ irr->rd = rrddim_find(st_system_interrupts, irr->id);
173
+
174
if(unlikely(!irr->rd))
163
- irr->rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
175
+ irr->rd = rrddim_add(st_system_interrupts, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
176
else
165
- rrddim_set_name(st, irr->rd, irr->name);
177
+ rrddim_set_name(st_system_interrupts, irr->rd, irr->name);
178
179
// also reset per cpu RRDDIMs to avoid repeating strncmp() in the per core loop
180
if(likely(do_per_core)) {
181
int c;
170
- for (c = 0; c < cpus ;c++)
171
- irr->cpu[c].rd = NULL;
182
+ for (c = 0; c < cpus ;c++) irr->cpu[c].rd = NULL;
183
}
184
}
174
- rrddim_set_by_pointer(st, irr->rd, irr->total);
185
+
186
+ rrddim_set_by_pointer(st_system_interrupts, irr->rd, irr->total);
187
}
176
- rrdset_done(st);
188
+
189
+ rrdset_done(st_system_interrupts);
190
+
191
+ // --------------------------------------------------------------------
192
193
if(likely(do_per_core)) {
194
+ static RRDSET **core_st = NULL;
195
+ static int old_cpus = 0;
196
+
197
+ if(old_cpus < cpus) {
198
+ core_st = reallocz(core_st, sizeof(RRDSET *) * cpus);
199
+ memset(&core_st[old_cpus], 0, sizeof(RRDSET *) * (cpus - old_cpus));
200
+ old_cpus = cpus;
201
+ }
202
+
203
int c;
204
205
for(c = 0; c < cpus ;c++) {
182
- char id[50+1];
183
- snprintfz(id, 50, "cpu%d_interrupts", c);
206
+ if(unlikely(!core_st[c])) {
207
+ char id[50+1];
208
+ snprintfz(id, 50, "cpu%d_interrupts", c);
209
185
- st = rrdset_find_bytype_localhost("cpu", id);
186
- if(unlikely(!st)) {
210
char title[100+1];
211
snprintfz(title, 100, "CPU%d Interrupts", c);
189
- st = rrdset_create_localhost("cpu", id, NULL, "interrupts", "cpu.interrupts", title, "interrupts/s",
190
- 1100 + c, update_every, RRDSET_TYPE_STACKED);
212
+ core_st[c] = rrdset_create_localhost(
213
+ "cpu"
214
+ , id
215
+ , NULL
216
+ , "interrupts"
217
+ , "cpu.interrupts"
218
+ , title
219
+ , "interrupts/s"
220
+ , 1100 + c
221
+ , update_every
222
+ , RRDSET_TYPE_STACKED
223
+ );
224
}
192
- else rrdset_next(st);
225
+ else rrdset_next(core_st[c]);
226
227
for(l = 0; l < lines ;l++) {
228
struct interrupt *irr = irrindex(irrs, l, cpus);
229
+
230
if(unlikely(!irr->used)) continue;
231
+
232
if(unlikely(!irr->cpu[c].rd)) {
198
- irr->cpu[c].rd = rrddim_find(st, irr->id);
233
+ irr->cpu[c].rd = rrddim_find(core_st[c], irr->id);
234
+
235
if(unlikely(!irr->cpu[c].rd))
200
- irr->cpu[c].rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
236
+ irr->cpu[c].rd = rrddim_add(core_st[c], irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
237
else
202
- rrddim_set_name(st, irr->cpu[c].rd, irr->name);
238
+ rrddim_set_name(core_st[c], irr->cpu[c].rd, irr->name);
239
}
204
- rrddim_set_by_pointer(st, irr->cpu[c].rd, irr->cpu[c].value);
240
+
241
+ rrddim_set_by_pointer(core_st[c], irr->cpu[c].rd, irr->cpu[c].value);
242
}
206
- rrdset_done(st);
243
+
244
+ rrdset_done(core_st[c]);
245
}
246
}
247
src/proc_loadavg.c
+40
-22
@@ -7,7 +7,6 @@ int do_proc_loadavg(int update_every, usec_t dt) {
7
static procfile *ff = NULL;
8
static int do_loadavg = -1, do_all_processes = -1;
9
static usec_t next_loadavg_dt = 0;
10
- static RRDSET *load_chart = NULL, *processes_chart = NULL;
10
11
if(unlikely(!ff)) {
12
char filename[FILENAME_MAX + 1];
@@ -49,24 +48,33 @@ int do_proc_loadavg(int update_every, usec_t dt) {
48
49
if(next_loadavg_dt <= dt) {
50
if(likely(do_loadavg)) {
51
+ static RRDSET *load_chart = NULL;
52
+ static RRDDIM *rd_load1 = NULL, *rd_load5 = NULL, *rd_load15 = NULL;
53
+
54
if(unlikely(!load_chart)) {
53
- load_chart = rrdset_find_byname_localhost("system.load");
54
- if(unlikely(!load_chart)) {
55
- load_chart = rrdset_create_localhost("system", "load", NULL, "load", NULL, "System Load Average"
56
- , "load", 100, (update_every < MIN_LOADAVG_UPDATE_EVERY)
57
- ? MIN_LOADAVG_UPDATE_EVERY : update_every
58
- , RRDSET_TYPE_LINE);
59
- rrddim_add(load_chart, "load1", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
60
- rrddim_add(load_chart, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
61
- rrddim_add(load_chart, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
62
- }
55
+ load_chart = rrdset_create_localhost(
56
+ "system"
57
+ , "load"
58
+ , NULL
59
+ , "load"
60
+ , NULL
61
+ , "System Load Average"
62
+ , "load"
63
+ , 100
64
+ , (update_every < MIN_LOADAVG_UPDATE_EVERY) ? MIN_LOADAVG_UPDATE_EVERY : update_every
65
+ , RRDSET_TYPE_LINE
66
+ );
67
+
68
+ rd_load1 = rrddim_add(load_chart, "load1", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
69
+ rd_load5 = rrddim_add(load_chart, "load5", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
70
+ rd_load15 = rrddim_add(load_chart, "load15", NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE);
71
}
72
else
73
rrdset_next(load_chart);
74
67
- rrddim_set(load_chart, "load1", (collected_number) (load1 * 1000));
68
- rrddim_set(load_chart, "load5", (collected_number) (load5 * 1000));
69
- rrddim_set(load_chart, "load15", (collected_number) (load15 * 1000));
75
+ rrddim_set_by_pointer(load_chart, rd_load1, (collected_number) (load1 * 1000));
76
+ rrddim_set_by_pointer(load_chart, rd_load5, (collected_number) (load5 * 1000));
77
+ rrddim_set_by_pointer(load_chart, rd_load15, (collected_number) (load15 * 1000));
78
rrdset_done(load_chart);
79
80
next_loadavg_dt = load_chart->update_every * USEC_PER_SEC;
@@ -78,18 +86,28 @@ int do_proc_loadavg(int update_every, usec_t dt) {
86
// --------------------------------------------------------------------
87
88
if(likely(do_all_processes)) {
89
+ static RRDSET *processes_chart = NULL;
90
+ static RRDDIM *rd_active = NULL;
91
+
92
if(unlikely(!processes_chart)) {
82
- processes_chart = rrdset_find_byname_localhost("system.active_processes");
83
- if(unlikely(!processes_chart)) {
84
- processes_chart = rrdset_create_localhost("system", "active_processes", NULL, "processes", NULL
85
- , "System Active Processes", "processes", 750, update_every
86
- , RRDSET_TYPE_LINE);
87
- rrddim_add(processes_chart, "active", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
88
- }
93
+ processes_chart = rrdset_create_localhost(
94
+ "system"
95
+ , "active_processes"
96
+ , NULL
97
+ , "processes"
98
+ , NULL
99
+ , "System Active Processes"
100
+ , "processes"
101
+ , 750
102
+ , update_every
103
+ , RRDSET_TYPE_LINE
104
+ );
105
+
106
+ rd_active = rrddim_add(processes_chart, "active", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
107
}
108
else rrdset_next(processes_chart);
109
92
- rrddim_set(processes_chart, "active", active_processes);
110
+ rrddim_set_by_pointer(processes_chart, rd_active, active_processes);
111
rrdset_done(processes_chart);
112
}
113
src/proc_softirqs.c
+72
-32
@@ -124,77 +124,117 @@ int do_proc_softirqs(int update_every, usec_t dt) {
124
irr->used = 1;
125
}
126
127
- RRDSET *st;
128
-
127
// --------------------------------------------------------------------
128
131
- st = rrdset_find_bytype_localhost("system", "softirqs");
132
- if(unlikely(!st)) st = rrdset_create_localhost("system", "softirqs", NULL, "softirqs", NULL, "System softirqs"
133
- , "softirqs/s", 950, update_every, RRDSET_TYPE_STACKED);
134
- else rrdset_next(st);
129
+ static RRDSET *st_system_softirqs = NULL;
130
+ if(unlikely(!st_system_softirqs))
131
+ st_system_softirqs = rrdset_create_localhost(
132
+ "system"
133
+ , "softirqs"
134
+ , NULL
135
+ , "softirqs"
136
+ , NULL
137
+ , "System softirqs"
138
+ , "softirqs/s"
139
+ , 950
140
+ , update_every
141
+ , RRDSET_TYPE_STACKED
142
+ );
143
+ else rrdset_next(st_system_softirqs);
144
145
for(l = 0; l < lines ;l++) {
146
struct interrupt *irr = irrindex(irrs, l, cpus);
147
+
148
if(unlikely(!irr->used)) continue;
149
+
150
// some interrupt may have changed without changing the total number of lines
151
// if the same number of interrupts have been added and removed between two
152
// calls of this function.
153
if(unlikely(!irr->rd || strncmp(irr->name, irr->rd->name, MAX_INTERRUPT_NAME) != 0)) {
143
- irr->rd = rrddim_find(st, irr->id);
154
+ irr->rd = rrddim_find(st_system_softirqs, irr->id);
155
+
156
if(unlikely(!irr->rd))
145
- irr->rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
157
+ irr->rd = rrddim_add(st_system_softirqs, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
158
else
147
- rrddim_set_name(st, irr->rd, irr->name);
159
+ rrddim_set_name(st_system_softirqs, irr->rd, irr->name);
160
161
// also reset per cpu RRDDIMs to avoid repeating strncmp() in the per core loop
162
if(likely(do_per_core)) {
163
int c;
152
- for (c = 0; c < cpus ;c++)
153
- irr->cpu[c].rd = NULL;
164
+ for (c = 0; c < cpus ;c++) irr->cpu[c].rd = NULL;
165
}
166
}
156
- rrddim_set_by_pointer(st, irr->rd, irr->total);
167
+
168
+ rrddim_set_by_pointer(st_system_softirqs, irr->rd, irr->total);
169
}
158
- rrdset_done(st);
170
+ rrdset_done(st_system_softirqs);
171
+
172
+ // --------------------------------------------------------------------
173
174
if(do_per_core) {
175
+ static RRDSET **core_st = NULL;
176
+ static int old_cpus = 0;
177
+
178
+ if(old_cpus < cpus) {
179
+ core_st = reallocz(core_st, sizeof(RRDSET *) * cpus);
180
+ memset(&core_st[old_cpus], 0, sizeof(RRDSET *) * (cpus - old_cpus));
181
+ old_cpus = cpus;
182
+ }
183
+
184
int c;
185
186
for(c = 0; c < cpus ; c++) {
164
- char id[50+1];
165
- snprintfz(id, 50, "cpu%d_softirqs", c);
166
-
167
- st = rrdset_find_bytype_localhost("cpu", id);
168
- if(unlikely(!st)) {
169
- // find if everything is zero
170
- unsigned long long core_sum = 0 ;
171
- for(l = 0; l < lines ;l++) {
187
+ if(unlikely(!core_st[c])) {
188
+ // find if everything is just zero
189
+ unsigned long long core_sum = 0;
190
+
191
+ for (l = 0; l < lines; l++) {
192
struct interrupt *irr = irrindex(irrs, l, cpus);
173
- if(unlikely(!irr->used)) continue;
193
+ if (unlikely(!irr->used)) continue;
194
core_sum += irr->cpu[c].value;
195
}
176
- if(unlikely(core_sum == 0)) continue; // try next core
196
178
- char title[100+1];
197
+ if (unlikely(core_sum == 0)) continue; // try next core
198
+
199
+ char id[50 + 1];
200
+ snprintfz(id, 50, "cpu%d_softirqs", c);
201
+
202
+ char title[100 + 1];
203
snprintfz(title, 100, "CPU%d softirqs", c);
180
- st = rrdset_create_localhost("cpu", id, NULL, "softirqs", "cpu.softirqs", title, "softirqs/s", 3000 + c
181
- , update_every, RRDSET_TYPE_STACKED);
204
+
205
+ core_st[c] = rrdset_create_localhost(
206
+ "cpu"
207
+ , id
208
+ , NULL
209
+ , "softirqs"
210
+ , "cpu.softirqs"
211
+ , title
212
+ , "softirqs/s"
213
+ , 3000 + c
214
+ , update_every
215
+ , RRDSET_TYPE_STACKED
216
+ );
217
}
183
- else rrdset_next(st);
218
+ else rrdset_next(core_st[c]);
219
220
for(l = 0; l < lines ;l++) {
221
struct interrupt *irr = irrindex(irrs, l, cpus);
222
+
223
if(unlikely(!irr->used)) continue;
224
+
225
if(unlikely(!irr->cpu[c].rd)) {
189
- irr->cpu[c].rd = rrddim_find(st, irr->id);
226
+ irr->cpu[c].rd = rrddim_find(core_st[c], irr->id);
227
+
228
if(unlikely(!irr->cpu[c].rd))
191
- irr->cpu[c].rd = rrddim_add(st, irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
229
+ irr->cpu[c].rd = rrddim_add(core_st[c], irr->id, irr->name, 1, 1, RRD_ALGORITHM_INCREMENTAL);
230
else
193
- rrddim_set_name(st, irr->cpu[c].rd, irr->name);
231
+ rrddim_set_name(core_st[c], irr->cpu[c].rd, irr->name);
232
}
195
- rrddim_set_by_pointer(st, irr->cpu[c].rd, irr->cpu[c].value);
233
+
234
+ rrddim_set_by_pointer(core_st[c], irr->cpu[c].rd, irr->cpu[c].value);
235
}
197
- rrdset_done(st);
236
+
237
+ rrdset_done(core_st[c]);
238
}
239
}
240
src/proc_sys_kernel_random_entropy_avail.c
+18
-5
@@ -17,15 +17,28 @@ int do_proc_sys_kernel_random_entropy_avail(int update_every, usec_t dt) {
17
18
unsigned long long entropy = str2ull(procfile_lineword(ff, 0, 0));
19
20
- RRDSET *st = rrdset_find_bytype_localhost("system", "entropy");
20
+ static RRDSET *st = NULL;
21
+ static RRDDIM *rd = NULL;
22
+
23
if(unlikely(!st)) {
22
- st = rrdset_create_localhost("system", "entropy", NULL, "entropy", NULL, "Available Entropy", "entropy", 1000
23
- , update_every, RRDSET_TYPE_LINE);
24
- rrddim_add(st, "entropy", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
24
+ st = rrdset_create_localhost(
25
+ "system"
26
+ , "entropy"
27
+ , NULL
28
+ , "entropy"
29
+ , NULL
30
+ , "Available Entropy"
31
+ , "entropy"
32
+ , 1000
33
+ , update_every
34
+ , RRDSET_TYPE_LINE
35
+ );
36
+
37
+ rd = rrddim_add(st, "entropy", NULL, 1, 1, RRD_ALGORITHM_ABSOLUTE);
38
}
39
else rrdset_next(st);
40
28
- rrddim_set(st, "entropy", entropy);
41
+ rrddim_set_by_pointer(st, rd, entropy);
42
rrdset_done(st);
43
44
return 0;
src/proc_vmstat.c
+91
-40
@@ -91,17 +91,29 @@ int do_proc_vmstat(int update_every, usec_t dt) {
91
do_swapio = CONFIG_BOOLEAN_YES;
92
93
static RRDSET *st_swapio = NULL;
94
- if(unlikely(!st_swapio)) {
95
- st_swapio = rrdset_create_localhost("system", "swapio", NULL, "swap", NULL, "Swap I/O", "kilobytes/s", 250
96
- , update_every, RRDSET_TYPE_AREA);
94
+ static RRDDIM *rd_in = NULL, *rd_out = NULL;
95
98
- rrddim_add(st_swapio, "in", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_INCREMENTAL);
99
- rrddim_add(st_swapio, "out", NULL, -sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_INCREMENTAL);
96
+ if(unlikely(!st_swapio)) {
97
+ st_swapio = rrdset_create_localhost(
98
+ "system"
99
+ , "swapio"
100
+ , NULL
101
+ , "swap"
102
+ , NULL
103
+ , "Swap I/O"
104
+ , "kilobytes/s"
105
+ , 250
106
+ , update_every
107
+ , RRDSET_TYPE_AREA
108
+ );
109
+
110
+ rd_in = rrddim_add(st_swapio, "in", NULL, sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_INCREMENTAL);
111
+ rd_out = rrddim_add(st_swapio, "out", NULL, -sysconf(_SC_PAGESIZE), 1024, RRD_ALGORITHM_INCREMENTAL);
112
}
113
else rrdset_next(st_swapio);
114
103
- rrddim_set(st_swapio, "in", pswpin);
104
- rrddim_set(st_swapio, "out", pswpout);
115
+ rrddim_set_by_pointer(st_swapio, rd_in, pswpin);
116
+ rrddim_set_by_pointer(st_swapio, rd_out, pswpout);
117
rrdset_done(st_swapio);
118
}
119
@@ -109,17 +121,29 @@ int do_proc_vmstat(int update_every, usec_t dt) {
121
122
if(do_io) {
123
static RRDSET *st_io = NULL;
112
- if(unlikely(!st_io)) {
113
- st_io = rrdset_create_localhost("system", "io", NULL, "disk", NULL, "Disk I/O", "kilobytes/s", 150
114
- , update_every, RRDSET_TYPE_AREA);
124
+ static RRDDIM *rd_in = NULL, *rd_out = NULL;
125
116
- rrddim_add(st_io, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
117
- rrddim_add(st_io, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
126
+ if(unlikely(!st_io)) {
127
+ st_io = rrdset_create_localhost(
128
+ "system"
129
+ , "io"
130
+ , NULL
131
+ , "disk"
132
+ , NULL
133
+ , "Disk I/O"
134
+ , "kilobytes/s"
135
+ , 150
136
+ , update_every
137
+ , RRDSET_TYPE_AREA
138
+ );
139
+
140
+ rd_in = rrddim_add(st_io, "in", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
141
+ rd_out = rrddim_add(st_io, "out", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
142
}
143
else rrdset_next(st_io);
144
121
- rrddim_set(st_io, "in", pgpgin);
122
- rrddim_set(st_io, "out", pgpgout);
145
+ rrddim_set_by_pointer(st_io, rd_in, pgpgin);
146
+ rrddim_set_by_pointer(st_io, rd_out, pgpgout);
147
rrdset_done(st_io);
148
}
149
@@ -127,18 +151,31 @@ int do_proc_vmstat(int update_every, usec_t dt) {
151
152
if(do_pgfaults) {
153
static RRDSET *st_pgfaults = NULL;
154
+ static RRDDIM *rd_minor = NULL, *rd_major = NULL;
155
+
156
if(unlikely(!st_pgfaults)) {
131
- st_pgfaults = rrdset_create_localhost("mem", "pgfaults", NULL, "system", NULL, "Memory Page Faults"
132
- , "page faults/s", 500, update_every, RRDSET_TYPE_LINE);
157
+ st_pgfaults = rrdset_create_localhost(
158
+ "mem"
159
+ , "pgfaults"
160
+ , NULL
161
+ , "system"
162
+ , NULL
163
+ , "Memory Page Faults"
164
+ , "page faults/s"
165
+ , 500
166
+ , update_every
167
+ , RRDSET_TYPE_LINE
168
+ );
169
+
170
rrdset_flag_set(st_pgfaults, RRDSET_FLAG_DETAIL);
171
135
- rrddim_add(st_pgfaults, "minor", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
136
- rrddim_add(st_pgfaults, "major", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
172
+ rd_minor = rrddim_add(st_pgfaults, "minor", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
173
+ rd_major = rrddim_add(st_pgfaults, "major", NULL, -1, 1, RRD_ALGORITHM_INCREMENTAL);
174
}
175
else rrdset_next(st_pgfaults);
176
140
- rrddim_set(st_pgfaults, "minor", pgfault);
141
- rrddim_set(st_pgfaults, "major", pgmajfault);
177
+ rrddim_set_by_pointer(st_pgfaults, rd_minor, pgfault);
178
+ rrddim_set_by_pointer(st_pgfaults, rd_major, pgmajfault);
179
rrdset_done(st_pgfaults);
180
}
181
@@ -149,6 +186,7 @@ int do_proc_vmstat(int update_every, usec_t dt) {
186
// single-node systems have uninteresting statistics (since all accesses
187
// are local).
188
if(unlikely(has_numa == -1))
189
+
190
has_numa = (numa_local || numa_foreign || numa_interleave || numa_other || numa_pte_updates ||
191
numa_huge_pte_updates || numa_hint_faults || numa_hint_faults_local || numa_pages_migrated) ? 1 : 0;
192
@@ -156,37 +194,50 @@ int do_proc_vmstat(int update_every, usec_t dt) {
194
do_numa = CONFIG_BOOLEAN_YES;
195
196
static RRDSET *st_numa = NULL;
197
+ static RRDDIM *rd_local = NULL, *rd_foreign = NULL, *rd_interleave = NULL, *rd_other = NULL, *rd_pte_updates = NULL, *rd_huge_pte_updates = NULL, *rd_hint_faults = NULL, *rd_hint_faults_local = NULL, *rd_pages_migrated = NULL;
198
+
199
if(unlikely(!st_numa)) {
160
- st_numa = rrdset_create_localhost("mem", "numa", NULL, "numa", NULL, "NUMA events", "events/s", 800
161
- , update_every, RRDSET_TYPE_LINE);
200
+ st_numa = rrdset_create_localhost(
201
+ "mem"
202
+ , "numa"
203
+ , NULL
204
+ , "numa"
205
+ , NULL
206
+ , "NUMA events"
207
+ , "events/s"
208
+ , 800
209
+ , update_every
210
+ , RRDSET_TYPE_LINE
211
+ );
212
+
213
rrdset_flag_set(st_numa, RRDSET_FLAG_DETAIL);
214
215
// These depend on CONFIG_NUMA in the kernel.
165
- rrddim_add(st_numa, "local", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
166
- rrddim_add(st_numa, "foreign", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
167
- rrddim_add(st_numa, "interleave", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
168
- rrddim_add(st_numa, "other", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
216
+ rd_local = rrddim_add(st_numa, "local", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
217
+ rd_foreign = rrddim_add(st_numa, "foreign", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
218
+ rd_interleave = rrddim_add(st_numa, "interleave", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
219
+ rd_other = rrddim_add(st_numa, "other", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
220
221
// The following stats depend on CONFIG_NUMA_BALANCING in the
222
// kernel.
172
- rrddim_add(st_numa, "pte_updates", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
173
- rrddim_add(st_numa, "huge_pte_updates", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
174
- rrddim_add(st_numa, "hint_faults", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
175
- rrddim_add(st_numa, "hint_faults_local", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
176
- rrddim_add(st_numa, "pages_migrated", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
223
+ rd_pte_updates = rrddim_add(st_numa, "pte_updates", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
224
+ rd_huge_pte_updates = rrddim_add(st_numa, "huge_pte_updates", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
225
+ rd_hint_faults = rrddim_add(st_numa, "hint_faults", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
226
+ rd_hint_faults_local = rrddim_add(st_numa, "hint_faults_local", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
227
+ rd_pages_migrated = rrddim_add(st_numa, "pages_migrated", NULL, 1, 1, RRD_ALGORITHM_INCREMENTAL);
228
}
229
else rrdset_next(st_numa);
230
180
- rrddim_set(st_numa, "local", numa_local);
181
- rrddim_set(st_numa, "foreign", numa_foreign);
182
- rrddim_set(st_numa, "interleave", numa_interleave);
183
- rrddim_set(st_numa, "other", numa_other);
231
+ rrddim_set_by_pointer(st_numa, rd_local, numa_local);
232
+ rrddim_set_by_pointer(st_numa, rd_foreign, numa_foreign);
233
+ rrddim_set_by_pointer(st_numa, rd_interleave, numa_interleave);
234
+ rrddim_set_by_pointer(st_numa, rd_other, numa_other);
235
185
- rrddim_set(st_numa, "pte_updates", numa_pte_updates);
186
- rrddim_set(st_numa, "huge_pte_updates", numa_huge_pte_updates);
187
- rrddim_set(st_numa, "hint_faults", numa_hint_faults);
188
- rrddim_set(st_numa, "hint_faults_local", numa_hint_faults_local);
189
- rrddim_set(st_numa, "pages_migrated", numa_pages_migrated);
236
+ rrddim_set_by_pointer(st_numa, rd_pte_updates, numa_pte_updates);
237
+ rrddim_set_by_pointer(st_numa, rd_huge_pte_updates, numa_huge_pte_updates);
238
+ rrddim_set_by_pointer(st_numa, rd_hint_faults, numa_hint_faults);
239
+ rrddim_set_by_pointer(st_numa, rd_hint_faults_local, numa_hint_faults_local);
240
+ rrddim_set_by_pointer(st_numa, rd_pages_migrated, numa_pages_migrated);
241
242
rrdset_done(st_numa);
243
}