commit - a60c9e772e2560a97c782a5dbe5269e6c5ad9d1f
commit + 01cd76145e99ea71ca66e60e659e21237b1240e6
blob - a10ff39474235e35fee9cc7454d03acf7f84bb72
blob + 4ac0ad0c7b384591131160ddd363b928e57c7d5e
--- lib/got_lib_object_cache.h
+++ lib/got_lib_object_cache.h
int cache_hit;
int cache_miss;
int cache_evict;
+ int cache_toolarge;
};
const struct got_error *got_object_cache_init(struct got_object_cache *,
blob - 4de69f14eb9159f85ebe50c0f1ddb6a976312e33
blob + 5c1d8d2b63a844a8451233a1009e6677e4303090
--- lib/object_cache.c
+++ lib/object_cache.c
break;
}
- if (size > GOT_OBJECT_CACHE_MAX_ELEM_SIZE)
+ if (size > GOT_OBJECT_CACHE_MAX_ELEM_SIZE) {
+#ifdef GOT_OBJ_CACHE_DEBUG
+ char *id_str;
+ if (got_object_id_str(&id_str, id) != NULL)
+ return got_error_from_errno("got_object_id_str");
+ fprintf(stderr, "%s: not caching ", getprogname());
+ switch (cache->type) {
+ case GOT_OBJECT_CACHE_TYPE_OBJ:
+ fprintf(stderr, "object");
+ break;
+ case GOT_OBJECT_CACHE_TYPE_TREE:
+ fprintf(stderr, "tree");
+ break;
+ case GOT_OBJECT_CACHE_TYPE_COMMIT:
+ fprintf(stderr, "commit");
+ break;
+ case GOT_OBJECT_CACHE_TYPE_TAG:
+ fprintf(stderr, "tag");
+ break;
+ }
+ fprintf(stderr, " %s (%zd bytes; %zd MB)\n", id_str, size,
+ size/1024/1024);
+ free(id_str);
+#endif
+ cache->cache_toolarge++;
return NULL;
+ }
nelem = got_object_idset_num_elements(cache->idset);
if (nelem >= cache->size) {
print_cache_stats(struct got_object_cache *cache, const char *name)
{
fprintf(stderr, "%s: %s cache: %d elements, %d searches, %d hits, "
- "%d missed, %d evicted\n", getprogname(), name,
+ "%d missed, %d evicted, %d too large\n", getprogname(), name,
got_object_idset_num_elements(cache->idset),
cache->cache_searches, cache->cache_hit,
- cache->cache_miss, cache->cache_evict);
+ cache->cache_miss, cache->cache_evict, cache->cache_toolarge);
}
const struct got_error *