commit 977259281baa8a7a2776eefc691db02976cae993 from: Stefan Sperling date: Tue Aug 30 17:31:46 2022 UTC keep track of the size of the largest object which entered an object cache commit - 98275f2eefb932aee3f1824f53c268fd736f6c5f commit + 977259281baa8a7a2776eefc691db02976cae993 blob - b3a2cb74d16eb1cea91ea7e995e998721d06f5fc blob + ef9737b133c279be1e1781fc0b8145a641d1fc30 --- lib/got_lib_object_cache.h +++ lib/got_lib_object_cache.h @@ -42,6 +42,7 @@ struct got_object_cache { int cache_miss; int cache_evict; int cache_toolarge; + size_t max_cached_size; }; const struct got_error *got_object_cache_init(struct got_object_cache *, blob - 9a73324894a8116700bddcfd4f59c9a3a39dd2e5 blob + 59879ce1ea33b3512e7bffed54fff8cf2635952d --- lib/object_cache.c +++ lib/object_cache.c @@ -258,6 +258,8 @@ got_object_cache_add(struct got_object_cache *cache, s err = got_object_idset_add(cache->idset, id, ce); if (err) free(ce); + else if (size > cache->max_cached_size) + cache->max_cached_size = size; return err; } @@ -293,10 +295,12 @@ static void 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, %d too large\n", getprogname(), name, + "%d missed, %d evicted, %d too large, max cached %zd bytes\n", + getprogname(), name, got_object_idset_num_elements(cache->idset), cache->cache_searches, cache->cache_hit, - cache->cache_miss, cache->cache_evict, cache->cache_toolarge); + cache->cache_miss, cache->cache_evict, cache->cache_toolarge, + cache->max_cached_size); } static const struct got_error *