23 #if defined(GEN_CACHE_STATS)
26 #endif // GEN_CACHE_STATS
94 #if defined(GEN_CACHE_STATS)
102 freenull(entry.dbpath);
103 #endif // GEN_CACHE_STATS
113 big_data_min_size(max_data_size / 4)
119 #if defined(GEN_CACHE_STATS)
123 #endif // GEN_CACHE_STATS
126 #if defined(GEN_CACHE_STATS)
127 static void sum_hash_values(
const char *,
long val,
void *client_data) {
128 size_t *sum = (
size_t*)client_data;
131 static void list_hash_entries(
const char *key,
long val,
void *client_data) {
136 printf(
"%s %li (%5.2f)\n", key, val, (
double)reuse_sum/val);
139 printf(
"%s %li\n", key, val);
142 #endif // GEN_CACHE_STATS
150 #if defined(GEN_CACHE_STATS)
151 size_t NotReUsed = 0;
159 size_t overall = NotReUsed+ReUsed;
161 printf(
"Cache stats:\n"
162 "Overall entries: %zu\n"
163 "Reused entries: %zu (%5.2f%%)\n"
164 "Mean reuse count: %5.2f\n",
166 ReUsed, (
double)ReUsed/overall*100.0,
167 (
double)ReUseSum/ReUsed);
175 #endif // GEN_CACHE_STATS
180 char *cached_data =
NULp;
194 cached_data = entry.
data;
195 #if defined(GEN_CACHE_STATS)
197 #endif // GEN_CACHE_STATS
239 long need_to_free = needed_mem-avail_mem;
244 if (need_to_free>(
long)cache.
sum_data_size) need_to_free = 0;
281 #if defined(GEN_CACHE_STATS)
284 #endif // GEN_CACHE_STATS
static char * cache_free_some_memory(gb_cache &cache, size_t needed_mem)
void GBS_hash_do_const_sorted_loop(const GB_HASH *hs, gb_hash_const_loop_type func, gbs_hash_compare_function sorter, void *client_data)
char * GB_set_cache_size(GBDATA *gbd, size_t size)
GBDATA * GB_child(GBDATA *father)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
long GBS_incr_hash(GB_HASH *hs, const char *key)
GB_MAIN_TYPE * GB_MAIN(GBDATA *gbd)
char * ARB_strdup(const char *str)
void GBS_free_hash(GB_HASH *hs)
char * gb_read_cache(GBENTRY *gbe)
gb_cache_idx firstfree_entry
gb_cache_idx oldest_entry
void flush_cache_entry(gb_cache &cache, gb_cache_idx index)
TYPE * ARB_alloc(size_t nelem)
const int GB_TOTAL_CACHE_SIZE
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
char * gb_alloc_cache_index(GBENTRY *gbe, size_t size)
bool is_container() const
void gb_free_cache(GB_MAIN_TYPE *Main, GBENTRY *gbe)
static void gb_uncache(GBCONTAINER *gbc)
GBCONTAINER * as_container() const
void GB_flush_cache(GBDATA *gbd)
bool entry_is_linked(gb_cache &cache, gb_cache_idx index)
TYPE * ARB_calloc(size_t nelem)
gb_cache_entry & unlink_cache_entry(gb_cache &cache, gb_cache_idx index)
const char * GB_get_db_path(GBDATA *gbd)
int GBS_HCF_sortedByKey(const char *k0, long dummy_1x, const char *k1, long dummy_2x)
GBENTRY * as_entry() const
GBDATA * GB_nextChild(GBDATA *child)
gb_cache_idx newest_entry
const int GB_MAX_CACHED_ENTRIES
void link_cache_entry_to_top(gb_cache &cache, gb_cache_idx index)
long GBS_read_hash(const GB_HASH *hs, const char *key)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)