1<!--$Id: memp_stat.so,v 10.72 2007/09/21 20:06:03 bostic Exp $-->
2<!--Copyright (c) 1997,2008 Oracle.  All rights reserved.-->
3<!--See the file LICENSE for redistribution information.-->
4<html>
5<head>
6<title>Berkeley DB: DB_ENV-&gt;memp_stat</title>
7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit.">
8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++">
9</head>
10<body bgcolor=white>
11<table width="100%"><tr valign=top>
12<td>
13<b>DB_ENV-&gt;memp_stat</b>
14</td>
15<td align=right>
16<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a>
17<a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a></td>
18</tr></table>
19<hr size=1 noshade>
20<tt>
21<b><pre>
22#include &lt;db.h&gt;
23<p>
24int
25DB_ENV-&gt;memp_stat(DB_ENV *env, DB_MPOOL_STAT **gsp,
26    DB_MPOOL_FSTAT *(*fsp)[], u_int32_t flags);
27<p>
28int
29DB_ENV-&gt;memp_stat_print(DB_ENV *env, u_int32_t flags);
30</pre></b>
31<hr size=1 noshade>
32<b>Description: DB_ENV-&gt;memp_stat</b>
33<p>The DB_ENV-&gt;memp_stat method returns the memory pool (that is, the buffer
34cache) subsystem statistics.</p>
35<p>The DB_ENV-&gt;memp_stat method creates statistical structures of type DB_MPOOL_STAT
36and DB_MPOOL_FSTAT, and copy pointers to them into user-specified memory
37locations.  The cache statistics are stored in the DB_MPOOL_STAT structure
38and the per-file cache statistics are stored the DB_MPOOL_FSTAT structure.</p>
39<p>Statistical structures are stored in allocated memory.  If application-specific allocation
40routines have been declared (see <a href="../api_c/env_set_alloc.html">DB_ENV-&gt;set_alloc</a> for more
41information), they are used to allocate the memory; otherwise, the
42standard C library <b>malloc</b>(3) is used.  The caller is
43responsible for deallocating the memory.  To deallocate the memory, free
44the memory reference; references inside the returned memory need not be
45individually freed.</p>
46<p>If <b>gsp</b> is non-NULL, the global statistics for the cache
47<b>mp</b> are copied into the memory location to which it refers.
48The following DB_MPOOL_STAT fields will be filled in:</p>
49<br>
50<b>size_t st_gbytes;</b><ul compact><li>Gigabytes of cache (total cache size is st_gbytes + st_bytes).</ul>
51<b>size_t st_bytes;</b><ul compact><li>Bytes of cache (total cache size is st_gbytes + st_bytes).</ul>
52<b>u_int32_t st_ncache;</b><ul compact><li>Number of caches.</ul>
53<b>u_int32_t st_max_ncache;</b><ul compact><li>Maximum number of caches, as configured with the
54<a href="../api_c/env_set_cache_max.html">DB_ENV-&gt;set_cache_max</a> method.</ul>
55<b>roff_t st_regsize;</b><ul compact><li>Individual cache size, in bytes.</ul>
56<b>size_t st_mmapsize;</b><ul compact><li>Maximum memory-mapped file size.</ul>
57<b>int st_maxopenfd;</b><ul compact><li>Maximum open file descriptors.</ul>
58<b>int st_maxwrite;</b><ul compact><li>Maximum sequential buffer writes.</ul>
59<b>db_timeout_t st_maxwrite_sleep;</b><ul compact><li>Microseconds to pause after writing maximum sequential buffers.</ul>
60<b>u_int32_t st_map;</b><ul compact><li>Requested pages mapped into the process' address space (there is no
61available information about whether or not this request caused disk I/O,
62although examining the application page fault rate may be helpful).</ul>
63<b>u_int32_t st_cache_hit;</b><ul compact><li>Requested pages found in the cache.</ul>
64<b>u_int32_t st_cache_miss;</b><ul compact><li>Requested pages not found in the cache.</ul>
65<b>u_int32_t st_page_create;</b><ul compact><li>Pages created in the cache.</ul>
66<b>u_int32_t st_page_in;</b><ul compact><li>Pages read into the cache.</ul>
67<b>u_int32_t st_page_out;</b><ul compact><li>Pages written from the cache to the backing file.</ul>
68<b>u_int32_t st_ro_evict;</b><ul compact><li>Clean pages forced from the cache.</ul>
69<b>u_int32_t st_rw_evict;</b><ul compact><li>Dirty pages forced from the cache.</ul>
70<b>u_int32_t st_page_trickle;</b><ul compact><li>Dirty pages written using the <a href="../api_c/memp_trickle.html">DB_ENV-&gt;memp_trickle</a> method.</ul>
71<b>u_int32_t st_pages;</b><ul compact><li>Pages in the cache.</ul>
72<b>u_int32_t st_page_clean;</b><ul compact><li>Clean pages currently in the cache.</ul>
73<b>u_int32_t st_page_dirty;</b><ul compact><li>Dirty pages currently in the cache.</ul>
74<b>u_int32_t st_hash_buckets;</b><ul compact><li>Number of hash buckets in buffer hash table.</ul>
75<b>u_int32_t st_hash_searches;</b><ul compact><li>Total number of buffer hash table lookups.</ul>
76<b>u_int32_t st_hash_longest;</b><ul compact><li>Longest chain ever encountered in buffer hash table lookups.</ul>
77<b>u_int32_t st_hash_examined;</b><ul compact><li>Total number of hash elements traversed during hash table lookups.</ul>
78<b>u_int32_t st_hash_nowait;</b><ul compact><li>Number of times that a thread of control was able to obtain a hash
79bucket lock without waiting.</ul>
80<b>u_int32_t st_hash_wait;</b><ul compact><li>Number of times that a thread of control was forced to wait before
81obtaining a hash bucket lock.</ul>
82<b>u_int32_t st_hash_max_nowait;</b><ul compact><li>The number of times a thread of control was able to obtain the hash
83bucket lock without waiting on the bucket which had the maximum number
84of times that a thread of control needed to wait.</ul>
85<b>u_int32_t st_hash_max_wait;</b><ul compact><li>Maximum number of times any hash bucket lock was waited for by a
86thread of control.</ul>
87<b>u_int32_t st_region_wait;</b><ul compact><li>Number of times that a thread of control was forced to wait before
88obtaining a cache region mutex.</ul>
89<b>u_int32_t st_region_nowait;</b><ul compact><li>Number of times that a thread of control was able to obtain a cache
90region mutex without waiting.</ul>
91<b>u_int32_t st_mvcc_frozen;</b><ul compact><li>Number of buffers frozen.</ul>
92<b>u_int32_t st_mvcc_thawed;</b><ul compact><li>Number of buffers thawed.</ul>
93<b>u_int32_t st_mvcc_freed;</b><ul compact><li>Number of frozen buffers freed.</ul>
94<b>u_int32_t st_alloc;</b><ul compact><li>Number of page allocations.</ul>
95<b>u_int32_t st_alloc_buckets;</b><ul compact><li>Number of hash buckets checked during allocation.</ul>
96<b>u_int32_t st_alloc_max_buckets;</b><ul compact><li>Maximum number of hash buckets checked during an allocation.</ul>
97<b>u_int32_t st_alloc_pages;</b><ul compact><li>Number of pages checked during allocation.</ul>
98<b>u_int32_t st_alloc_max_pages;</b><ul compact><li>Maximum number of pages checked during an allocation.</ul>
99<b>u_int32_t st_io_wait;</b><ul compact><li>Number of operations blocked waiting for I/O to complete.</ul>
100<br>
101<p>If <b>fsp</b> is non-NULL, a pointer to a NULL-terminated
102variable length array of statistics for individual files, in the cache
103<b>mp</b>, is copied into the memory location to which it refers.  If
104no individual files currently exist in the cache, <b>fsp</b> will be
105set to NULL.</p>
106<p>The per-file statistics are stored in structures of type DB_MPOOL_FSTAT.
107The following DB_MPOOL_FSTAT fields will be filled in for each file in
108the cache; that is, each element of the array:</p>
109<br>
110<b>char * file_name;</b><ul compact><li>The name of the file.</ul>
111<b>size_t st_pagesize;</b><ul compact><li>Page size in bytes.</ul>
112<b>u_int32_t st_cache_hit;</b><ul compact><li>Requested pages found in the cache.</ul>
113<b>u_int32_t st_cache_miss;</b><ul compact><li>Requested pages not found in the cache.</ul>
114<b>u_int32_t st_map;</b><ul compact><li>Requested pages mapped into the process' address space.</ul>
115<b>u_int32_t st_page_create;</b><ul compact><li>Pages created in the cache.</ul>
116<b>u_int32_t st_page_in;</b><ul compact><li>Pages read into the cache.</ul>
117<b>u_int32_t st_page_out;</b><ul compact><li>Pages written from the cache to the backing file.</ul>
118<br>
119<p>The DB_ENV-&gt;memp_stat method may not be called before the <a href="../api_c/env_open.html">DB_ENV-&gt;open</a> method is called.</p>
120<p>The DB_ENV-&gt;memp_stat method
121returns a non-zero error value on failure
122and 0 on success.
123</p>
124<b>Parameters</b> <br>
125 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or
126the following value:
127<br>
128<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after returning their values.</ul>
129<br></ul>
130 <b>fsp</b><ul compact><li>The <b>fsp</b> parameter references memory into which
131a pointer to the allocated per-file statistics structures is copied.</ul> 
132 <b>gsp</b><ul compact><li>The <b>gsp</b> parameter references memory into which
133a pointer to the allocated global statistics structure is copied.</ul> 
134<br>
135<br><b>Errors</b>
136<p>The DB_ENV-&gt;memp_stat method
137may fail and return one of the following non-zero errors:</p>
138<br>
139<b>EINVAL</b><ul compact><li>An
140invalid flag value or parameter was specified.</ul>
141<br>
142<hr size=1 noshade>
143<b>Description: DB_ENV-&gt;memp_stat_print</b>
144<p>The DB_ENV-&gt;memp_stat_print method displays the
145memory pool subsystem statistical information, as described for the DB_ENV-&gt;memp_stat method.
146The information is printed to a specified output channel (see the
147<a href="../api_c/env_set_msgfile.html">DB_ENV-&gt;set_msgfile</a> method for more information), or passed to an
148application callback function (see the <a href="../api_c/env_set_msgcall.html">DB_ENV-&gt;set_msgcall</a> method for
149more information).</p>
150<p>The DB_ENV-&gt;memp_stat_print method may not be called before the <a href="../api_c/env_open.html">DB_ENV-&gt;open</a> method is called.</p>
151<p>The DB_ENV-&gt;memp_stat_print method
152returns a non-zero error value on failure
153and 0 on success.
154</p>
155<b>Parameters</b> <br>
156 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one
157or more of the following values:
158<br>
159<b><a name="DB_STAT_ALL">DB_STAT_ALL</a></b><ul compact><li>Display all available information.</ul>
160<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after displaying their values.</ul>
161<b><a name="DB_STAT_MEMP_HASH">DB_STAT_MEMP_HASH</a></b><ul compact><li>Display the buffers with hash chains.</ul>
162<br></ul>
163<br>
164<hr size=1 noshade>
165<br><b>Class</b>
166<a href="../api_c/env_class.html">DB_ENV</a>, <a href="../api_c/mempfile_class.html">DB_MPOOLFILE</a>
167<br><b>See Also</b>
168<a href="../api_c/memp_list.html">Memory Pools and Related Methods</a>
169</tt>
170<table width="100%"><tr><td><br></td><td align=right>
171<a href="../api_c/api_core.html"><img src="../images/api.gif" alt="API"></a><a href="../ref/toc.html"><img src="../images/ref.gif" alt="Ref"></a>
172</td></tr></table>
173<p><font size=1>Copyright (c) 1996,2008 Oracle.  All rights reserved.</font>
174</body>
175</html>
176