Named shared library areas

By default, AIX® shares libraries among processes using a global set of segments, referred to as the global shared library area.

For 32-bit processes, this area consists of one segment for shared library text (segment 0xD) and one segment for pre-relocated library data (segment 0xF). Sharing text and pre-relocating data improves performance on systems where a large number of processes use common shared libraries.

Because the global shared library area is a single fixed-size resource, attempts to share a set of libraries that exceed the capacity of the area cannot succeed. In this situation, a portion of a process libraries are loaded privately. Loading libraries privately, as opposed to shared, consumes private address space in the process and places greater demands on paging space, leading to a degradation in overall system performance.

To address this limitation of the global shared library area, AIX 5.3 supports named shared library areas, which include the following benefits:

  • A named shared library area replaces the global shared library area for a group of processes.
  • A named shared library area enables a group of processes to have the full shared library capacity available to them at the same location in the effective address space as the global shared library area (segments 0xD and 0xF).
  • The named shared library area feature is enabled via the LDR_CNTRL environment variable and no changes are required to existing binaries.
  • Multiple named shared library areas can be active on the system simultaneously.
  • Processes specify a particular named shared library area by a unique name. This name is chosen by the process that causes the area’s creation.
  • Named shared library areas are available for use only by 32-bit processes.

Because the use of a specific named shared library area is restricted to processes that request it, none of its space will be consumed by processes using the global shared library area or a different named shared library area. This decrease in competition for space in the named shared library area benefits processes using the area. These processes experience lower private address space consumption and a greater ability to share libraries among themselves. Use of a named shared library area among processes that utilize common shared libraries can optimize the processes' address space usage and decrease demands on paging space, resulting in enhanced overall system performance.

Alternate memory model (doubletext32)

In addition to the default shared library area memory model (one segment dedicated to shared library text and one segment dedicated to pre-relocated library data), named shared library areas support an alternate memory model that dedicates both segments to shared library text. This model is useful for process groups that share greater than 256 MB of library text. Note that since this alternate memory model performs no pre-relocation of library data, some performance degradation during module loading (for both exec-time dependencies and dynamically loaded modules) may be experienced. Therefore, the actual performance benefits of increased shared library text capacity should be considered on a case by case basis.

Interface

Access

A process requests the use of a named shared library area by having the LDR_CNTRL environment variable with the NAMEDSHLIB option in its environment at run time. The syntax of the new option is as follows:

NAMEDSHLIB=name[,attribute][,attribute2]...[,attributeN]

A valid name string can be any string matching the regular expression, [A-Za-z0-9_\.]+ (containing only alphanumeric, underbar, and period characters).

A valid name string must be terminated by one of the following characters:

  • @ (at sign): The delimiter for multiple LDR_CNTRL options
  • , (comma): The delimiter for NAMEDSHLIB attributes
  • \0 (null): The terminator of the LDR_CNTRL environment string

If an invalid name string is specified, the entire NAMEDSHLIB option is ignored. If an invalid attribute is specified, only that attribute is ignored. Currently, there is only one supported attribute: doubletext32.

There are no access restrictions for using named shared library areas. All requests for use of an area are granted.

Creation

There is no explicit interface to create a named shared library area. When a process requests the use of a named shared library area that does not exist, the area is automatically created.

Purging

The system removes unused libraries from a named shared library area using the same mechanisms that apply to the global shared library area:
  • Automatic removal of unused libraries occurs when the area becomes full.
  • Forced removal of unsused libraries can be accomplished using the slibclean command.

Destruction

There is no explicit interface to destroy a named shared library area. When the last process using a named shared library area exits (the usecount of the area drops to zero), the area is automatically destroyed.

Attributes

The NAMEDSHLIB attributes are examined by the system loader only during named shared library area creation. Therefore, requests to use an existing named shared library area are not strictly required to specify attributes matching those specified at creation (the request will not fail because of an attribute mismatch). However, because the system automatically destroys unused named shared library areas, it is good practice to always specify attributes, even when you are requesting the use of an existing named shared library area.

Examples

  1. Run a pair of applications using the named shared library area named XYZ with one segment dedicated to shared library text and one segment dedicated to pre-relocated library data by running the following commands:
    $ export LDR_CNTRL=NAMEDSHLIB=XYZ
    $ xyz_app
    $ xyz_app2
  2. Run a pair of applications using the named shared library area named more_shtext with both segments dedicated to shared library text by running the following commands:
    $ export LDR_CNTRL=NAMEDSHLIB=more_shtext,doubletext32
    $ mybigapp
    $ mybigapp2