]> arthur.barton.de Git - netdata.git/commitdiff
Merge pull request #1368 from rlefevre/time-improvements
authorCosta Tsaousis <costa@tsaousis.gr>
Sat, 28 Jan 2017 16:41:53 +0000 (18:41 +0200)
committerGitHub <noreply@github.com>
Sat, 28 Jan 2017 16:41:53 +0000 (18:41 +0200)
Time improvements

1  2 
src/apps_plugin.c
src/proc_diskstats.c
src/sys_fs_cgroup.c

index b69171395085b375bf39530c920677ccc3881e4c,fb3082d69109ad66a3b1af58c48849d487dbc2c7..60c0802d7ddbddff3ed44d9ad5699203dccbf37e
@@@ -754,16 -610,15 +754,16 @@@ static inline int read_proc_pid_stat(st
      if(unlikely(!ff)) goto cleanup;
  
      p->last_stat_collected_usec = p->stat_collected_usec;
-     p->stat_collected_usec = now_realtime_usec();
+     p->stat_collected_usec = now_monotonic_usec();
      file_counter++;
  
 -    // p->pid           = str2ul(procfile_lineword(ff, 0, 0+i));
 +    // p->pid           = str2pid_t(procfile_lineword(ff, 0, 0+i));
  
 -    strncpyz(p->comm, procfile_lineword(ff, 0, 1), MAX_COMPARE_NAME);
 +    if(unlikely(!p->comm[0]))
 +        strncpyz(p->comm, procfile_lineword(ff, 0, 1), MAX_COMPARE_NAME);
  
      // p->state         = *(procfile_lineword(ff, 0, 2));
 -    p->ppid             = (int32_t)str2ul(procfile_lineword(ff, 0, 3));
 +    p->ppid             = (int32_t)str2pid_t(procfile_lineword(ff, 0, 3));
      // p->pgrp          = str2ul(procfile_lineword(ff, 0, 4));
      // p->session       = str2ul(procfile_lineword(ff, 0, 5));
      // p->tty_nr        = str2ul(procfile_lineword(ff, 0, 6));
@@@ -937,9 -792,9 +937,9 @@@ static inline int read_proc_pid_io(stru
      file_counter++;
  
      p->last_io_collected_usec = p->io_collected_usec;
-     p->io_collected_usec = now_realtime_usec();
+     p->io_collected_usec = now_monotonic_usec();
  
 -    unsigned long long last;
 +    kernel_uint_t last;
  
      last = p->io_logical_bytes_read_raw;
      p->io_logical_bytes_read_raw = str2ull(procfile_lineword(ff, 0, 1));
@@@ -3069,13 -2913,10 +3069,10 @@@ int main(int argc, char **argv
          profiling_count++;
          if(unlikely(profiling_count > 1000)) exit(0);
  #else
-         while(now < next) {
-             sleep_usec(next - now);
-             now = now_realtime_usec();
-         }
+         heartbeat_next(&hb, step);
  #endif
  
 -        if(!collect_data_for_all_processes_from_proc()) {
 +        if(!collect_data_for_all_processes()) {
              error("Cannot collect /proc data for running processes. Disabling apps.plugin...");
              printf("DISABLE\n");
              exit(1);
          show_guest_time_old = show_guest_time;
  
          if(unlikely(debug))
 -            fprintf(stderr, "apps.plugin: done Loop No %llu\n", global_iterations_counter);
 +            fprintf(stderr, "apps.plugin: done Loop No %zu\n", global_iterations_counter);
  
-         time_t current_t = now_realtime_sec();
          // restart check (14400 seconds)
-         if(current_t - started_t > 14400) exit(0);
+         if(now_monotonic_sec() - started_t > 14400) exit(0);
      }
  }
Simple merge
Simple merge