本文介绍了将-rdynamic链接器选项添加到gcc / g ++会影响性能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我想在应用程序崩溃时获取堆栈跟踪。我明白,-rdynamic选项可以使用函数名称获取完整的堆栈跟踪。但是我担心是否会对我的应用程序的性能产生任何影响。

解决方案

是的,虽然它非常具体,通常也不值得关注。 b

-rdynamic选项指示链接器向符号表中添加符号,这些符号在运行时通常不需要。这意味着动态链接程序需要在运行时扫描符号解析的符号的数量可能更多。



具体而言,由于基于GNU的符号表查找系统使用散列来实现,具有更多符号会增加散列冲突的可能性。由于在哈希表中碰撞的所有symols都位于列表中,因此运行时链接程序需要遍历列表并使用memcmp比较每个符号名称。有更多的符号碰撞在散列意义有更长的列表,所以它将需要更多的时间来解决每个动态符号。



这种情况稍微恶化的C ++和C,与由于类名,大量的带有相同前缀的符号名称。



实际上,这只是第一次使用符号,所以除非您的应用程序非常大,并包含很多符号,它不会被感觉。



在极少数情况下,您的应用程序非常庞大,像可以用来克服开销。


I want to get the stack trace when the application crashes. I understand that the -rdynamic option enables to get the complete stack trace with the function names. But I'm concerned if there will be any impact on the performance of my application.

解决方案

Yes, there is, although it is very specific and normally not a cause of concern.

The -rdynamic option instructs the linker to add symbols to the symbol tables that are not normally needed at run time. It means there are more, possibly many more, symbols that the dynamic linker needs to weed through at run time for symbol resolution.

Specifically, since symbol table lookups in GNU based systems are implemented using a hash, having more symbols increases the chance that there would be hash collisions. Since all symols that collide in the hash table sit in a list, the run time linker needs to traverse the list and compare, using memcmp, each symbol name. Having more symbols collide in the hash meaning having longer lists and so it will take more time to resolve each dynamic symbol.

This situation is slightly worse for C++ then C, with the multitude of identically prefixed symbol names due to class names.

In practice, this only effects the very first time that a symbol is used and so, unless your application is very large and contains a lot of symbols, it will not be felt.

In the rare case that your application is that large, tricks like prelinking can be used to overcome the overhead.

这篇关于将-rdynamic链接器选项添加到gcc / g ++会影响性能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 11:44