hamsterdb Embedded Database 1.1.13
|
Internal hamsterdb Embedded Storage statistics gathering and hinting functions. More...
#include <ham/hamsterdb.h>
Go to the source code of this file.
Internal hamsterdb Embedded Storage statistics gathering and hinting functions.
Please be aware that the interfaces in this file are mostly for internal use. Unlike those in hamsterdb.h they are not stable and can be changed with every new version.
Definition in file hamsterdb_stats.h.
#define HAM_FREELIST_SLOT_SPREAD (16-5+1) |
As we [can] support record sizes up to 4Gb, at least theoretically, we can express this size range as a spanning DB_CHUNKSIZE size range: 1..N, where N = log2(4Gb) - log2(DB_CHUNKSIZE). As we happen to know DB_CHUNKSIZE == 32, at least for all regular hamsterdb builds, our biggest power-of-2 for the freelist slot count ~ 32-5 = 27, where 0 represents slot size = 1 DB_CHUNKSIZE, 1 represents size of 2 DB_CHUNKSIZEs, 2 ~ 4 DB_CHUNKSIZEs, and so on.
EDIT: In order to cut down on statistics management cost due to overhead caused by having to keep up with the latest for VERY large sizes, we cut this number down to support sizes up to a maximum size of 64Kb ~ 2^16, meaning any requests for more than 64Kb/CHUNKSIZE bytes is sharing their statistics.
Definition at line 71 of file hamsterdb_stats.h.
#define HAM_STATISTICS_HIGH_WATER_MARK 0x7FFFFFFF |
The upper bound value which will trigger a statistics data rescale operation to be initiated in order to prevent integer overflow in the statistics data elements.
Definition at line 52 of file hamsterdb_stats.h.
typedef void ham_free_statistics_func_t(ham_statistics_t *self) |
function prototype for the hamsterdb-specified ham_statistics_t cleanup function.
Definition at line 45 of file hamsterdb_stats.h.
typedef struct ham_freelist_page_statistics_t ham_freelist_page_statistics_t |
freelist statistics as they are persisted on disc.
Stats are kept with each freelist entry record, but we also keep some derived data in the nonpermanent space with each freelist: it's not required to keep a freelist page in cache just so the statistics + our operational mode combined can tell us it's a waste of time to go there.
typedef struct ham_freelist_slotsize_stats_t ham_freelist_slotsize_stats_t |
We keep track of VERY first free slot index + free slot index pointing at last (~ supposed largest) free range + 'utilization' of the range between FIRST and LAST as a ratio of number of free slots in there vs. total number of slots in that range (giving us a 'fill' ratio) + a fragmentation indication, determined by counting the number of freelist slot searches that FAILed vs. SUCCEEDed within the first..last range, when the search begun at the 'first' position (a FAIL here meaning the freelist scan did not deliver a free slot WITHIN the first..last range, i.e. it has scanned this entire range without finding anything suitably large).
Note that the free_fill in here is AN ESTIMATE.
typedef struct ham_runtime_statistics_dbdata_t ham_runtime_statistics_dbdata_t |
global freelist algorithm specific run-time info: per cache
Statistics gathered specific per operation (find, insert, erase)
typedef struct ham_statistics_t ham_statistics_t |
Definition at line 34 of file hamsterdb_stats.h.
HAM_EXPORT ham_status_t HAM_CALLCONV ham_clean_statistics_datarec | ( | ham_statistics_t * | stats | ) |
Invoke the optional ham_statistics_t content cleanup function.
This function will check whether the ham_statistics_t free/cleanup callback has been set or not before invoking it.
stats | A pointer to a valid ham_statistics_t data structure. 'Valid' means you must call this ham_clean_statistics_datarec() function after having called ham_env_get_parameters or ham_get_parameters with a HAM_PARAM_GET_STATISTICS ham_parameter_t entry which had this ham_statistics_t reference stats attached and before either the related ham_db_t or ham_env_t handles are closed (ham_env_close/ham_close) or deleted (ham_env_delete/ham_delete). |