| 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
| 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 6 | <title>Configuring the memory pool</title> |
| 7 | <link rel="stylesheet" href="gettingStarted.css" type="text/css" /> |
| 8 | <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /> |
| 9 | <link rel="start" href="index.html" title="Berkeley DB Programmer's Reference Guide" /> |
| 10 | <link rel="up" href="mp.html" title="Chapter 18. The Memory Pool Subsystem" /> |
| 11 | <link rel="prev" href="mp.html" title="Chapter 18. The Memory Pool Subsystem" /> |
| 12 | <link rel="next" href="mp_warm.html" title="Warming the memory pool" /> |
| 13 | </head> |
| 14 | <body> |
| 15 | <div xmlns="" class="navheader"> |
| 16 | <div class="libver"> |
| 17 | <p>Library Version 11.2.5.3</p> |
| 18 | </div> |
| 19 | <table width="100%" summary="Navigation header"> |
| 20 | <tr> |
| 21 | <th colspan="3" align="center">Configuring the memory pool</th> |
| 22 | </tr> |
| 23 | <tr> |
| 24 | <td width="20%" align="left"><a accesskey="p" href="mp.html">Prev</a> </td> |
| 25 | <th width="60%" align="center">Chapter 18. |
| 26 | The Memory Pool Subsystem |
| 27 | </th> |
| 28 | <td width="20%" align="right"> <a accesskey="n" href="mp_warm.html">Next</a></td> |
| 29 | </tr> |
| 30 | </table> |
| 31 | <hr /> |
| 32 | </div> |
| 33 | <div class="sect1" lang="en" xml:lang="en"> |
| 34 | <div class="titlepage"> |
| 35 | <div> |
| 36 | <div> |
| 37 | <h2 class="title" style="clear: both"><a id="mp_config"></a>Configuring the memory pool</h2> |
| 38 | </div> |
| 39 | </div> |
| 40 | </div> |
| 41 | <p>There are two issues to consider when configuring the memory pool.</p> |
| 42 | <p>The first issue, the most important tuning parameter for Berkeley DB |
| 43 | applications, is the size of the memory pool. There are two ways to |
| 44 | specify the pool size. First, calling the <a href="../api_reference/C/envset_cachesize.html" class="olink">DB_ENV->set_cachesize()</a> method |
| 45 | specifies the pool size for all of the applications sharing the Berkeley DB |
| 46 | environment. Second, the <a href="../api_reference/C/dbset_cachesize.html" class="olink">DB->set_cachesize()</a> method only specifies a |
| 47 | pool size for the specific database. Note: It is meaningless to call |
| 48 | <a href="../api_reference/C/dbset_cachesize.html" class="olink">DB->set_cachesize()</a> for a database opened inside of a Berkeley DB |
| 49 | environment because the environment pool size will override any pool |
| 50 | size specified for a single database. For information on tuning the |
| 51 | Berkeley DB cache size, see |
| 52 | <a class="xref" href="general_am_conf.html#am_conf_cachesize" title="Selecting a cache size">Selecting a cache size</a>.</p> |
| 53 | <p> |
| 54 | Note the memory pool defaults to assuming that the average page size is |
| 55 | 4k. This factor is used to determine the size of the hash table used |
| 56 | to locate pages in the memory pool. The size of the hash table is |
| 57 | calculated to so that on average 2.5 pages will be in each hash table |
| 58 | entry. Each page requires a mutex be allocated to it and the average |
| 59 | page size is used to determine the number of mutexes to allocate to the |
| 60 | memory pool. |
| 61 | </p> |
| 62 | <p> |
| 63 | Normally you should see good results by using the default values for |
| 64 | the page size, but in some cases you may be able to achieve better |
| 65 | performance by manually configuring the page size. The expected page |
| 66 | size, hash table size and mutex count can be set via the methods: |
| 67 | <a href="../api_reference/C/envset_mp_pagesize.html" class="olink">DB_ENV->set_mp_pagesize()</a>, <a href="../api_reference/C/envset_mp_tablesize.html" class="olink">DB_ENV->set_mp_tablesize()</a>, and <a href="../api_reference/C/envset_mp_mtxcount.html" class="olink">DB_ENV->set_mp_mtxcount()</a>. |
| 68 | </p> |
| 69 | <p>The second memory pool configuration issue is the maximum size an |
| 70 | underlying file can be and still be mapped into the process address |
| 71 | space (instead of reading the file's pages into the cache). Mapping |
| 72 | files into the process address space can result in better performance |
| 73 | because available virtual memory is often much larger than the local |
| 74 | cache, and page faults are faster than page copying on many systems. |
| 75 | However, in the presence of limited virtual memory, it can cause |
| 76 | resource starvation; and in the presence of large databases, it can |
| 77 | result in immense process sizes. In addition, because of the |
| 78 | requirements of the Berkeley DB transactional implementation, only read-only |
| 79 | files can be mapped into process memory.</p> |
| 80 | <p>To specify that no files are to be mapped into the process address |
| 81 | space, specify the <a href="../api_reference/C/dbopen.html#open_DB_NOMMAP" class="olink">DB_NOMMAP</a> flag to the |
| 82 | <a href="../api_reference/C/envset_flags.html" class="olink">DB_ENV->set_flags()</a> method. To specify that any individual file should |
| 83 | not be mapped into the process address space, specify the |
| 84 | <a href="../api_reference/C/dbopen.html#open_DB_NOMMAP" class="olink">DB_NOMMAP</a> flag to the <a href="../api_reference/C/mempfopen.html" class="olink">DB_MPOOLFILE->open()</a> interface. To limit |
| 85 | the size of files mapped into the process address space, use the |
| 86 | <a href="../api_reference/C/envset_mp_mmapsize.html" class="olink">DB_ENV->set_mp_mmapsize()</a> method.</p> |
| 87 | </div> |
| 88 | <div class="navfooter"> |
| 89 | <hr /> |
| 90 | <table width="100%" summary="Navigation footer"> |
| 91 | <tr> |
| 92 | <td width="40%" align="left"><a accesskey="p" href="mp.html">Prev</a> </td> |
| 93 | <td width="20%" align="center"> |
| 94 | <a accesskey="u" href="mp.html">Up</a> |
| 95 | </td> |
| 96 | <td width="40%" align="right"> <a accesskey="n" href="mp_warm.html">Next</a></td> |
| 97 | </tr> |
| 98 | <tr> |
| 99 | <td width="40%" align="left" valign="top">Chapter 18. |
| 100 | The Memory Pool Subsystem |
| 101 | </td> |
| 102 | <td width="20%" align="center"> |
| 103 | <a accesskey="h" href="index.html">Home</a> |
| 104 | </td> |
| 105 | <td width="40%" align="right" valign="top"> Warming the memory pool</td> |
| 106 | </tr> |
| 107 | </table> |
| 108 | </div> |
| 109 | </body> |
| 110 | </html> |