English 中文(简体)
共用图书馆与静态图书馆的联络时间
原标题:Loading time for shared libraries vs static libraries

我对共享图书馆和固定图书馆装货时间有问题。

Assume that i have a executable foo.exe which used liba, libb, libc. 另外,在某个时候,机器上还有十多起可起诉的机器。

Now if the above 3 libraries were shared libraries : 1st Insance is loaded into RAM : The time taken will be time taken by main() of foo.exe to be loaded memory (assuming its negligible) + time to load liba + time to load libb + time to load libc 2nd instance is started : Now assume a second instance of this executable is run. Since all libraries are already loaded into the main memory, time taken is only for loading the main() to the memory which is negligible .

Now if the above 3 libraries were static libraries : 1st Insance is loaded into RAM : The time taken will be time taken by main() of foo.exe to be loaded memory (assuming its negligible) + time to load liba + time to load libb + time to load libc (Offcourse its now all part of the executable as a whole) 2nd instance is started : Now assume a second instance of this executable is run. Time taken will be again time taken by main() of foo.exe to be loaded memory (assuming its negligible) + time to load liba + time to load libb + time to load libc. (Since each executable cant share librareies as these are static librareies)

因此,我的结论是,随着静态图书馆的建立,装货时间将会增加。 但是,有人告诉我,共用图书馆在装船时比静态图书馆要花更多的时间,因此会出现拖延,因此共用图书馆不是一个好的选择。 如何做到这一点?

最佳回答

联系(解决参考资料)不是免费的。 随着静态连接,该决议一劳永逸地产生双轨。 随着动态连接,每当双筒装满时都必须做。 更不用说,编纂成共用图书馆的法典,其效率可能低于固定链接的编码。 确切的费用取决于结构以及系统动态连接的实施。

The cost of making a library dynamic can be relatively high for the 32-bit x86 instruction set: in the ELF binary format, one of the already scarce registers has to be sacrificed to make dynamically linked code relocatable. The older a.out format placed each shared library at a fixed place, but that didn t scale. I believe that Mac OS X has had an intermediate system when dynamic libraries where placed in pre-determined locations in the address space, but the conflicts were resolved at the scale of the individual computer (the lengthy "Optimizing system performance" phase after installing new software). In a way, this system (called pre-binding) allows you to have your cake and eat it too. I do not know if prebinding is still necessary now that Apple pretty much switched to the amd64 architecture.

此外,在现代职业介绍所,固定和动态联系的代码在使用时只从磁盘上载(以纸页),但这与你的问题相当棘手。

问题回答

法定图书馆在编纂时连接起来,共享图书馆在运行时连接起来。 因此,使用静态图书馆的应诉人甚至在被写到磁盘之前就将其所有链接时间摊销。

令人难以置信的快速应对办法有很多。 我们有2种无政府状态:

Q1. Architecure-1 :Assume exe volume 3GB(法定图书馆)。 95%为图书馆,5%为主()。 如此庞大的面积将需要更多的时间(假定静态图书馆),或需要更多的时间(假设使用共享图书馆,如果所有图书馆已经记忆中只需要链接的话)。

Architecure-2:Assume i有1.5GB(95%的校准+5%的主()),6个例同时运行。 一旦这6个案子被搁置了几天,假设我们准备在最初的6个案子加连时会遇到额外的拖延。

问题2. 现在,如果我使用共有物体,而不是固定物体,那么在援助团内就会有很多自由的空间,因为所有图书馆都是在6个事件中共享的? 我的实时执行速度不会加快,因为援助团的面积会增加,从而减少了页数的瓦解?

问题3. 如果使用地图文档来减少出口象征的数量(只有使用共享图书馆才能这样做),那么我的文号表规模不会减少,也不会改善操作时间的业绩?

Thanks Sud





相关问题
How to combine shared libraries?

I ve got some .so libraries that I d like to combine into one shared library so that it doesn t depend on the original .so files anymore. The .so files have dependencies to each other. How can I do ...

Shared library in Go?

Is it possible to create a Shared Library (.so) using Go? UPDATED: created an "issue" for it.

Create a shared lib using another shared lib

I have a shared library "libwiston.so". I am using this to create another shared library called "libAnimation.so", which will be used by another project. Now, the second library "libAnimation.so" can ...

Load multiple copies of a shared library

I am running Linux, and I would like to be able to make parallel function calls into a shared library (.so) which is unfortunately not threadsafe (I am guessing it has global datastructures). For ...

热门标签