The global symbol table is implemented using a hash table. Under this mechanism, whenever a library is loaded (either implicitly or by using dlopen() or shl_load()), the mechanism hashes the library's exports and places them into this table. When a library is unloaded, the mechanism looks up the library's exports in the table and removes them.

The hash table does not contain entries for symbols defined by shl_definesym(). User-defined symbols must therefore be handled separately. Enabling the mechanism causes the dynamic loader to use more memory and impacts the performance of the dlopen(), dlclose(), shl_load(), and shl_unload() API calls.

With the global symbol table, the dynamic loader may need to perform a large number of hashing operations to locate symbols. Performing this hash function may cost considerable time, especially when symbol names are very long (C++ programs). To speed up dld, computing hash values can be off-loaded to the linker.

Use the +gst options, +gst, +gstbuckets (PA-32 only), +gstsize, +nodynhash (PA-64 and IPF only), and +plabel_cache, (PA-32 only), to control the behavior of the global symbol table hash mechanism. See the ld(1) and chatr(1) manpages for information on these options.

With these options, you can tune the size of the hash table and number of buckets per entry to reach a balance of performance and memory use. To maximize for performance, tune the table size for an average chain length of one. For maximum memory use, at the expense of performance, tune the size of the table to minimize the number of empty entries. In general, use prime numbers for the table size. The mechanism provides default values of table size, 1103, and number of buckets, 3.

To get statistical information about hash table performance, set the environment variable

_HP_DLDOPTS to contain -symtab_enable and -symtab_stat options. These options provide a message for each library that contains the following information:

Operation (load/unload)

Name of library

Name of library

Number of exports

Number of entries in table with no stored symbols

Average length of non-zero chains

Calculated performance of the hash table

Amount of memory used by the hash table

Improving Performance by Optimizing the Hash Table Size

The -nbucket <pow2primen/2> linker option enables the user to optimize the hash table size (number of hash buckets).

The -nbucket pow2 option sets the number of hash buckets to the highest power of 2 that is less than the number of dynamic symbols in the library.

The -nbucketprime option sets the number of hash buckets to the largest prime number that is less than the number of dynamic symbols in the library. The prime option is set as the default -nbucketoption.

The -nbucket n/2 option sets the number of hash buckets to half the number of dynamic symbols in the library.

The -nbucketprime option can significantly improve the distribution in the hash table, and the pow2 option can significantly reduce the amount of time taken by dld in arithmetic computations while traversing hash chains. To determine the option that optimizes the hash table size for an application, run the target application for each of the -nbucketoptions with the _HP_DLDOPTS environment variable set to -time.

Improving Performance by Optimizing the Hash Table Size 221