Berkeley DB Reference Guide: Memory Pool Subsystem
Google

ee,hash,hashing,transaction,transactions,locking,logging,access method,access me thods,java,C,C++">

Berkeley DB Reference Guide: Memory Pool Subsystem

Configuring the memory pool

There are two parameters for configuring the memory pool.

The most important tuning parameter for almost all applications (including Berkeley DB applications), is the size of the pool. There are two ways to specify the pool size. First, by setting the mp_size field in the DB_ENV structure. This specifies the pool size for all of the applications sharing the Berkeley DB environment. Second, by setting the db_cachesize field in the DB_INFO structure. The latter only specifies a pool size for the specific database. Note, it is meaningless to set the db_cachesize field for a database opened inside of a Berkeley DB environment, since the environment pool size will override any pool size specified for a single database. For information on tuning the Berkeley DB cache size, see Selecting a cache size.

The second memory pool configuration parameter is the maximum size of backing files to map into the process address space instead of copying pages through the local cache.

Note, only read-only database files can be mapped into process memory. Because of the requirements of Berkeley DB's transactional implementation, log records describing database changes must be written to disk before the actual database changes. As mapping read-write database files into process memory would permit the underlying operating system to write modified database changes at will, it is not supported.

Mapping files into the process address space can result in better-than-usual performance, as available virtual memory is normally much larger than the local cache, and page faults are faster than page copying on many systems. However, in the presence of limited virtual memory it can cause resource starvation, and in the presence of large databases, it can result in immense process sizes.

To specify that no files are to be mapped into the process address space, specify the DB_NOMMAP flag to the db_appinit or memp_open interface. To specify that any individual file should not be mapped into the process address space, specify the DB_NOMMAP flag to the memp_open interface. To limit the maximum size of files mapped into the process address space, set the mp_mmapsize field in the DB_INFO structure.