Performance 使用-gdwarf-2编译时编程速度更快
我有一个程序,在一个线程中进行一些繁重的计算。有一个debug和release版本,它们都具有相同的命令行参数,只是debug版本得到-gdwarf-2。有趣的是,带有调试符号的版本比没有调试符号的版本运行速度快10%左右 我检查了两个版本中的文件,没有发现任何差异。所有部分(文本、bss、数据)的大小大致相同。在这两种模式下生成的汇编器看起来相似,只是结尾不同。发布版本以以下内容结束:Performance 使用-gdwarf-2编译时编程速度更快,performance,gcc,dwarf,Performance,Gcc,Dwarf,我有一个程序,在一个线程中进行一些繁重的计算。有一个debug和release版本,它们都具有相同的命令行参数,只是debug版本得到-gdwarf-2。有趣的是,带有调试符号的版本比没有调试符号的版本运行速度快10%左右 我检查了两个版本中的文件,没有发现任何差异。所有部分(文本、bss、数据)的大小大致相同。在这两种模式下生成的汇编器看起来相似,只是结尾不同。发布版本以以下内容结束: num_of_entries: .quad 10000 .local _ZStL8__
num_of_entries:
.quad 10000
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.weakref _ZL28__gthrw___pthread_key_createPjPFvPvE,__pthread_key_create
.hidden DW.ref.__gxx_personality_v0
.weak DW.ref.__gxx_personality_v0
.section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
.align 8
.type DW.ref.__gxx_personality_v0, @object
.size DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
.quad __gxx_personality_v0
.hidden __dso_handle
.ident "GCC: (GNU) 4.9.4"
.section .note.GNU-stack,"",@progbits
num_of_entries:
.quad 10000
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.weakref _ZL28__gthrw___pthread_key_createPjPFvPvE,__pthread_key_create
.text
.Letext0:
.section .text.unlikely
.Letext_cold0:
.file 29 "/common/pkgs/gcc/4.9.4/include/c++/4.9.4/type_traits"
.file 30 "/common/pkgs/gcc/4.9.4/include/c++/4.9.4/bits/cpp_type_traits.h"
...
.file 104 "/common/pkgs/gcc/4.9.4/include/c++/4.9.4/cxxabi.h"
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x59e75
.value 0x2
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .LASF6801
.byte 0x4
.long .LASF6802
.long .LASF6803
.long .Ldebug_ranges0+0x75a0
.quad 0
.quad 0
.long .Ldebug_line0
.uleb128 0x2
.string "std"
.byte 0x36
.byte 0
而调试版本有如下内容:
num_of_entries:
.quad 10000
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.weakref _ZL28__gthrw___pthread_key_createPjPFvPvE,__pthread_key_create
.hidden DW.ref.__gxx_personality_v0
.weak DW.ref.__gxx_personality_v0
.section .data.DW.ref.__gxx_personality_v0,"awG",@progbits,DW.ref.__gxx_personality_v0,comdat
.align 8
.type DW.ref.__gxx_personality_v0, @object
.size DW.ref.__gxx_personality_v0, 8
DW.ref.__gxx_personality_v0:
.quad __gxx_personality_v0
.hidden __dso_handle
.ident "GCC: (GNU) 4.9.4"
.section .note.GNU-stack,"",@progbits
num_of_entries:
.quad 10000
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.weakref _ZL28__gthrw___pthread_key_createPjPFvPvE,__pthread_key_create
.text
.Letext0:
.section .text.unlikely
.Letext_cold0:
.file 29 "/common/pkgs/gcc/4.9.4/include/c++/4.9.4/type_traits"
.file 30 "/common/pkgs/gcc/4.9.4/include/c++/4.9.4/bits/cpp_type_traits.h"
...
.file 104 "/common/pkgs/gcc/4.9.4/include/c++/4.9.4/cxxabi.h"
.section .debug_info,"",@progbits
.Ldebug_info0:
.long 0x59e75
.value 0x2
.long .Ldebug_abbrev0
.byte 0x8
.uleb128 0x1
.long .LASF6801
.byte 0x4
.long .LASF6802
.long .LASF6803
.long .Ldebug_ranges0+0x75a0
.quad 0
.quad 0
.long .Ldebug_line0
.uleb128 0x2
.string "std"
.byte 0x36
.byte 0
我使用的是GCC4.9。有人能给我一个提示或建议我怎么做吗
更新:
perf stat显示了一些有趣的数字:
对于带有调试符号的版本:
70,953,691 cache-references
11,332,829 cache-misses # 15.972 % of all cache refs
26,489,515,232 cycles
60,272,811,599 instructions # 2.28 insns per cycle
13,027,834,737 branches
64,798 faults
1 migrations
19 context-switches
7.181574550 seconds time elapsed
70,256,938 cache-references
11,960,752 cache-misses # 17.024 % of all cache refs
27,858,492,922 cycles
59,522,994,867 instructions # 2.14 insns per cycle
12,779,462,973 branches
65,212 faults
1 migrations
19 context-switches
7.550653346 seconds time elapsed
对于没有调试符号的版本:
70,953,691 cache-references
11,332,829 cache-misses # 15.972 % of all cache refs
26,489,515,232 cycles
60,272,811,599 instructions # 2.28 insns per cycle
13,027,834,737 branches
64,798 faults
1 migrations
19 context-switches
7.181574550 seconds time elapsed
70,256,938 cache-references
11,960,752 cache-misses # 17.024 % of all cache refs
27,858,492,922 cycles
59,522,994,867 instructions # 2.14 insns per cycle
12,779,462,973 branches
65,212 faults
1 migrations
19 context-switches
7.550653346 seconds time elapsed
发布版本上的缓存未命中率似乎更高,即使所有操作都应该相同。您的目标体系结构是什么?x86-64是目标体系结构Windows?马科斯…安卓请相应地更新您的问题。linux是目标archIt不可能在没有看到任何代码的情况下说出任何明确的信息。大会的任何一项决议都没有任何相关性。