0

Let's say I have two binaries which perform the same task - they convert complex data from one format to another.

I will run them on a busy server at low priority and I don't really care if one is faster than the other - I want to know which of them will have lower "CPU impact" to perform the same task.

binary_1:

26879408.172126      task-clock:u (msec)       #    0.709 CPUs utilized
              0      context-switches:u        #    0.000 K/sec
              0      cpu-migrations:u          #    0.000 K/sec
     1142192473      page-faults:u             #    0.042 M/sec
 81241884199345      cycles:u                  #    3.022 GHz                      (83.59%)
 65593453047217      stalled-cycles-frontend:u #   80.74% frontend cycles idle     (83.59%)
 34800591044061      stalled-cycles-backend:u  #   42.84% backend cycles idle      (67.09%)
 98783244945290      instructions:u            #    1.22  insn per cycle
                                               #    0.66  stalled cycles per insn  (83.64%)
 18250463170335      branches:u                #  678.976 M/sec                    (83.60%)
   169450790563      branch-misses:u           #    0.93% of all branches          (83.59%)

37911.679793230 seconds time elapsed

binary_2:

33134123.016486      task-clock:u (msec)       #    1.071 CPUs utilized
              0      context-switches:u        #    0.000 K/sec
              0      cpu-migrations:u          #    0.000 K/sec
     1947142971      page-faults:u             #    0.059 M/sec
105227191042973      cycles:u                  #    3.176 GHz                      (83.69%)
 80721331715962      stalled-cycles-frontend:u #   76.71% frontend cycles idle     (83.69%)
 46245245856602      stalled-cycles-backend:u  #   43.95% backend cycles idle      (67.25%)
140459525725760      instructions:u            #    1.33  insn per cycle
                                               #    0.57  stalled cycles per insn  (83.93%)
  9187630340020      branches:u                #  277.286 M/sec                    (83.70%)
   112107883833      branch-misses:u           #    1.22% of all branches          (83.69%)

30949.033426941 seconds time elapsed

As you can see, binary_1 was executing for 37911 seconds, and binary_2 for 30949 seconds.

On the other hand, binary_2 used more cycles and instructions.

Because I will be running it on a busy server, I think that binary_1 will have lower impact on the CPU (and, other tasks). Is my reasoning correct?

Tomasz
  • 179
  • 12
  • 1
    Define "CPU impact". – Jakuje Dec 19 '16 at 16:38
  • You measure CPU cycles only in user-space (:u), while the time is counted for userspace + kernel, so probably the first binary spends more time in kernel. – Ilya Verbin Dec 19 '16 at 16:48
  • > Define "CPU impact". Extreme example: "sleep 1m" will have less CPU impact than "gzip -c 10_GB_file >/dev/null", although they might execute similar amount of time and their end result will be similar (result defined as console blocked for more or less 1 minute). Based on that, I know that I will be able to run lots of "sleep 1m" commands at the same time before all CPUs saturate; on the other hand, I will be only able to run a handful of "gzip -c 10_GB_file >/dev/null" at the same time before all CPUs saturate. – Tomasz Dec 20 '16 at 02:18
  • cycles:u are not counting when CPU is halted. – Ilya Verbin Dec 20 '16 at 11:08

0 Answers0