Debian Codegraph @

docs/programmer_reference/mp.html

raw symbols SCIP
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>Chapter 18.  The Memory Pool Subsystem</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="index.html" title="Berkeley DB Programmer's Reference Guide" />
11 <link rel="prev" href="log_limits.html" title="Log file limits" />
12 <link rel="next" href="mp_config.html" title="Configuring 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">Chapter 18. 
22 The Memory Pool Subsystem
23 </th>
24 </tr>
25 <tr>
26 <td width="20%" align="left"><a accesskey="p" href="log_limits.html">Prev</a> </td>
27 <th width="60%" align="center"> </th>
28 <td width="20%" align="right"> <a accesskey="n" href="mp_config.html">Next</a></td>
29 </tr>
30 </table>
31 <hr />
32 </div>
33 <div class="chapter" lang="en" xml:lang="en">
34 <div class="titlepage">
35 <div>
36 <div>
37 <h2 class="title"><a id="mp"></a>Chapter 18. 
38 The Memory Pool Subsystem
39 </h2>
40 </div>
41 </div>
42 </div>
43 <div class="toc">
44 <p>
45 <b>Table of Contents</b>
46 </p>
47 <dl>
48 <dt>
49 <span class="sect1">
50 <a href="mp.html#mp_intro">Introduction to the memory pool subsystem</a>
51 </span>
52 </dt>
53 <dt>
54 <span class="sect1">
55 <a href="mp_config.html">Configuring the memory pool</a>
56 </span>
57 </dt>
58 <dt>
59 <span class="sect1">
60 <a href="mp_warm.html">Warming the memory pool</a>
61 </span>
62 </dt>
63 <dd>
64 <dl>
65 <dt>
66 <span class="sect2">
67 <a href="mp_warm.html#warm_cache">The warm_cache() function</a>
68 </span>
69 </dt>
70 </dl>
71 </dd>
72 </dl>
73 </div>
74 <div class="sect1" lang="en" xml:lang="en">
75 <div class="titlepage">
76 <div>
77 <div>
78 <h2 class="title" style="clear: both"><a id="mp_intro"></a>Introduction to the memory pool subsystem</h2>
79 </div>
80 </div>
81 </div>
82 <p>The Memory Pool subsystem is the general-purpose shared memory buffer
83 pool used by Berkeley DB. This module is useful outside of the Berkeley DB package
84 for processes that require page-oriented, shared and cached file
85 access. (However, such "use outside of Berkeley DB" is not supported
86 in replicated environments.)</p>
87 <p>A <span class="emphasis"><em>memory pool</em></span> is a memory cache shared among any number of
88 threads of control. The <a href="../api_reference/C/envopen.html#envopen_DB_INIT_MPOOL" class="olink">DB_INIT_MPOOL</a> flag to the
89 <a href="../api_reference/C/envopen.html" class="olink">DB_ENV-&gt;open()</a> method opens and optionally creates a memory pool. When
90 that pool is no longer in use, it should be closed using the
91 <a href="../api_reference/C/envclose.html" class="olink">DB_ENV-&gt;close()</a> method.</p>
92 <p>The <a href="../api_reference/C/mempfcreate.html" class="olink">DB_ENV-&gt;memp_fcreate()</a> method returns a <a href="../api_reference/C/memp.html" class="olink">DB_MPOOLFILE</a> handle on an
93 underlying file within the memory pool. The file may be opened using
94 the <a href="../api_reference/C/mempfopen.html" class="olink">DB_MPOOLFILE-&gt;open()</a> method. The <a href="../api_reference/C/mempfget.html" class="olink">DB_MPOOLFILE-&gt;get()</a> method is used to retrieve
95 pages from files in the pool. All retrieved pages must be subsequently
96 returned using the <a href="../api_reference/C/mempput.html" class="olink">DB_MPOOLFILE-&gt;put()</a> method. At the time pages are returned,
97 they may be marked <span class="bold"><strong>dirty</strong></span>, which causes them to be written to
98 the underlying file before being discarded from the pool. If there is
99 insufficient room to bring a new page in the pool, a page is selected
100 to be discarded from the pool using a least-recently-used algorithm.
101 All dirty pages in the pool from the file may be flushed using the
102 <a href="../api_reference/C/mempfsync.html" class="olink">DB_MPOOLFILE-&gt;sync()</a> method. When the file handle is no longer in use, it
103 should be closed using the <a href="../api_reference/C/mempfclose.html" class="olink">DB_MPOOLFILE-&gt;close()</a> method.</p>
104 <p>There are additional configuration interfaces that apply when opening
105 a new file in the memory pool:</p>
106 <div class="itemizedlist">
107 <ul type="disc">
108 <li>The <a href="../api_reference/C/mempset_clear_len.html" class="olink">DB_MPOOLFILE-&gt;set_clear_len()</a> method specifies the number of bytes to clear
109 when creating a new page in the memory pool.</li>
110 <li>The <a href="../api_reference/C/mempset_fileid.html" class="olink">DB_MPOOLFILE-&gt;set_fileid()</a> method specifies a unique ID associated with the file.</li>
111 <li>The <a href="../api_reference/C/mempset_ftype.html" class="olink">DB_MPOOLFILE-&gt;set_ftype()</a> method specifies the type of file for the purposes of
112 page input and output processing.</li>
113 <li>The <a href="../api_reference/C/mempset_lsn_offset.html" class="olink">DB_MPOOLFILE-&gt;set_lsn_offset()</a> method specifies the byte offset of each page's
114 log sequence number (<a href="../api_reference/C/lsn.html" class="olink">DB_LSN</a>) for the purposes of transaction
115 checkpoints.</li>
116 <li>The <a href="../api_reference/C/mempset_pgcookie.html" class="olink">DB_MPOOLFILE-&gt;set_pgcookie()</a> method specifies an application provided argument
117 for the purposes of page input and output processing.</li>
118 </ul>
119 </div>
120 <p>There are additional interfaces for the memory pool as a whole:</p>
121 <div class="itemizedlist">
122 <ul type="disc">
123 <li>It is possible to gradually flush buffers from the pool in order to
124 maintain a consistent percentage of clean buffers in the pool using
125 the <a href="../api_reference/C/memptrickle.html" class="olink">DB_ENV-&gt;memp_trickle()</a> method.</li>
126 <li>Because special-purpose processing may be necessary when pages are read
127 or written (for example, endian conversion, or page checksums), the
128 <a href="../api_reference/C/mempregister.html" class="olink">DB_ENV-&gt;memp_register()</a> function allows applications to specify automatic
129 input and output processing in these cases.</li>
130 <li>The <a href="../api_reference/C/db_stat.html" class="olink">db_stat</a> utility uses the <a href="../api_reference/C/mempstat.html" class="olink">DB_ENV-&gt;memp_stat()</a> method to display
131 statistics about the efficiency of the pool.</li>
132 <li>All dirty pages in the pool may be flushed using the <a href="../api_reference/C/mempsync.html" class="olink">DB_ENV-&gt;memp_sync()</a> method.
133 In addition, <a href="../api_reference/C/mempsync.html" class="olink">DB_ENV-&gt;memp_sync()</a> takes an argument that is specific to
134 database systems, and which allows the memory pool to be flushed up to
135 a specified log sequence number (<a href="../api_reference/C/lsn.html" class="olink">DB_LSN</a>).</li>
136 <li>The entire pool may be discarded using the <a href="../api_reference/C/envremove.html" class="olink">DB_ENV-&gt;remove()</a> method.</li>
137 </ul>
138 </div>
139 <p>For more information on the memory pool subsystem methods, see the <a href="../api_reference/C/memp.html#memplist" class="olink">Memory Pools and Related Methods</a> section in the <em class="citetitle">Berkeley DB C API Reference Guide.</em> </p>
140 </div>
141 </div>
142 <div class="navfooter">
143 <hr />
144 <table width="100%" summary="Navigation footer">
145 <tr>
146 <td width="40%" align="left"><a accesskey="p" href="log_limits.html">Prev</a> </td>
147 <td width="20%" align="center"> </td>
148 <td width="40%" align="right"> <a accesskey="n" href="mp_config.html">Next</a></td>
149 </tr>
150 <tr>
151 <td width="40%" align="left" valign="top">Log file limits </td>
152 <td width="20%" align="center">
153 <a accesskey="h" href="index.html">Home</a>
154 </td>
155 <td width="40%" align="right" valign="top"> Configuring the memory pool</td>
156 </tr>
157 </table>
158 </div>
159 </body>
160 </html>