commit - ab2f42e760e128287c5e880a39c591845231922b
commit + c3b318d03e2208287f9ada2f6f9c759dfc0ba576
blob - b9d4f89656dd56b278729ad6c522d9c453d476da
blob + b8d6ef35517c4f74859324be5b8a53ec24206dd6
--- lib/delta_cache.c
+++ lib/delta_cache.c
int nelem;
int maxelem;
size_t maxelemsize;
+ int cache_search;
+ int cache_hit;
+ int cache_miss;
+ int cache_evict;
+ int cache_toolarge;
};
struct got_delta_cache *
{
struct got_delta_cache_element *entry;
+#ifdef GOT_OBJ_CACHE_DEBUG
+ fprintf(stderr, "%s: delta cache: %d elements, %d searches, %d hits, "
+ "%d missed, %d evicted, %d too large\n", getprogname(), cache->nelem,
+ cache->cache_search, cache->cache_hit, cache->cache_miss,
+ cache->cache_evict, cache->cache_toolarge);
+#endif
while (!TAILQ_EMPTY(&cache->entries)) {
entry = TAILQ_FIRST(&cache->entries);
TAILQ_REMOVE(&cache->entries, entry, entry);
free(entry->delta_data);
free(entry);
cache->nelem--;
+ cache->cache_evict++;
}
{
struct got_delta_cache_element *entry;
- if (delta_len > cache->maxelemsize)
+ if (delta_len > cache->maxelemsize) {
+ cache->cache_toolarge++;
return got_error(GOT_ERR_NO_SPACE);
+ }
if (cache->nelem >= cache->maxelem)
remove_least_used_element(cache);
{
struct got_delta_cache_element *entry;
+ cache->cache_search++;
*delta_data = NULL;
*delta_len = 0;
TAILQ_FOREACH(entry, &cache->entries, entry) {
if (entry->delta_data_offset != delta_data_offset)
continue;
+ cache->cache_hit++;
if (entry != TAILQ_FIRST(&cache->entries)) {
TAILQ_REMOVE(&cache->entries, entry, entry);
TAILQ_INSERT_HEAD(&cache->entries, entry, entry);
*delta_len = entry->delta_len;
return;
}
+
+ cache->cache_miss++;
}