dwarves: Add -O2 to CFLAGS

Using the defaults, which uses no -O flags:

  [acme@quaco pahole]$ grep CMAKE_C_FLAGS_RELEASE CMakeLists.txt
  set(CMAKE_C_FLAGS_RELEASE "-Wall")
  [acme@quaco pahole]$ perf stat -r5 pahole -J vmlinux

   Performance counter stats for 'pahole -J vmlinux' (5 runs):

           18,516.09 msec task-clock:u              #    1.000 CPUs utilized            ( +-  0.55% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
             548,753      page-faults:u             #    0.030 M/sec                    ( +-  0.00% )
      68,498,897,915      cycles:u                  #    3.699 GHz                      ( +-  0.05% )
     123,209,200,210      instructions:u            #    1.80  insn per cycle           ( +-  0.00% )
      25,484,050,414      branches:u                # 1376.319 M/sec                    ( +-  0.00% )
         366,334,745      branch-misses:u           #    1.44% of all branches          ( +-  0.03% )

              18.518 +- 0.102 seconds time elapsed  ( +-  0.55% )

  [acme@quaco pahole]$

With this patch, using -O2:

  [acme@quaco pahole]$ grep CMAKE_C_FLAGS_RELEASE CMakeLists.txt
  set(CMAKE_C_FLAGS_RELEASE "-Wall -O2")
  [acme@quaco pahole]$ perf stat -r5 pahole -J vmlinux

   Performance counter stats for 'pahole -J vmlinux' (5 runs):

           12,645.96 msec task-clock:u              #    1.000 CPUs utilized            ( +-  0.61% )
                   0      context-switches:u        #    0.000 K/sec
                   0      cpu-migrations:u          #    0.000 K/sec
             548,744      page-faults:u             #    0.043 M/sec                    ( +-  0.00% )
      45,359,248,873      cycles:u                  #    3.587 GHz                      ( +-  0.03% )
      84,051,005,257      instructions:u            #    1.85  insn per cycle           ( +-  0.00% )
      19,755,005,738      branches:u                # 1562.159 M/sec                    ( +-  0.00% )
         365,276,883      branch-misses:u           #    1.85% of all branches          ( +-  0.12% )

             12.6471 +- 0.0771 seconds time elapsed  ( +-  0.61% )

  [acme@quaco pahole]$

Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@fb.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Alexei Starovoitov 2019-12-16 11:15:54 -03:00 committed by Arnaldo Carvalho de Melo
parent 6d11dd157f
commit 69df73444c
1 changed files with 2 additions and 2 deletions

View File

@ -27,8 +27,8 @@ if (NOT CMAKE_BUILD_TYPE)
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -ggdb")
set(CMAKE_C_FLAGS_RELEASE "-Wall")
set(CMAKE_C_FLAGS_DEBUG "-Wall -Werror -ggdb -O2")
set(CMAKE_C_FLAGS_RELEASE "-Wall -O2")
add_definitions(-D_GNU_SOURCE -DDWARVES_VERSION="v1.15")
find_package(DWARF REQUIRED)