cgroups data collection optimizations
Costa Tsaousis (ktsaou) committed
Jan 16, 2017 at 22:40 UTC
53fd6c6e6888967ec9f85974607c640df9210cd1
1 file changed
+404
-234
src/sys_fs_cgroup.c
+404
-234
@@ -12,6 +12,8 @@ static int cgroup_enable_systemd_services = CONFIG_ONDEMAND_YES;
12
static int cgroup_enable_new_cgroups_detected_at_runtime = 1;
13
static int cgroup_check_for_new_every = 10;
14
static int cgroup_update_every = 1;
15
+static int cgroup_recheck_zero_blkio_every_iterations = 10;
16
+static int cgroup_recheck_zero_mem_failcnt_every_iterations = 10;
17
18
static char *cgroup_cpuacct_base = NULL;
19
static char *cgroup_blkio_base = NULL;
@@ -127,6 +129,9 @@ void read_cgroup_plugin_configuration() {
129
130
cgroup_enable_systemd_services = config_get_boolean_ondemand("plugin:cgroups", "enable systemd services", cgroup_enable_systemd_services);
131
132
+ cgroup_recheck_zero_blkio_every_iterations = (int)config_get_number("plugin:cgroups", "recheck zero blkio every iterations", cgroup_recheck_zero_blkio_every_iterations);
133
+ cgroup_recheck_zero_mem_failcnt_every_iterations = (int)config_get_number("plugin:cgroups", "recheck zero memory failcnt every iterations", cgroup_recheck_zero_mem_failcnt_every_iterations);
134
+
135
char filename[FILENAME_MAX + 1], *s;
136
struct mountinfo *mi, *root = mountinfo_read(0);
137
@@ -235,6 +240,7 @@ void read_cgroup_plugin_configuration() {
240
241
struct blkio {
242
int updated;
243
+ int delay_counter;
244
245
char *filename;
246
@@ -300,6 +306,7 @@ struct memory {
306
unsigned long long msw_usage_in_bytes;
307
308
int failcnt_updated;
309
+ int failcnt_delay_counter;
310
char *filename_failcnt;
311
unsigned long long failcnt;
312
};
@@ -399,18 +406,24 @@ struct cgroup {
406
static inline void cgroup_read_cpuacct_stat(struct cpuacct_stat *cp) {
407
static procfile *ff = NULL;
408
402
- cp->updated = 0;
403
- if(cp->filename) {
409
+ if(likely(cp->filename)) {
410
ff = procfile_reopen(ff, cp->filename, NULL, PROCFILE_FLAG_DEFAULT);
405
- if(!ff) return;
411
+ if(unlikely(!ff)) {
412
+ cp->updated = 0;
413
+ return;
414
+ }
415
416
ff = procfile_readall(ff);
408
- if(!ff) return;
417
+ if(unlikely(!ff)) {
418
+ cp->updated = 0;
419
+ return;
420
+ }
421
422
unsigned long i, lines = procfile_lines(ff);
423
412
- if(lines < 1) {
424
+ if(unlikely(lines < 1)) {
425
error("File '%s' should have 1+ lines.", cp->filename);
426
+ cp->updated = 0;
427
return;
428
}
429
@@ -418,37 +431,48 @@ static inline void cgroup_read_cpuacct_stat(struct cpuacct_stat *cp) {
431
char *s = procfile_lineword(ff, i, 0);
432
uint32_t hash = simple_hash(s);
433
421
- if(hash == user_hash && !strcmp(s, "user"))
434
+ if(unlikely(hash == user_hash && !strcmp(s, "user"))) {
435
cp->user = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
436
+ continue;
437
+ }
438
424
- else if(hash == system_hash && !strcmp(s, "system"))
439
+ if(unlikely(hash == system_hash && !strcmp(s, "system"))) {
440
cp->system = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
441
+ continue;
442
+ }
443
}
444
445
cp->updated = 1;
429
-
430
- // fprintf(stderr, "READ '%s': user: %llu, system: %llu\n", cp->filename, cp->user, cp->system);
446
}
447
}
448
449
static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
450
static procfile *ff = NULL;
451
437
- ca->updated = 0;
438
- if(ca->filename) {
452
+ if(likely(ca->filename)) {
453
ff = procfile_reopen(ff, ca->filename, NULL, PROCFILE_FLAG_DEFAULT);
440
- if(!ff) return;
454
+ if(unlikely(!ff)) {
455
+ ca->updated = 0;
456
+ return;
457
+ }
458
459
ff = procfile_readall(ff);
443
- if(!ff) return;
460
+ if(unlikely(!ff)) {
461
+ ca->updated = 0;
462
+ return;
463
+ }
464
445
- if(procfile_lines(ff) < 1) {
465
+ if(unlikely(procfile_lines(ff) < 1)) {
466
error("File '%s' should have 1+ lines but has %u.", ca->filename, procfile_lines(ff));
467
+ ca->updated = 0;
468
return;
469
}
470
471
unsigned long i = procfile_linewords(ff, 0);
451
- if(i == 0) return;
472
+ if(unlikely(i == 0)) {
473
+ return;
474
+ ca->updated = 0;
475
+ }
476
477
// we may have 1 more CPU reported
478
while(i > 0) {
@@ -457,16 +481,14 @@ static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
481
else break;
482
}
483
460
- if(i != ca->cpus) {
484
+ if(unlikely(i != ca->cpus)) {
485
freez(ca->cpu_percpu);
486
ca->cpu_percpu = mallocz(sizeof(unsigned long long) * i);
487
ca->cpus = (unsigned int)i;
488
}
489
466
- for(i = 0; i < ca->cpus ;i++) {
490
+ for(i = 0; i < ca->cpus ;i++)
491
ca->cpu_percpu[i] = strtoull(procfile_lineword(ff, 0, i), NULL, 10);
468
- // fprintf(stderr, "READ '%s': cpu%d/%d: %llu ('%s')\n", ca->filename, i, ca->cpus, ca->cpu_percpu[i], procfile_lineword(ff, 0, i));
469
- }
492
493
ca->updated = 1;
494
}
@@ -475,18 +497,29 @@ static inline void cgroup_read_cpuacct_usage(struct cpuacct_usage *ca) {
497
static inline void cgroup_read_blkio(struct blkio *io) {
498
static procfile *ff = NULL;
499
478
- io->updated = 0;
479
- if(io->filename) {
500
+ if(unlikely(io->delay_counter > 0)) {
501
+ io->delay_counter--;
502
+ return;
503
+ }
504
+
505
+ if(likely(io->filename)) {
506
ff = procfile_reopen(ff, io->filename, NULL, PROCFILE_FLAG_DEFAULT);
481
- if(!ff) return;
507
+ if(unlikely(!ff)) {
508
+ io->updated = 0;
509
+ return;
510
+ }
511
512
ff = procfile_readall(ff);
484
- if(!ff) return;
513
+ if(unlikely(!ff)) {
514
+ io->updated = 0;
515
+ return;
516
+ }
517
518
unsigned long i, lines = procfile_lines(ff);
519
488
- if(lines < 1) {
520
+ if(unlikely(lines < 1)) {
521
error("File '%s' should have 1+ lines.", io->filename);
522
+ io->updated = 0;
523
return;
524
}
525
@@ -502,154 +535,236 @@ static inline void cgroup_read_blkio(struct blkio *io) {
535
char *s = procfile_lineword(ff, i, 1);
536
uint32_t hash = simple_hash(s);
537
505
- if(hash == Read_hash && !strcmp(s, "Read"))
538
+ if(unlikely(hash == Read_hash && !strcmp(s, "Read"))) {
539
io->Read += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
540
+ continue;
541
+ }
542
508
- else if(hash == Write_hash && !strcmp(s, "Write"))
543
+ if(unlikely(hash == Write_hash && !strcmp(s, "Write"))) {
544
io->Write += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
545
+ continue;
546
+ }
547
548
/*
512
- else if(hash == Sync_hash && !strcmp(s, "Sync"))
549
+ if(hash == Sync_hash && !strcmp(s, "Sync")) {
550
io->Sync += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
551
+ continue;
552
+ }
553
515
- else if(hash == Async_hash && !strcmp(s, "Async"))
554
+ if(hash == Async_hash && !strcmp(s, "Async")) {
555
io->Async += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
556
+ continue;
557
+ }
558
518
- else if(hash == Total_hash && !strcmp(s, "Total"))
559
+ if(hash == Total_hash && !strcmp(s, "Total")) {
560
io->Total += strtoull(procfile_lineword(ff, i, 2), NULL, 10);
561
+ continue;
562
+ }
563
*/
564
}
565
566
io->updated = 1;
524
- // fprintf(stderr, "READ '%s': Read: %llu, Write: %llu, Sync: %llu, Async: %llu, Total: %llu\n", io->filename, io->Read, io->Write, io->Sync, io->Async, io->Total);
567
+
568
+ if(unlikely(!io->Read && !io->Write))
569
+ io->delay_counter = cgroup_recheck_zero_blkio_every_iterations;
570
}
571
}
572
573
static inline void cgroup_read_memory(struct memory *mem) {
574
static procfile *ff = NULL;
575
531
- mem->updated = 0;
532
- if(mem->filename) {
576
+ if(likely(mem->filename)) {
577
ff = procfile_reopen(ff, mem->filename, NULL, PROCFILE_FLAG_DEFAULT);
534
- if(!ff) return;
578
+ if(unlikely(!ff)) {
579
+ mem->updated = 0;
580
+ goto memory_next;
581
+ }
582
583
ff = procfile_readall(ff);
537
- if(!ff) return;
584
+ if(unlikely(!ff)) {
585
+ mem->updated = 0;
586
+ goto memory_next;
587
+ }
588
589
unsigned long i, lines = procfile_lines(ff);
590
541
- if(lines < 1) {
591
+ if(unlikely(lines < 1)) {
592
error("File '%s' should have 1+ lines.", mem->filename);
543
- return;
593
+ mem->updated = 0;
594
+ goto memory_next;
595
}
596
597
for(i = 0; i < lines ; i++) {
598
char *s = procfile_lineword(ff, i, 0);
599
uint32_t hash = simple_hash(s);
600
550
- if(hash == cache_hash && !strcmp(s, "cache"))
601
+ if(unlikely(hash == cache_hash && !strcmp(s, "cache"))) {
602
mem->cache = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
603
+ continue;
604
+ }
605
553
- else if(hash == rss_hash && !strcmp(s, "rss"))
606
+ if(unlikely(hash == rss_hash && !strcmp(s, "rss"))) {
607
mem->rss = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
608
+ continue;
609
+ }
610
556
- else if(hash == rss_huge_hash && !strcmp(s, "rss_huge"))
611
+ if(unlikely(hash == rss_huge_hash && !strcmp(s, "rss_huge"))) {
612
mem->rss_huge = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
613
+ continue;
614
+ }
615
559
- else if(hash == mapped_file_hash && !strcmp(s, "mapped_file"))
616
+ if(unlikely(hash == mapped_file_hash && !strcmp(s, "mapped_file"))) {
617
mem->mapped_file = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
618
+ continue;
619
+ }
620
562
- else if(hash == writeback_hash && !strcmp(s, "writeback"))
621
+ if(unlikely(hash == writeback_hash && !strcmp(s, "writeback"))) {
622
mem->writeback = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
623
+ continue;
624
+ }
625
565
- else if(hash == dirty_hash && !strcmp(s, "dirty")) {
626
+ if(unlikely(hash == dirty_hash && !strcmp(s, "dirty"))) {
627
mem->dirty = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
628
mem->has_dirty_swap = 1;
629
+ continue;
630
}
631
570
- else if(hash == swap_hash && !strcmp(s, "swap")) {
632
+ if(unlikely(hash == swap_hash && !strcmp(s, "swap"))) {
633
mem->swap = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
634
mem->has_dirty_swap = 1;
635
+ continue;
636
}
637
575
- else if(hash == pgpgin_hash && !strcmp(s, "pgpgin"))
638
+ if(unlikely(hash == pgpgin_hash && !strcmp(s, "pgpgin"))) {
639
mem->pgpgin = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
640
+ continue;
641
+ }
642
578
- else if(hash == pgpgout_hash && !strcmp(s, "pgpgout"))
643
+ if(unlikely(hash == pgpgout_hash && !strcmp(s, "pgpgout"))) {
644
mem->pgpgout = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
645
+ continue;
646
+ }
647
581
- else if(hash == pgfault_hash && !strcmp(s, "pgfault"))
648
+ if(unlikely(hash == pgfault_hash && !strcmp(s, "pgfault"))) {
649
mem->pgfault = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
650
+ continue;
651
+ }
652
584
- else if(hash == pgmajfault_hash && !strcmp(s, "pgmajfault"))
653
+ if(unlikely(hash == pgmajfault_hash && !strcmp(s, "pgmajfault"))) {
654
mem->pgmajfault = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
655
+ continue;
656
+ }
657
658
/*
588
- else if(hash == inactive_anon_hash && !strcmp(s, "inactive_anon"))
659
+ if(unlikely(hash == inactive_anon_hash && !strcmp(s, "inactive_anon"))) {
660
mem->inactive_anon = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
661
+ continue;
662
+ }
663
591
- else if(hash == active_anon_hash && !strcmp(s, "active_anon"))
664
+ if(unlikely(hash == active_anon_hash && !strcmp(s, "active_anon"))) {
665
mem->active_anon = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
666
+ continue;
667
+ }
668
594
- else if(hash == inactive_file_hash && !strcmp(s, "inactive_file"))
669
+ if(unlikely(hash == inactive_file_hash && !strcmp(s, "inactive_file"))) {
670
mem->inactive_file = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
671
+ continue;
672
+ }
673
597
- else if(hash == active_file_hash && !strcmp(s, "active_file"))
674
+ if(unlikely(hash == active_file_hash && !strcmp(s, "active_file"))) {
675
mem->active_file = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
676
+ continue;
677
+ }
678
600
- else if(hash == unevictable_hash && !strcmp(s, "unevictable"))
679
+ if(unlikely(hash == unevictable_hash && !strcmp(s, "unevictable"))) {
680
mem->unevictable = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
681
+ continue;
682
+ }
683
603
- else if(hash == hierarchical_memory_limit_hash && !strcmp(s, "hierarchical_memory_limit"))
684
+ if(unlikely(hash == hierarchical_memory_limit_hash && !strcmp(s, "hierarchical_memory_limit"))) {
685
mem->hierarchical_memory_limit = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
686
+ continue;
687
+ }
688
606
- else if(hash == total_cache_hash && !strcmp(s, "total_cache"))
689
+ if(unlikely(hash == total_cache_hash && !strcmp(s, "total_cache"))) {
690
mem->total_cache = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
691
+ continue;
692
+ }
693
609
- else if(hash == total_rss_hash && !strcmp(s, "total_rss"))
694
+ if(unlikely(hash == total_rss_hash && !strcmp(s, "total_rss"))) {
695
mem->total_rss = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
696
+ continue;
697
+ }
698
612
- else if(hash == total_rss_huge_hash && !strcmp(s, "total_rss_huge"))
699
+ if(unlikely(hash == total_rss_huge_hash && !strcmp(s, "total_rss_huge"))) {
700
mem->total_rss_huge = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
701
+ continue;
702
+ }
703
615
- else if(hash == total_mapped_file_hash && !strcmp(s, "total_mapped_file"))
704
+ if(unlikely(hash == total_mapped_file_hash && !strcmp(s, "total_mapped_file"))) {
705
mem->total_mapped_file = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
706
+ continue;
707
+ }
708
618
- else if(hash == total_writeback_hash && !strcmp(s, "total_writeback"))
709
+ if(unlikely(hash == total_writeback_hash && !strcmp(s, "total_writeback"))) {
710
mem->total_writeback = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
711
+ continue;
712
+ }
713
621
- else if(hash == total_dirty_hash && !strcmp(s, "total_dirty"))
714
+ if(unlikely(hash == total_dirty_hash && !strcmp(s, "total_dirty"))) {
715
mem->total_dirty = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
716
+ continue;
717
+ }
718
624
- else if(hash == total_swap_hash && !strcmp(s, "total_swap"))
719
+ if(unlikely(hash == total_swap_hash && !strcmp(s, "total_swap"))) {
720
mem->total_swap = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
721
+ continue;
722
+ }
723
627
- else if(hash == total_pgpgin_hash && !strcmp(s, "total_pgpgin"))
724
+ if(unlikely(hash == total_pgpgin_hash && !strcmp(s, "total_pgpgin"))) {
725
mem->total_pgpgin = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
726
+ continue;
727
+ }
728
630
- else if(hash == total_pgpgout_hash && !strcmp(s, "total_pgpgout"))
729
+ if(unlikely(hash == total_pgpgout_hash && !strcmp(s, "total_pgpgout"))) {
730
mem->total_pgpgout = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
731
+ continue;
732
+ }
733
633
- else if(hash == total_pgfault_hash && !strcmp(s, "total_pgfault"))
734
+ if(unlikely(hash == total_pgfault_hash && !strcmp(s, "total_pgfault"))) {
735
mem->total_pgfault = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
736
+ continue;
737
+ }
738
636
- else if(hash == total_pgmajfault_hash && !strcmp(s, "total_pgmajfault"))
739
+ if(unlikely(hash == total_pgmajfault_hash && !strcmp(s, "total_pgmajfault"))) {
740
mem->total_pgmajfault = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
741
+ continue;
742
+ }
743
639
- else if(hash == total_inactive_anon_hash && !strcmp(s, "total_inactive_anon"))
744
+ if(unlikely(hash == total_inactive_anon_hash && !strcmp(s, "total_inactive_anon"))) {
745
mem->total_inactive_anon = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
746
+ continue;
747
+ }
748
642
- else if(hash == total_active_anon_hash && !strcmp(s, "total_active_anon"))
749
+ if(unlikely(hash == total_active_anon_hash && !strcmp(s, "total_active_anon"))) {
750
mem->total_active_anon = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
751
+ continue;
752
+ }
753
645
- else if(hash == total_inactive_file_hash && !strcmp(s, "total_inactive_file"))
754
+ if(unlikely(hash == total_inactive_file_hash && !strcmp(s, "total_inactive_file"))) {
755
mem->total_inactive_file = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
756
+ continue;
757
+ }
758
648
- else if(hash == total_active_file_hash && !strcmp(s, "total_active_file"))
759
+ if(unlikely(hash == total_active_file_hash && !strcmp(s, "total_active_file"))) {
760
mem->total_active_file = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
761
+ continue;
762
+ }
763
651
- else if(hash == total_unevictable_hash && !strcmp(s, "total_unevictable"))
764
+ if(unlikely(hash == total_unevictable_hash && !strcmp(s, "total_unevictable"))) {
765
mem->total_unevictable = strtoull(procfile_lineword(ff, i, 1), NULL, 10);
766
+ continue;
767
+ }
768
*/
769
}
770
@@ -658,22 +773,32 @@ static inline void cgroup_read_memory(struct memory *mem) {
773
mem->updated = 1;
774
}
775
661
- mem->usage_in_bytes_updated = 0;
662
- if(mem->filename_usage_in_bytes) {
776
+memory_next:
777
+ if(likely(mem->filename_usage_in_bytes)) {
778
if(likely(!read_single_number_file(mem->filename_usage_in_bytes, &mem->usage_in_bytes)))
779
mem->usage_in_bytes_updated = 1;
780
+ else
781
+ mem->usage_in_bytes_updated = 0;
782
}
783
667
- mem->msw_usage_in_bytes_updated = 0;
668
- if(mem->filename_msw_usage_in_bytes) {
784
+ if(likely(mem->filename_msw_usage_in_bytes)) {
785
if(likely(!read_single_number_file(mem->filename_msw_usage_in_bytes, &mem->msw_usage_in_bytes)))
786
mem->msw_usage_in_bytes_updated = 1;
787
+ else
788
+ mem->msw_usage_in_bytes_updated = 0;
789
}
790
673
- mem->failcnt_updated = 0;
674
- if(mem->filename_failcnt) {
675
- if(likely(!read_single_number_file(mem->filename_failcnt, &mem->failcnt)))
791
+ if(likely(mem->filename_failcnt)) {
792
+ if(unlikely(mem->failcnt_delay_counter > 0)) {
793
+ mem->failcnt_updated = 0;
794
+ mem->failcnt_delay_counter--;
795
+ }
796
+ else if(likely(!read_single_number_file(mem->filename_failcnt, &mem->failcnt))) {
797
mem->failcnt_updated = 1;
798
+
799
+ if(unlikely(!mem->failcnt))
800
+ mem->failcnt_delay_counter = cgroup_recheck_zero_mem_failcnt_every_iterations;
801
+ }
802
}
803
}
804
@@ -1123,7 +1248,7 @@ static inline void find_all_cgroups() {
1248
char filename[FILENAME_MAX + 1];
1249
if(unlikely(cgroup_enable_cpuacct_stat && !cg->cpuacct_stat.filename)) {
1250
snprintfz(filename, FILENAME_MAX, "%s%s/cpuacct.stat", cgroup_cpuacct_base, cg->id);
1126
- if(stat(filename, &buf) != -1) {
1251
+ if(likely(stat(filename, &buf) != -1)) {
1252
cg->cpuacct_stat.filename = strdupz(filename);
1253
debug(D_CGROUP, "cpuacct.stat filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_stat.filename);
1254
}
@@ -1132,7 +1257,7 @@ static inline void find_all_cgroups() {
1257
1258
if(unlikely(cgroup_enable_cpuacct_usage && !cg->cpuacct_usage.filename && !(cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE))) {
1259
snprintfz(filename, FILENAME_MAX, "%s%s/cpuacct.usage_percpu", cgroup_cpuacct_base, cg->id);
1135
- if(stat(filename, &buf) != -1) {
1260
+ if(likely(stat(filename, &buf) != -1)) {
1261
cg->cpuacct_usage.filename = strdupz(filename);
1262
debug(D_CGROUP, "cpuacct.usage_percpu filename for cgroup '%s': '%s'", cg->id, cg->cpuacct_usage.filename);
1263
}
@@ -1142,7 +1267,7 @@ static inline void find_all_cgroups() {
1267
if(unlikely(cgroup_enable_memory)) {
1268
if(unlikely(!cg->memory.filename) && !(cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE)) {
1269
snprintfz(filename, FILENAME_MAX, "%s%s/memory.stat", cgroup_memory_base, cg->id);
1145
- if(stat(filename, &buf) != -1) {
1270
+ if(likely(stat(filename, &buf) != -1)) {
1271
cg->memory.filename = strdupz(filename);
1272
debug(D_CGROUP, "memory.stat filename for cgroup '%s': '%s'", cg->id, cg->memory.filename);
1273
}
@@ -1151,7 +1276,7 @@ static inline void find_all_cgroups() {
1276
}
1277
if(unlikely(!cg->memory.filename_usage_in_bytes)) {
1278
snprintfz(filename, FILENAME_MAX, "%s%s/memory.usage_in_bytes", cgroup_memory_base, cg->id);
1154
- if(stat(filename, &buf) != -1) {
1279
+ if(likely(stat(filename, &buf) != -1)) {
1280
cg->memory.filename_usage_in_bytes = strdupz(filename);
1281
debug(D_CGROUP, "memory.usage_in_bytes filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_usage_in_bytes);
1282
}
@@ -1160,7 +1285,7 @@ static inline void find_all_cgroups() {
1285
}
1286
if(unlikely(!cg->memory.filename_msw_usage_in_bytes)) {
1287
snprintfz(filename, FILENAME_MAX, "%s%s/memory.msw_usage_in_bytes", cgroup_memory_base, cg->id);
1163
- if(stat(filename, &buf) != -1) {
1288
+ if(likely(stat(filename, &buf) != -1)) {
1289
cg->memory.filename_msw_usage_in_bytes = strdupz(filename);
1290
debug(D_CGROUP, "memory.msw_usage_in_bytes filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_msw_usage_in_bytes);
1291
}
@@ -1169,7 +1294,7 @@ static inline void find_all_cgroups() {
1294
}
1295
if(unlikely(!cg->memory.filename_failcnt)) {
1296
snprintfz(filename, FILENAME_MAX, "%s%s/memory.failcnt", cgroup_memory_base, cg->id);
1172
- if(stat(filename, &buf) != -1) {
1297
+ if(likely(stat(filename, &buf) != -1)) {
1298
cg->memory.filename_failcnt = strdupz(filename);
1299
debug(D_CGROUP, "memory.failcnt filename for cgroup '%s': '%s'", cg->id, cg->memory.filename_failcnt);
1300
}
@@ -1181,51 +1306,62 @@ static inline void find_all_cgroups() {
1306
if(unlikely(cgroup_enable_blkio)) {
1307
if(unlikely(!cg->io_service_bytes.filename)) {
1308
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_service_bytes", cgroup_blkio_base, cg->id);
1184
- if(stat(filename, &buf) != -1) {
1309
+ if(likely(stat(filename, &buf) != -1)) {
1310
cg->io_service_bytes.filename = strdupz(filename);
1311
debug(D_CGROUP, "io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->io_service_bytes.filename);
1312
}
1188
- else debug(D_CGROUP, "io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1313
+ else
1314
+ debug(D_CGROUP, "io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1315
}
1316
+
1317
if(unlikely(!cg->io_serviced.filename)) {
1318
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_serviced", cgroup_blkio_base, cg->id);
1192
- if(stat(filename, &buf) != -1) {
1319
+ if(likely(stat(filename, &buf) != -1)) {
1320
cg->io_serviced.filename = strdupz(filename);
1321
debug(D_CGROUP, "io_serviced filename for cgroup '%s': '%s'", cg->id, cg->io_serviced.filename);
1322
}
1196
- else debug(D_CGROUP, "io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1323
+ else
1324
+ debug(D_CGROUP, "io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1325
}
1326
+
1327
if(unlikely(!cg->throttle_io_service_bytes.filename)) {
1328
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.throttle.io_service_bytes", cgroup_blkio_base, cg->id);
1200
- if(stat(filename, &buf) != -1) {
1329
+ if(likely(stat(filename, &buf) != -1)) {
1330
cg->throttle_io_service_bytes.filename = strdupz(filename);
1331
debug(D_CGROUP, "throttle_io_service_bytes filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_service_bytes.filename);
1332
}
1204
- else debug(D_CGROUP, "throttle_io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1333
+ else
1334
+ debug(D_CGROUP, "throttle_io_service_bytes file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1335
}
1336
+
1337
if(unlikely(!cg->throttle_io_serviced.filename)) {
1338
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.throttle.io_serviced", cgroup_blkio_base, cg->id);
1208
- if(stat(filename, &buf) != -1) {
1339
+ if(likely(stat(filename, &buf) != -1)) {
1340
cg->throttle_io_serviced.filename = strdupz(filename);
1341
debug(D_CGROUP, "throttle_io_serviced filename for cgroup '%s': '%s'", cg->id, cg->throttle_io_serviced.filename);
1342
}
1212
- else debug(D_CGROUP, "throttle_io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1343
+ else
1344
+ debug(D_CGROUP, "throttle_io_serviced file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1345
}
1346
+
1347
if(unlikely(!cg->io_merged.filename)) {
1348
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_merged", cgroup_blkio_base, cg->id);
1216
- if(stat(filename, &buf) != -1) {
1349
+ if(likely(stat(filename, &buf) != -1)) {
1350
cg->io_merged.filename = strdupz(filename);
1351
debug(D_CGROUP, "io_merged filename for cgroup '%s': '%s'", cg->id, cg->io_merged.filename);
1352
}
1220
- else debug(D_CGROUP, "io_merged file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1353
+ else
1354
+ debug(D_CGROUP, "io_merged file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1355
}
1356
+
1357
if(unlikely(!cg->io_queued.filename)) {
1358
snprintfz(filename, FILENAME_MAX, "%s%s/blkio.io_queued", cgroup_blkio_base, cg->id);
1224
- if(stat(filename, &buf) != -1) {
1359
+ if(likely(stat(filename, &buf) != -1)) {
1360
cg->io_queued.filename = strdupz(filename);
1361
debug(D_CGROUP, "io_queued filename for cgroup '%s': '%s'", cg->id, cg->io_queued.filename);
1362
}
1228
- else debug(D_CGROUP, "io_queued file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1363
+ else
1364
+ debug(D_CGROUP, "io_queued file for cgroup '%s': '%s' does not exist.", cg->id, filename);
1365
}
1366
}
1367
}
@@ -1271,112 +1407,123 @@ void update_services_charts(int update_every,
1407
1408
// create the charts
1409
1274
- if(do_cpu) {
1410
+ if(likely(do_cpu)) {
1411
if(unlikely(!st_cpu)) {
1412
char title[CHART_TITLE_MAX + 1];
1413
1414
st_cpu = rrdset_find_bytype("services", "cpu");
1279
- if(!st_cpu) {
1415
+ if(likely(!st_cpu)) {
1416
snprintfz(title, CHART_TITLE_MAX, "Systemd Services CPU utilization (%d%% = %d core%s)", (processors * 100), processors, (processors > 1) ? "s" : "");
1417
st_cpu = rrdset_create("services", "cpu", NULL, "cpu", "services.cpu", title, "%", 30000, update_every, RRDSET_TYPE_STACKED);
1418
}
1419
}
1284
- else rrdset_next(st_cpu);
1420
+ else
1421
+ rrdset_next(st_cpu);
1422
}
1423
1287
- if(do_mem_usage) {
1424
+ if(likely(do_mem_usage)) {
1425
if(unlikely(!st_mem_usage)) {
1426
st_mem_usage = rrdset_find_bytype("services", "mem_usage");
1290
- if(!st_mem_usage)
1427
+ if(likely(!st_mem_usage))
1428
st_mem_usage = rrdset_create("services", "mem_usage", NULL, "mem", "services.mem_usage", "Systemd Services RAM Usage", "MB", 30001, update_every, RRDSET_TYPE_STACKED);
1429
}
1293
- else rrdset_next(st_mem_usage);
1430
+ else
1431
+ rrdset_next(st_mem_usage);
1432
}
1433
1296
- if(do_io) {
1434
+ if(likely(do_io)) {
1435
if(unlikely(!st_io_read)) {
1436
st_io_read = rrdset_find_bytype("services", "io_read");
1299
- if(!st_io_read)
1437
+ if(likely(!st_io_read))
1438
st_io_read = rrdset_create("services", "io_read", NULL, "disk", "services.io_read", "Systemd Services Disk Read Bandwidth", "KB/s", 30012, update_every, RRDSET_TYPE_STACKED);
1439
}
1302
- else rrdset_next(st_io_read);
1440
+ else
1441
+ rrdset_next(st_io_read);
1442
1443
if(unlikely(!st_io_write)) {
1444
st_io_write = rrdset_find_bytype("services", "io_write");
1306
- if(!st_io_write)
1445
+ if(likely(!st_io_write))
1446
st_io_write = rrdset_create("services", "io_write", NULL, "disk", "services.io_write", "Systemd Services Disk Write Bandwidth", "KB/s", 30013, update_every, RRDSET_TYPE_STACKED);
1447
}
1309
- else rrdset_next(st_io_write);
1448
+ else
1449
+ rrdset_next(st_io_write);
1450
}
1451
1312
- if(do_io_ops) {
1452
+ if(likely(do_io_ops)) {
1453
if(unlikely(!st_io_serviced_read)) {
1454
st_io_serviced_read = rrdset_find_bytype("services", "io_ops_read");
1315
- if(!st_io_serviced_read)
1455
+ if(likely(!st_io_serviced_read))
1456
st_io_serviced_read = rrdset_create("services", "io_ops_read", NULL, "disk", "services.io_ops_read", "Systemd Services Disk Read Operations", "operations/s", 30014, update_every, RRDSET_TYPE_STACKED);
1457
}
1318
- else rrdset_next(st_io_serviced_read);
1458
+ else
1459
+ rrdset_next(st_io_serviced_read);
1460
1461
if(unlikely(!st_io_serviced_write)) {
1462
st_io_serviced_write = rrdset_find_bytype("services", "io_ops_write");
1322
- if(!st_io_serviced_write)
1463
+ if(likely(!st_io_serviced_write))
1464
st_io_serviced_write = rrdset_create("services", "io_ops_write", NULL, "disk", "services.io_ops_write", "Systemd Services Disk Write Operations", "operations/s", 30015, update_every, RRDSET_TYPE_STACKED);
1465
}
1325
- else rrdset_next(st_io_serviced_write);
1466
+ else
1467
+ rrdset_next(st_io_serviced_write);
1468
}
1469
1328
- if(do_throttle_io) {
1470
+ if(likely(do_throttle_io)) {
1471
if(unlikely(!st_throttle_io_read)) {
1472
st_throttle_io_read = rrdset_find_bytype("services", "throttle_io_read");
1331
- if(!st_throttle_io_read)
1473
+ if(likely(!st_throttle_io_read))
1474
st_throttle_io_read = rrdset_create("services", "throttle_io_read", NULL, "disk", "services.throttle_io_read", "Systemd Services Throttle Disk Read Bandwidth", "KB/s", 30016, update_every, RRDSET_TYPE_STACKED);
1475
}
1334
- else rrdset_next(st_throttle_io_read);
1476
+ else
1477
+ rrdset_next(st_throttle_io_read);
1478
1479
if(unlikely(!st_throttle_io_write)) {
1480
st_throttle_io_write = rrdset_find_bytype("services", "throttle_io_write");
1338
- if(!st_throttle_io_write)
1481
+ if(likely(!st_throttle_io_write))
1482
st_throttle_io_write = rrdset_create("services", "throttle_io_write", NULL, "disk", "services.throttle_io_write", "Systemd Services Throttle Disk Write Bandwidth", "KB/s", 30017, update_every, RRDSET_TYPE_STACKED);
1483
}
1341
- else rrdset_next(st_throttle_io_write);
1484
+ else
1485
+ rrdset_next(st_throttle_io_write);
1486
}
1487
1344
- if(do_throttle_ops) {
1488
+ if(likely(do_throttle_ops)) {
1489
if(unlikely(!st_throttle_ops_read)) {
1490
st_throttle_ops_read = rrdset_find_bytype("services", "throttle_io_ops_read");
1347
- if(!st_throttle_ops_read)
1491
+ if(likely(!st_throttle_ops_read))
1492
st_throttle_ops_read = rrdset_create("services", "throttle_io_ops_read", NULL, "disk", "services.throttle_io_ops_read", "Systemd Services Throttle Disk Read Operations", "operations/s", 30018, update_every, RRDSET_TYPE_STACKED);
1493
}
1350
- else rrdset_next(st_throttle_ops_read);
1494
+ else
1495
+ rrdset_next(st_throttle_ops_read);
1496
1497
if(unlikely(!st_throttle_ops_write)) {
1498
st_throttle_ops_write = rrdset_find_bytype("services", "throttle_io_ops_write");
1354
- if(!st_throttle_ops_write)
1499
+ if(likely(!st_throttle_ops_write))
1500
st_throttle_ops_write = rrdset_create("services", "throttle_io_ops_write", NULL, "disk", "services.throttle_io_ops_write", "Systemd Services Throttle Disk Write Operations", "operations/s", 30019, update_every, RRDSET_TYPE_STACKED);
1501
}
1357
- else rrdset_next(st_throttle_ops_write);
1502
+ else
1503
+ rrdset_next(st_throttle_ops_write);
1504
}
1505
1506
// update the values
1507
struct cgroup *cg;
1508
for(cg = cgroup_root; cg ; cg = cg->next) {
1363
- if(!cg->available || !cg->enabled || !(cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE)) continue;
1509
+ if(unlikely(!cg->available || !cg->enabled || !(cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE)))
1510
+ continue;
1511
1365
- if(do_cpu && cg->cpuacct_stat.updated) {
1512
+ if(likely(do_cpu && cg->cpuacct_stat.updated)) {
1513
if(unlikely(!cg->rd_cpu))
1514
cg->rd_cpu = rrddim_add(st_cpu, cg->chart_id, cg->chart_title, 100, hz, RRDDIM_INCREMENTAL);
1515
1516
rrddim_set_by_pointer(st_cpu, cg->rd_cpu, cg->cpuacct_stat.user + cg->cpuacct_stat.system);
1517
}
1518
1372
- if(do_mem_usage && cg->memory.usage_in_bytes_updated) {
1519
+ if(likely(do_mem_usage && cg->memory.usage_in_bytes_updated)) {
1520
if(unlikely(!cg->rd_mem_usage))
1521
cg->rd_mem_usage = rrddim_add(st_mem_usage, cg->chart_id, cg->chart_title, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1522
1523
rrddim_set_by_pointer(st_mem_usage, cg->rd_mem_usage, cg->memory.usage_in_bytes);
1524
}
1525
1379
- if(do_io && cg->io_service_bytes.updated) {
1526
+ if(likely(do_io && cg->io_service_bytes.updated)) {
1527
if(unlikely(!cg->rd_io_service_bytes_read))
1528
cg->rd_io_service_bytes_read = rrddim_add(st_io_read, cg->chart_id, cg->chart_title, 1, 1024, RRDDIM_INCREMENTAL);
1529
@@ -1388,7 +1535,7 @@ void update_services_charts(int update_every,
1535
rrddim_set_by_pointer(st_io_write, cg->rd_io_service_bytes_write, cg->io_service_bytes.Write);
1536
}
1537
1391
- if(do_io_ops && cg->io_serviced.updated) {
1538
+ if(likely(do_io_ops && cg->io_serviced.updated)) {
1539
if(unlikely(!cg->rd_io_serviced_read))
1540
cg->rd_io_serviced_read = rrddim_add(st_io_serviced_read, cg->chart_id, cg->chart_title, 1, 1, RRDDIM_INCREMENTAL);
1541
@@ -1400,7 +1547,7 @@ void update_services_charts(int update_every,
1547
rrddim_set_by_pointer(st_io_serviced_write, cg->rd_io_serviced_write, cg->io_serviced.Write);
1548
}
1549
1403
- if(do_throttle_io && cg->throttle_io_service_bytes.updated) {
1550
+ if(likely(do_throttle_io && cg->throttle_io_service_bytes.updated)) {
1551
if(unlikely(!cg->rd_throttle_io_read))
1552
cg->rd_throttle_io_read = rrddim_add(st_throttle_io_read, cg->chart_id, cg->chart_title, 1, 1024, RRDDIM_INCREMENTAL);
1553
@@ -1412,7 +1559,7 @@ void update_services_charts(int update_every,
1559
rrddim_set_by_pointer(st_throttle_io_write, cg->rd_throttle_io_write, cg->throttle_io_service_bytes.Write);
1560
}
1561
1415
- if(do_throttle_ops && cg->throttle_io_serviced.updated) {
1562
+ if(likely(do_throttle_ops && cg->throttle_io_serviced.updated)) {
1563
if(unlikely(!cg->rd_throttle_io_serviced_read))
1564
cg->rd_throttle_io_serviced_read = rrddim_add(st_throttle_ops_read, cg->chart_id, cg->chart_title, 1, 1, RRDDIM_INCREMENTAL);
1565
@@ -1426,12 +1573,31 @@ void update_services_charts(int update_every,
1573
}
1574
1575
// complete the iteration
1429
- if(do_cpu) rrdset_done(st_cpu);
1430
- if(do_mem_usage) rrdset_done(st_mem_usage);
1431
- if(do_io) { rrdset_done(st_io_read); rrdset_done(st_io_write); }
1432
- if(do_io_ops) { rrdset_done(st_io_serviced_read); rrdset_done(st_io_serviced_write); }
1433
- if(do_throttle_io) { rrdset_done(st_throttle_io_read); rrdset_done(st_throttle_io_write); }
1434
- if(do_throttle_ops) { rrdset_done(st_throttle_ops_read); rrdset_done(st_throttle_ops_write); }
1576
+ if(likely(do_cpu))
1577
+ rrdset_done(st_cpu);
1578
+
1579
+ if(likely(do_mem_usage))
1580
+ rrdset_done(st_mem_usage);
1581
+
1582
+ if(likely(do_io)) {
1583
+ rrdset_done(st_io_read);
1584
+ rrdset_done(st_io_write);
1585
+ }
1586
+
1587
+ if(likely(do_io_ops)) {
1588
+ rrdset_done(st_io_serviced_read);
1589
+ rrdset_done(st_io_serviced_write);
1590
+ }
1591
+
1592
+ if(likely(do_throttle_io)) {
1593
+ rrdset_done(st_throttle_io_read);
1594
+ rrdset_done(st_throttle_io_write);
1595
+ }
1596
+
1597
+ if(likely(do_throttle_ops)) {
1598
+ rrdset_done(st_throttle_ops_read);
1599
+ rrdset_done(st_throttle_ops_write);
1600
+ }
1601
}
1602
1603
static inline char *cgroup_chart_type(char *buffer, const char *id, size_t len) {
@@ -1463,9 +1629,10 @@ void update_cgroup_charts(int update_every) {
1629
1630
struct cgroup *cg;
1631
for(cg = cgroup_root; cg ; cg = cg->next) {
1466
- if(!cg->available || !cg->enabled) continue;
1632
+ if(unlikely(!cg->available || !cg->enabled))
1633
+ continue;
1634
1468
- if(cgroup_enable_systemd_services && cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE) {
1635
+ if(likely(cgroup_enable_systemd_services && cg->options & CGROUP_OPTIONS_SYSTEM_SLICE_SERVICE)) {
1636
if(cg->cpuacct_stat.updated && (cg->cpuacct_stat.user || cg->cpuacct_stat.system)) services_do_cpu++;
1637
if(cg->memory.usage_in_bytes_updated && (cg->memory.usage_in_bytes)) services_do_mem_usage++;
1638
if(cg->io_service_bytes.updated && (cg->io_service_bytes.Read || cg->io_service_bytes.Write)) services_do_io++;
@@ -1479,41 +1646,41 @@ void update_cgroup_charts(int update_every) {
1646
1647
type[0] = '\0';
1648
1482
- if(cg->cpuacct_stat.updated) {
1649
+ if(likely(cg->cpuacct_stat.updated)) {
1650
if(unlikely(!cg->st_cpu)) {
1651
cg->st_cpu = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "cpu");
1485
- if(!cg->st_cpu) {
1652
+ if(likely(!cg->st_cpu)) {
1653
snprintfz(title, CHART_TITLE_MAX, "CPU Usage (%d%% = %d core%s) for cgroup %s", (processors * 100), processors, (processors > 1) ? "s" : "", cg->chart_title);
1654
cg->st_cpu = rrdset_create(type, "cpu", NULL, "cpu", "cgroup.cpu", title, "%", 40000, update_every, RRDSET_TYPE_STACKED);
1488
-
1489
- rrddim_add(cg->st_cpu, "user", NULL, 100, hz, RRDDIM_INCREMENTAL);
1490
- rrddim_add(cg->st_cpu, "system", NULL, 100, hz, RRDDIM_INCREMENTAL);
1655
}
1656
+ rrddim_add(cg->st_cpu, "user", NULL, 100, hz, RRDDIM_INCREMENTAL);
1657
+ rrddim_add(cg->st_cpu, "system", NULL, 100, hz, RRDDIM_INCREMENTAL);
1658
}
1493
- else rrdset_next(cg->st_cpu);
1659
+ else
1660
+ rrdset_next(cg->st_cpu);
1661
1662
rrddim_set(cg->st_cpu, "user", cg->cpuacct_stat.user);
1663
rrddim_set(cg->st_cpu, "system", cg->cpuacct_stat.system);
1664
rrdset_done(cg->st_cpu);
1665
}
1666
1500
- if(cg->cpuacct_usage.updated) {
1667
+ if(likely(cg->cpuacct_usage.updated)) {
1668
char id[RRD_ID_LENGTH_MAX + 1];
1669
unsigned int i;
1670
1671
if(unlikely(!cg->st_cpu_per_core)) {
1672
cg->st_cpu_per_core = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "cpu_per_core");
1506
- if(!cg->st_cpu_per_core) {
1673
+ if(likely(!cg->st_cpu_per_core)) {
1674
snprintfz(title, CHART_TITLE_MAX, "CPU Usage (%d%% = %d core%s) Per Core for cgroup %s", (processors * 100), processors, (processors > 1) ? "s" : "", cg->chart_title);
1675
cg->st_cpu_per_core = rrdset_create(type, "cpu_per_core", NULL, "cpu", "cgroup.cpu_per_core", title, "%", 40100, update_every, RRDSET_TYPE_STACKED);
1509
-
1510
- for(i = 0; i < cg->cpuacct_usage.cpus; i++) {
1511
- snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
1512
- rrddim_add(cg->st_cpu_per_core, id, NULL, 100, 1000000000, RRDDIM_INCREMENTAL);
1513
- }
1676
+ }
1677
+ for(i = 0; i < cg->cpuacct_usage.cpus; i++) {
1678
+ snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
1679
+ rrddim_add(cg->st_cpu_per_core, id, NULL, 100, 1000000000, RRDDIM_INCREMENTAL);
1680
}
1681
}
1516
- else rrdset_next(cg->st_cpu_per_core);
1682
+ else
1683
+ rrdset_next(cg->st_cpu_per_core);
1684
1685
for(i = 0; i < cg->cpuacct_usage.cpus ;i++) {
1686
snprintfz(id, CHART_TITLE_MAX, "cpu%u", i);
@@ -1522,23 +1689,24 @@ void update_cgroup_charts(int update_every) {
1689
rrdset_done(cg->st_cpu_per_core);
1690
}
1691
1525
- if(cg->memory.updated) {
1526
- if(cg->memory.cache || cg->memory.rss || cg->memory.rss_huge || cg->memory.mapped_file) {
1692
+ if(likely(cg->memory.updated)) {
1693
+ if(likely(cg->memory.cache || cg->memory.rss || cg->memory.rss_huge || cg->memory.mapped_file)) {
1694
if(unlikely(!cg->st_mem)) {
1695
cg->st_mem = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "mem");
1529
- if(!cg->st_mem) {
1696
+ if(likely(!cg->st_mem)) {
1697
snprintfz(title, CHART_TITLE_MAX, "Memory Usage for cgroup %s", cg->chart_title);
1698
cg->st_mem = rrdset_create(type, "mem", NULL, "mem", "cgroup.mem", title, "MB", 40210, update_every, RRDSET_TYPE_STACKED);
1532
-
1533
- rrddim_add(cg->st_mem, "cache", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1534
- rrddim_add(cg->st_mem, "rss", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1535
- if(cg->memory.has_dirty_swap)
1536
- rrddim_add(cg->st_mem, "swap", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1537
- rrddim_add(cg->st_mem, "rss_huge", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1538
- rrddim_add(cg->st_mem, "mapped_file", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1699
}
1700
+
1701
+ rrddim_add(cg->st_mem, "cache", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1702
+ rrddim_add(cg->st_mem, "rss", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1703
+ if(cg->memory.has_dirty_swap)
1704
+ rrddim_add(cg->st_mem, "swap", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1705
+ rrddim_add(cg->st_mem, "rss_huge", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1706
+ rrddim_add(cg->st_mem, "mapped_file", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1707
}
1541
- else rrdset_next(cg->st_mem);
1708
+ else
1709
+ rrdset_next(cg->st_mem);
1710
1711
rrddim_set(cg->st_mem, "cache", cg->memory.cache);
1712
rrddim_set(cg->st_mem, "rss", cg->memory.rss);
@@ -1551,52 +1719,53 @@ void update_cgroup_charts(int update_every) {
1719
1720
if(unlikely(!cg->st_writeback)) {
1721
cg->st_writeback = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "writeback");
1554
- if(!cg->st_writeback) {
1722
+ if(likely(!cg->st_writeback)) {
1723
snprintfz(title, CHART_TITLE_MAX, "Writeback Memory for cgroup %s", cg->chart_title);
1724
cg->st_writeback = rrdset_create(type, "writeback", NULL, "mem", "cgroup.writeback", title, "MB", 40300, update_every, RRDSET_TYPE_AREA);
1557
-
1558
- if(cg->memory.has_dirty_swap)
1559
- rrddim_add(cg->st_writeback, "dirty", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1560
- rrddim_add(cg->st_writeback, "writeback", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1725
}
1726
+
1727
+ if(cg->memory.has_dirty_swap)
1728
+ rrddim_add(cg->st_writeback, "dirty", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1729
+ rrddim_add(cg->st_writeback, "writeback", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1730
}
1563
- else rrdset_next(cg->st_writeback);
1731
+ else
1732
+ rrdset_next(cg->st_writeback);
1733
1734
if(cg->memory.has_dirty_swap)
1735
rrddim_set(cg->st_writeback, "dirty", cg->memory.dirty);
1736
rrddim_set(cg->st_writeback, "writeback", cg->memory.writeback);
1737
rrdset_done(cg->st_writeback);
1738
1570
- if(cg->memory.pgpgin || cg->memory.pgpgout) {
1739
+ if(likely(cg->memory.pgpgin || cg->memory.pgpgout)) {
1740
if(unlikely(!cg->st_mem_activity)) {
1741
cg->st_mem_activity = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "mem_activity");
1573
- if(!cg->st_mem_activity) {
1742
+ if(likely(!cg->st_mem_activity)) {
1743
snprintfz(title, CHART_TITLE_MAX, "Memory Activity for cgroup %s", cg->chart_title);
1744
cg->st_mem_activity = rrdset_create(type, "mem_activity", NULL, "mem", "cgroup.mem_activity", title, "MB/s", 40400, update_every, RRDSET_TYPE_LINE);
1576
-
1577
- rrddim_add(cg->st_mem_activity, "pgpgin", "in", sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1578
- rrddim_add(cg->st_mem_activity, "pgpgout", "out", -sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1745
}
1746
+ rrddim_add(cg->st_mem_activity, "pgpgin", "in", sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1747
+ rrddim_add(cg->st_mem_activity, "pgpgout", "out", -sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1748
}
1581
- else rrdset_next(cg->st_mem_activity);
1749
+ else
1750
+ rrdset_next(cg->st_mem_activity);
1751
1752
rrddim_set(cg->st_mem_activity, "pgpgin", cg->memory.pgpgin);
1753
rrddim_set(cg->st_mem_activity, "pgpgout", cg->memory.pgpgout);
1754
rrdset_done(cg->st_mem_activity);
1755
}
1756
1588
- if(cg->memory.pgfault || cg->memory.pgmajfault) {
1757
+ if(likely(cg->memory.pgfault || cg->memory.pgmajfault)) {
1758
if(unlikely(!cg->st_pgfaults)) {
1759
cg->st_pgfaults = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "pgfaults");
1591
- if(!cg->st_pgfaults) {
1760
+ if(likely(!cg->st_pgfaults)) {
1761
snprintfz(title, CHART_TITLE_MAX, "Memory Page Faults for cgroup %s", cg->chart_title);
1762
cg->st_pgfaults = rrdset_create(type, "pgfaults", NULL, "mem", "cgroup.pgfaults", title, "MB/s", 40500, update_every, RRDSET_TYPE_LINE);
1594
-
1595
- rrddim_add(cg->st_pgfaults, "pgfault", NULL, sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1596
- rrddim_add(cg->st_pgfaults, "pgmajfault", "swap", -sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1763
}
1764
+ rrddim_add(cg->st_pgfaults, "pgfault", NULL, sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1765
+ rrddim_add(cg->st_pgfaults, "pgmajfault", "swap", -sysconf(_SC_PAGESIZE), 1024 * 1024, RRDDIM_INCREMENTAL);
1766
}
1599
- else rrdset_next(cg->st_pgfaults);
1767
+ else
1768
+ rrdset_next(cg->st_pgfaults);
1769
1770
rrddim_set(cg->st_pgfaults, "pgfault", cg->memory.pgfault);
1771
rrddim_set(cg->st_pgfaults, "pgmajfault", cg->memory.pgmajfault);
@@ -1604,143 +1773,142 @@ void update_cgroup_charts(int update_every) {
1773
}
1774
}
1775
1607
- if(cg->memory.usage_in_bytes_updated) {
1776
+ if(likely(cg->memory.usage_in_bytes_updated)) {
1777
if(unlikely(!cg->st_mem_usage)) {
1778
cg->st_mem_usage = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "mem_usage");
1610
- if(!cg->st_mem_usage) {
1779
+ if(likely(!cg->st_mem_usage)) {
1780
snprintfz(title, CHART_TITLE_MAX, "Total Memory for cgroup %s", cg->chart_title);
1781
cg->st_mem_usage = rrdset_create(type, "mem_usage", NULL, "mem", "cgroup.mem_usage", title, "MB", 40200, update_every, RRDSET_TYPE_STACKED);
1613
-
1614
- rrddim_add(cg->st_mem_usage, "ram", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1615
- rrddim_add(cg->st_mem_usage, "swap", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1782
}
1783
+ rrddim_add(cg->st_mem_usage, "ram", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1784
+ rrddim_add(cg->st_mem_usage, "swap", NULL, 1, 1024 * 1024, RRDDIM_ABSOLUTE);
1785
}
1618
- else rrdset_next(cg->st_mem_usage);
1786
+ else
1787
+ rrdset_next(cg->st_mem_usage);
1788
1789
rrddim_set(cg->st_mem_usage, "ram", cg->memory.usage_in_bytes);
1790
rrddim_set(cg->st_mem_usage, "swap", (cg->memory.msw_usage_in_bytes > cg->memory.usage_in_bytes)?cg->memory.msw_usage_in_bytes - cg->memory.usage_in_bytes:0);
1791
rrdset_done(cg->st_mem_usage);
1792
}
1793
1625
- if(cg->memory.failcnt_updated && cg->memory.failcnt) {
1794
+ if(likely(cg->memory.failcnt_updated && cg->memory.failcnt)) {
1795
if(unlikely(!cg->st_mem_failcnt)) {
1796
cg->st_mem_failcnt = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "mem_failcnt");
1628
- if(!cg->st_mem_failcnt) {
1797
+ if(likely(!cg->st_mem_failcnt)) {
1798
snprintfz(title, CHART_TITLE_MAX, "Memory Limit Failures for cgroup %s", cg->chart_title);
1799
cg->st_mem_failcnt = rrdset_create(type, "mem_failcnt", NULL, "mem", "cgroup.mem_failcnt", title, "MB", 40250, update_every, RRDSET_TYPE_LINE);
1631
-
1632
- rrddim_add(cg->st_mem_failcnt, "failures", NULL, 1, 1, RRDDIM_INCREMENTAL);
1800
}
1801
+ rrddim_add(cg->st_mem_failcnt, "failures", NULL, 1, 1, RRDDIM_INCREMENTAL);
1802
}
1635
- else rrdset_next(cg->st_mem_failcnt);
1803
+ else
1804
+ rrdset_next(cg->st_mem_failcnt);
1805
1806
rrddim_set(cg->st_mem_failcnt, "failures", cg->memory.failcnt);
1807
rrdset_done(cg->st_mem_failcnt);
1808
}
1809
1641
- if(cg->io_service_bytes.updated && (cg->io_service_bytes.Read || cg->io_service_bytes.Write)) {
1810
+ if(likely(cg->io_service_bytes.updated && (cg->io_service_bytes.Read || cg->io_service_bytes.Write))) {
1811
if(unlikely(!cg->st_io)) {
1812
cg->st_io = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "io");
1644
- if(!cg->st_io) {
1813
+ if(likely(!cg->st_io)) {
1814
snprintfz(title, CHART_TITLE_MAX, "I/O Bandwidth (all disks) for cgroup %s", cg->chart_title);
1815
cg->st_io = rrdset_create(type, "io", NULL, "disk", "cgroup.io", title, "KB/s", 41200, update_every, RRDSET_TYPE_AREA);
1647
-
1648
- rrddim_add(cg->st_io, "read", NULL, 1, 1024, RRDDIM_INCREMENTAL);
1649
- rrddim_add(cg->st_io, "write", NULL, -1, 1024, RRDDIM_INCREMENTAL);
1816
}
1817
+ rrddim_add(cg->st_io, "read", NULL, 1, 1024, RRDDIM_INCREMENTAL);
1818
+ rrddim_add(cg->st_io, "write", NULL, -1, 1024, RRDDIM_INCREMENTAL);
1819
}
1652
- else rrdset_next(cg->st_io);
1820
+ else
1821
+ rrdset_next(cg->st_io);
1822
1823
rrddim_set(cg->st_io, "read", cg->io_service_bytes.Read);
1824
rrddim_set(cg->st_io, "write", cg->io_service_bytes.Write);
1825
rrdset_done(cg->st_io);
1826
}
1827
1659
- if(cg->io_serviced.updated && (cg->io_serviced.Read || cg->io_serviced.Write)) {
1828
+ if(likely(cg->io_serviced.updated && (cg->io_serviced.Read || cg->io_serviced.Write))) {
1829
if(unlikely(!cg->st_serviced_ops)) {
1830
cg->st_serviced_ops = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "serviced_ops");
1662
- if(!cg->st_serviced_ops) {
1663
- snprintfz(title, CHART_TITLE_MAX, "Serviced I/O Operations (all disks) for cgroup %s"
1664
- , cg->chart_title);
1831
+ if(likely(!cg->st_serviced_ops)) {
1832
+ snprintfz(title, CHART_TITLE_MAX, "Serviced I/O Operations (all disks) for cgroup %s", cg->chart_title);
1833
cg->st_serviced_ops = rrdset_create(type, "serviced_ops", NULL, "disk", "cgroup.serviced_ops", title, "operations/s", 41200, update_every, RRDSET_TYPE_LINE);
1666
-
1667
- rrddim_add(cg->st_serviced_ops, "read", NULL, 1, 1, RRDDIM_INCREMENTAL);
1668
- rrddim_add(cg->st_serviced_ops, "write", NULL, -1, 1, RRDDIM_INCREMENTAL);
1834
}
1835
+ rrddim_add(cg->st_serviced_ops, "read", NULL, 1, 1, RRDDIM_INCREMENTAL);
1836
+ rrddim_add(cg->st_serviced_ops, "write", NULL, -1, 1, RRDDIM_INCREMENTAL);
1837
}
1671
- else rrdset_next(cg->st_serviced_ops);
1838
+ else
1839
+ rrdset_next(cg->st_serviced_ops);
1840
1841
rrddim_set(cg->st_serviced_ops, "read", cg->io_serviced.Read);
1842
rrddim_set(cg->st_serviced_ops, "write", cg->io_serviced.Write);
1843
rrdset_done(cg->st_serviced_ops);
1844
}
1845
1678
- if(cg->throttle_io_service_bytes.updated && (cg->throttle_io_service_bytes.Read || cg->throttle_io_service_bytes.Write)) {
1846
+ if(likely(cg->throttle_io_service_bytes.updated && (cg->throttle_io_service_bytes.Read || cg->throttle_io_service_bytes.Write))) {
1847
if(unlikely(!cg->st_throttle_io)) {
1848
cg->st_throttle_io = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "throttle_io");
1681
- if(!cg->st_throttle_io) {
1849
+ if(likely(!cg->st_throttle_io)) {
1850
snprintfz(title, CHART_TITLE_MAX, "Throttle I/O Bandwidth (all disks) for cgroup %s", cg->chart_title);
1851
cg->st_throttle_io = rrdset_create(type, "throttle_io", NULL, "disk", "cgroup.throttle_io", title, "KB/s", 41200, update_every, RRDSET_TYPE_AREA);
1684
-
1685
- rrddim_add(cg->st_throttle_io, "read", NULL, 1, 1024, RRDDIM_INCREMENTAL);
1686
- rrddim_add(cg->st_throttle_io, "write", NULL, -1, 1024, RRDDIM_INCREMENTAL);
1852
}
1853
+ rrddim_add(cg->st_throttle_io, "read", NULL, 1, 1024, RRDDIM_INCREMENTAL);
1854
+ rrddim_add(cg->st_throttle_io, "write", NULL, -1, 1024, RRDDIM_INCREMENTAL);
1855
}
1689
- else rrdset_next(cg->st_throttle_io);
1856
+ else
1857
+ rrdset_next(cg->st_throttle_io);
1858
1859
rrddim_set(cg->st_throttle_io, "read", cg->throttle_io_service_bytes.Read);
1860
rrddim_set(cg->st_throttle_io, "write", cg->throttle_io_service_bytes.Write);
1861
rrdset_done(cg->st_throttle_io);
1862
}
1863
1696
- if(cg->throttle_io_serviced.updated && (cg->throttle_io_serviced.Read || cg->throttle_io_serviced.Write)) {
1864
+ if(likely(cg->throttle_io_serviced.updated && (cg->throttle_io_serviced.Read || cg->throttle_io_serviced.Write))) {
1865
if(unlikely(!cg->st_throttle_serviced_ops)) {
1866
cg->st_throttle_serviced_ops = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "throttle_serviced_ops");
1699
- if(!cg->st_throttle_serviced_ops) {
1867
+ if(likely(!cg->st_throttle_serviced_ops)) {
1868
snprintfz(title, CHART_TITLE_MAX, "Throttle Serviced I/O Operations (all disks) for cgroup %s", cg->chart_title);
1869
cg->st_throttle_serviced_ops = rrdset_create(type, "throttle_serviced_ops", NULL, "disk", "cgroup.throttle_serviced_ops", title, "operations/s", 41200, update_every, RRDSET_TYPE_LINE);
1702
-
1703
- rrddim_add(cg->st_throttle_serviced_ops, "read", NULL, 1, 1, RRDDIM_INCREMENTAL);
1704
- rrddim_add(cg->st_throttle_serviced_ops, "write", NULL, -1, 1, RRDDIM_INCREMENTAL);
1870
}
1871
+ rrddim_add(cg->st_throttle_serviced_ops, "read", NULL, 1, 1, RRDDIM_INCREMENTAL);
1872
+ rrddim_add(cg->st_throttle_serviced_ops, "write", NULL, -1, 1, RRDDIM_INCREMENTAL);
1873
}
1707
- else rrdset_next(cg->st_throttle_serviced_ops);
1874
+ else
1875
+ rrdset_next(cg->st_throttle_serviced_ops);
1876
1877
rrddim_set(cg->st_throttle_serviced_ops, "read", cg->throttle_io_serviced.Read);
1878
rrddim_set(cg->st_throttle_serviced_ops, "write", cg->throttle_io_serviced.Write);
1879
rrdset_done(cg->st_throttle_serviced_ops);
1880
}
1881
1714
- if(cg->io_queued.updated) {
1882
+ if(likely(cg->io_queued.updated)) {
1883
if(unlikely(!cg->st_queued_ops)) {
1884
cg->st_queued_ops = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "queued_ops");
1717
- if(!cg->st_queued_ops) {
1885
+ if(likely(!cg->st_queued_ops)) {
1886
snprintfz(title, CHART_TITLE_MAX, "Queued I/O Operations (all disks) for cgroup %s", cg->chart_title);
1887
cg->st_queued_ops = rrdset_create(type, "queued_ops", NULL, "disk", "cgroup.queued_ops", title, "operations", 42000, update_every, RRDSET_TYPE_LINE);
1720
-
1721
- rrddim_add(cg->st_queued_ops, "read", NULL, 1, 1, RRDDIM_ABSOLUTE);
1722
- rrddim_add(cg->st_queued_ops, "write", NULL, -1, 1, RRDDIM_ABSOLUTE);
1888
}
1889
+ rrddim_add(cg->st_queued_ops, "read", NULL, 1, 1, RRDDIM_ABSOLUTE);
1890
+ rrddim_add(cg->st_queued_ops, "write", NULL, -1, 1, RRDDIM_ABSOLUTE);
1891
}
1725
- else rrdset_next(cg->st_queued_ops);
1892
+ else
1893
+ rrdset_next(cg->st_queued_ops);
1894
1895
rrddim_set(cg->st_queued_ops, "read", cg->io_queued.Read);
1896
rrddim_set(cg->st_queued_ops, "write", cg->io_queued.Write);
1897
rrdset_done(cg->st_queued_ops);
1898
}
1899
1732
- if(cg->io_merged.updated && (cg->io_merged.Read || cg->io_merged.Write)) {
1900
+ if(likely(cg->io_merged.updated && (cg->io_merged.Read || cg->io_merged.Write))) {
1901
if(unlikely(!cg->st_merged_ops)) {
1902
cg->st_merged_ops = rrdset_find_bytype(cgroup_chart_type(type, cg->chart_id, RRD_ID_LENGTH_MAX), "merged_ops");
1735
- if(!cg->st_merged_ops) {
1903
+ if(likely(!cg->st_merged_ops)) {
1904
snprintfz(title, CHART_TITLE_MAX, "Merged I/O Operations (all disks) for cgroup %s", cg->chart_title);
1905
cg->st_merged_ops = rrdset_create(type, "merged_ops", NULL, "disk", "cgroup.merged_ops", title, "operations/s", 42100, update_every, RRDSET_TYPE_LINE);
1738
-
1739
- rrddim_add(cg->st_merged_ops, "read", NULL, 1, 1024, RRDDIM_INCREMENTAL);
1740
- rrddim_add(cg->st_merged_ops, "write", NULL, -1, 1024, RRDDIM_INCREMENTAL);
1906
}
1907
+ rrddim_add(cg->st_merged_ops, "read", NULL, 1, 1024, RRDDIM_INCREMENTAL);
1908
+ rrddim_add(cg->st_merged_ops, "write", NULL, -1, 1024, RRDDIM_INCREMENTAL);
1909
}
1743
- else rrdset_next(cg->st_merged_ops);
1910
+ else
1911
+ rrdset_next(cg->st_merged_ops);
1912
1913
rrddim_set(cg->st_merged_ops, "read", cg->io_merged.Read);
1914
rrddim_set(cg->st_merged_ops, "write", cg->io_merged.Write);
@@ -1748,9 +1916,7 @@ void update_cgroup_charts(int update_every) {
1916
}
1917
}
1918
1751
- debug(D_CGROUP, "done updating cgroups charts");
1752
-
1753
- if(cgroup_enable_systemd_services)
1919
+ if(likely(cgroup_enable_systemd_services))
1920
update_services_charts(update_every,
1921
services_do_cpu,
1922
services_do_mem_usage,
@@ -1761,6 +1927,8 @@ void update_cgroup_charts(int update_every) {
1927
services_do_queued_ops,
1928
services_do_merged_ops*/
1929
);
1930
+
1931
+ debug(D_CGROUP, "done updating cgroups charts");
1932
}
1933
1934
// ----------------------------------------------------------------------------
@@ -1816,14 +1984,16 @@ void *cgroups_main(void *ptr) {
1984
if(vdo_cpu_netdata) {
1985
getrusage(RUSAGE_THREAD, &thread);
1986
1819
- if(!stcpu_thread) stcpu_thread = rrdset_find("netdata.plugin_cgroups_cpu");
1820
- if(!stcpu_thread) {
1821
- stcpu_thread = rrdset_create("netdata", "plugin_cgroups_cpu", NULL, "cgroups", NULL, "NetData CGroups Plugin CPU usage", "milliseconds/s", 132000, cgroup_update_every, RRDSET_TYPE_STACKED);
1987
+ if(unlikely(!stcpu_thread)) {
1988
+ stcpu_thread = rrdset_find("netdata.plugin_cgroups_cpu");
1989
+ if(unlikely(!stcpu_thread))
1990
+ stcpu_thread = rrdset_create("netdata", "plugin_cgroups_cpu", NULL, "cgroups", NULL, "NetData CGroups Plugin CPU usage", "milliseconds/s", 132000, cgroup_update_every, RRDSET_TYPE_STACKED);
1991
1992
rrddim_add(stcpu_thread, "user", NULL, 1, 1000, RRDDIM_INCREMENTAL);
1993
rrddim_add(stcpu_thread, "system", NULL, 1, 1000, RRDDIM_INCREMENTAL);
1994
}
1826
- else rrdset_next(stcpu_thread);
1995
+ else
1996
+ rrdset_next(stcpu_thread);
1997
1998
rrddim_set(stcpu_thread, "user" , thread.ru_utime.tv_sec * 1000000ULL + thread.ru_utime.tv_usec);
1999
rrddim_set(stcpu_thread, "system", thread.ru_stime.tv_sec * 1000000ULL + thread.ru_stime.tv_usec);