[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: general question about lazy loading of shared libraries

Owen Taylor wrote:

On Thu, 2004-11-18 at 15:45 -0800, Roland McGrath wrote:

Directly-linked libraries are always loaded immediately on startup. Their PLT relocations may be deferred until used, but we always load the
libraries themselves and run their initializers at startup time.

To be clear here, any pages of the library that don't need to be modified to do relocations are only "loaded" in a bookkeeping sense - ld.so tells the kernel to mmap the library, and the kernel assigns the library a place in memory, but pages won't actually be read off disk until they are used.

One of the big ways that prelink reduces startup time is being
making the set of pages that need to be loaded to do relocations

I don't know an easy way to tell exactly what pages of the libraries you are using are touched and thus read off disk at start up... and it's
not even a well defined question - you can't tell if a page was read because of your app or because of another app.

You can get a general idea by looking at the display at top, roughly

VIRT - amount of memory your app has loaded in the bookkeeping sense
RES - subset of VIRT in memory at the current time
SHARE - subset of VIRT that some other application is also using


Thanks Owen, thats hopeful. My real goal is to avoid the disk activity for unused modules. It sounds like, to the extent that the libraries use one or more whole pages, that might actually happen.

I'm working on Graphviz graph layout tools that support multiple renderers. I'd like to link all the
renderers but only incur the disk i/o cost for the one thats used in a single invocation. I'm not concerned
about these libraries being shared with other apps, or other instances of the same app, since that will happen rarely,
and in any case then the disk i/o costs will be shared.

Does the deferred paging depend on prelinking having been performed?

Is there a way to detect the maximum RES memory used by a program before it exited (or before it exits if I need to instrument it)?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]