,I%Berkeley DB: memp_stat[P

memp_stat





#include <db.h>

int,memp_stat(DB_MPOOL *mp, DB_MPOOL_STAT **gsp,: DB_MPOOL_FSTAT *(*fsp)[], void *(*db_malloc)(size_t));





Description



GThe memp_stat function method creates statistical structures and copiesFpointers to them into user-specified memory locations. The statisticsGinclude the number of files participating in the pool, the active pagesDin the pool, and information as to how effective the cache has been.

7Statistical structures are created in allocated memory.IfBdb_malloc is non-NULL, it is called to allocate the memory,:otherwise, the library function malloc(3)) is used.CThe function db_malloc must match the calling conventions of&the malloc(3)) library routine.CRegardless, the caller is responsible for deallocating the returnedmemory.ETo deallocate the returned memory, free each returned memory pointer;@pointers inside the memory do not need to be individually freed.

DIf gsp is non-NULL, the global statistics for the memory poolAmp are copied into the memory location it references. TheBglobal statistics are stored in a structure of type DB_MPOOL_STAT.

5The following DB_MPOOL_STAT fields will be filled in:

C
u_int32_t st_refcnt;
The number of references to the region.4
u_int32_t st_regsize;
The size of the region.0
size_t st_cachesize;
Cache size in bytes.B
u_int32_t st_cache_hit;
Requested pages found in the cache.G
u_int32_t st_cache_miss;
Requested pages not found in the cache.\
u_int32_t st_map;
Requested pages mapped into the process' address space (there is noHavailable information as to whether or not this request caused disk I/O,Calthough examining the application page fault rate may be helpful).<
u_int32_t st_page_create;
Pages created in the cache.7
u_int32_t st_page_in;
Pages read into the cache.O
u_int32_t st_page_out;
Pages written from the cache to the backing file.@
u_int32_t st_ro_evict;
Clean pages forced from the cache.@
u_int32_t st_rw_evict;
Dirty pages forced from the cache.N
u_int32_t st_hash_buckets;
Number of hash buckets in buffer hash table.M
u_int32_t st_hash_searches;
Total number of buffer hash table lookups.b
u_int32_t st_hash_longest;
The longest chain ever encountered in buffer hash table lookups.e
u_int32_t st_hash_examined;
Total number of hash elements traversed during hash table lookups.C
u_int32_t st_page_clean;
Clean pages currently in the cache.C
u_int32_t st_page_dirty;
Dirty pages currently in the cache.†
u_int32_t st_page_trickle;
Dirty pages written using the memp_trickle interface.g
u_int32_t st_region_wait;
The number of times that a thread of control was forced to wait beforeobtaining the region lock.b
u_int32_t st_region_nowait;
The number of times that a thread of control was able to obtain the region lock without waiting.
BIf fsp is non-NULL, a pointer to a NULL-terminated variableNlength array of statistics for individual files, in the memory pool mp,Iis copied into the memory location it references. If no individual filesCcurrently exist in the memory pool, fsp will be set to NULL.

HThe per-file statistics are stored in structures of type DB_MPOOL_FSTAT.FThe following DB_MPOOL_FSTAT fields will be filled in for each file in*the pool, i.e., each element of the array:

-
char *file_name;
The name of the file..
size_t st_pagesize;
Page size in bytes.B
u_int32_t st_cache_hit;
Requested pages found in the cache.G
u_int32_t st_cache_miss;
Requested pages not found in the cache.P
u_int32_t st_map;
Requested pages mapped into the process' address space.<
u_int32_t st_page_create;
Pages created in the cache.7
u_int32_t st_page_in;
Pages read into the cache.O
u_int32_t st_page_out;
Pages written from the cache to the backing file.


The memp_statHfunction returns the value of errno on failure, and 0 on success.



Errors

RIf a fatal error occurs in Berkeley DB, the memp_stat function may fail and returnFDB_RUNRECOVERY, at which point all subsequent database calls will alsoreturn DB_RUNRECOVERY.

The memp_stat)function may fail and return errnoKfor any of the errors specified for the following Berkeley DB and C library functions: abort(3), fcntl(3), fprintf(3), getpid(3), malloc(3), memcpy(3), memset(3),and strlen(3).In addition, the memp_stat)function may fail and return errnofor the following conditions:

B

EINVAL
An invalid flag value or parameter was specified.







See Also

8memp_close,=memp_fclose,9memp_fget,;memp_fopen,9memp_fput,9memp_fset,;memp_fsync,6memp_open,Amemp_register, memp_stat, memp_stat,6memp_sync,;memp_trickleand:memp_unlink.
ÿÿ