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: DbEnv::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>DbEnv::memp_stat</b> 14</td> 15<td align=right> 16<a href="/api_cxx/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 <db_cxx.h> 23<p> 24int 25DbEnv::memp_stat(DB_MPOOL_STAT **gsp, 26 DB_MPOOL_FSTAT *(*fsp)[], u_int32_t flags); 27<p> 28int 29DbEnv::memp_stat_print(u_int32_t flags); 30</pre></b> 31<hr size=1 noshade> 32<b>Description: DbEnv::memp_stat</b> 33<p>The DbEnv::memp_stat method returns the memory pool (that is, the buffer 34cache) subsystem statistics.</p> 35<p>The DbEnv::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_cxx/env_set_alloc.html">DbEnv::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_cxx/env_set_cache_max.html">DbEnv::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_cxx/memp_trickle.html">DbEnv::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 DbEnv::memp_stat method may not be called before the <a href="/api_cxx/env_open.html">DbEnv::open</a> method is called.</p> 120<p>The DbEnv::memp_stat method 121either returns a non-zero error value 122or throws an exception that encapsulates a non-zero error value on 123failure, and returns 0 on success. 124</p> 125<b>Parameters</b> <br> 126 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or 127the following value: 128<br> 129<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after returning their values.</ul> 130<br></ul> 131 <b>fsp</b><ul compact><li>The <b>fsp</b> parameter references memory into which 132a pointer to the allocated per-file statistics structures is copied.</ul> 133 <b>gsp</b><ul compact><li>The <b>gsp</b> parameter references memory into which 134a pointer to the allocated global statistics structure is copied.</ul> 135<br> 136<br><b>Errors</b> 137<p>The DbEnv::memp_stat method 138may fail and throw 139<a href="/api_cxx/except_class.html">DbException</a>, 140encapsulating one of the following non-zero errors, or return one of 141the following non-zero errors:</p> 142<br> 143<b>EINVAL</b><ul compact><li>An 144invalid flag value or parameter was specified.</ul> 145<br> 146<hr size=1 noshade> 147<b>Description: DbEnv::memp_stat_print</b> 148<p>The DbEnv::memp_stat_print method displays the 149memory pool subsystem statistical information, as described for the DbEnv::memp_stat method. 150The information is printed to a specified output channel (see the 151<a href="/api_cxx/env_set_msgfile.html">DbEnv::set_msgfile</a> method for more information), or passed to an 152application callback function (see the <a href="/api_cxx/env_set_msgcall.html">DbEnv::set_msgcall</a> method for 153more information).</p> 154<p>The DbEnv::memp_stat_print method may not be called before the <a href="/api_cxx/env_open.html">DbEnv::open</a> method is called.</p> 155<p>The DbEnv::memp_stat_print method 156either returns a non-zero error value 157or throws an exception that encapsulates a non-zero error value on 158failure, and returns 0 on success. 159</p> 160<b>Parameters</b> <br> 161 <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 162or more of the following values: 163<br> 164<b><a name="DB_STAT_ALL">DB_STAT_ALL</a></b><ul compact><li>Display all available information.</ul> 165<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after displaying their values.</ul> 166<b><a name="DB_STAT_MEMP_HASH">DB_STAT_MEMP_HASH</a></b><ul compact><li>Display the buffers with hash chains.</ul> 167<br></ul> 168<br> 169<hr size=1 noshade> 170<br><b>Class</b> 171<a href="/api_cxx/env_class.html">DbEnv</a>, <a href="/api_cxx/mempfile_class.html">DbMpoolFile</a> 172<br><b>See Also</b> 173<a href="/api_cxx/memp_list.html">Memory Pools and Related Methods</a> 174</tt> 175<table width="100%"><tr><td><br></td><td align=right> 176<a href="/api_cxx/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a> 177</td></tr></table> 178<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 179</body> 180</html> 181