How To Write Shared Libraries(17)

1.6 Summary of the Costs of ELF(1)

We have now discussed the startup process and how it is affected by the form of the binaries. We will now summarize the various factors so that we later on can determine the benefits of an optimization more easily.
我们现在讨论进程启动过程和它是如何被程序的格式所影响的。现在总结跟踪情况,以便后续更容易的选择优化策略。

Code Size
As everywhere, a reduced size for code with the same semantics often means higher efficiency and performance. Smaller ELF binaries need less memory at run-time.
任何地方,更小的大小意味着更好的效率和性能表现。小程序需要更少的运行时内存空间。

In general the compiler will always generate the best code possible and we do not cover this further. But it must be known that every DSO includes a certain overhead in data and code. Therefore fewer DSOs means smaller text.
一般编译器总是生成尽可能好的程序,我们不必关心。但你必须了解,每个DSO都有一些数据和代码。因此,更少的DSO意味着更小。

Number of Objects
The fact that a smaller number of objects containing the same functionality is bene- ficial has been mentioned in several places:
实际上一个小数量的对象包含相同的功能有几个优点:

• Fewer objects are loaded at run-time. This directly translates to fewer system call. In the GNU dynamic linker implementation loading a DSO requires at least 8 system calls, all of them can be potentially quite expensive.
运行时加载更少的对象。这样直接就是减少了系统调用。在GNU的动态链接器中加载一个DSO至少需要8个系统调用,都可能非常耗时。
• Related, the application and the dependencies with additional dependencies must record the names of the dependencies. This is not a terribly high cost but certainly can sum up if there are many dozens of dependencies.
相关的,应用和依赖依赖的内容需要记住依赖内容的名字。这不是很耗时,但如果有许多一点总和会高。
• The lookup scope grows. This is one of the dominating factors in cost equation for the relocations.
查找范围的增长。一次的主要的过程相当于重定位。(待完善)
• More objects means more symbol tables which in turn normally means more duplication. Undefined references are not collapsed into one and handling of multiple definitions have to be sorted out by the dynamic linker.
Moreover, symbols are often exported from a DSO to be used in another one. This would not have to happen if the DSOs would be merged.
更多的对象意味着更多的表格,一般意义上就有更多的冲突。为定义的引用没有收集到一起,必须排序处理多处定义。
一般导出给其他DSO使用。如果合并就没有这些问题。
• The sorting of initializers/finalizers is more complicated.
排序构造和析构过程更复杂。
• Ingeneral does the dynamic linker have some overhead for each loaded DSO per process. Every time a new DSO is requested the list of already loaded DSOs must be searched which can be quite time consuming since DSOs can have many aliases.
一般动态链接器都有通用操作部分。每次一个新的DSO加载到列表,已经加载的必须搜索一次,这样执行多次,因为DSO有多个别名。

Number of Symbols
The number of exported and undefined symbols determines the size of the dynamic symbol table, the hash table, and the average hash table chain length. The normal symbol table is not used at run-time and it is therefore not necessary to strip a binary of it. It has no impact on performance.
导出的未定义的语法标记决定了动态表、hash表、和链表平均长度。一般的表格不是运行时使用的,因此不需要删除,无运行时影响。

Additionally, fewer exported symbols means fewer chances for conflicts when using pre-linking (not covered further).
另外,更少的导出内容意味着更少的预链接冲突。

你可能感兴趣的:(How To Write Shared Libraries(17))