]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
chore: Improve inode cache logging
authorJoel Rosdahl <joel@rosdahl.net>
Sat, 5 Nov 2022 11:43:03 +0000 (12:43 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sat, 5 Nov 2022 11:45:36 +0000 (12:45 +0100)
- Only log inode cache hits/misses in debug mode.
- Always log accumulated inode statistics at program exit.

src/InodeCache.cpp

index 5985cd5b612c4d3a94041b10a183280899152432..7c98f47fa09b60f977275a2149c3216e88d38acf 100644 (file)
@@ -382,6 +382,10 @@ InodeCache::InodeCache(const Config& config) : m_config(config)
 InodeCache::~InodeCache()
 {
   if (m_sr) {
+    LOG("Accumulated stats for inode cache: hits={}, misses={}, errors={}",
+        m_sr->hits.load(),
+        m_sr->misses.load(),
+        m_sr->errors.load());
     munmap(m_sr, sizeof(SharedRegion));
   }
 }
@@ -430,18 +434,13 @@ InodeCache::get(const std::string& path,
     return false;
   }
 
-  LOG("Inode cache {}: {}", found ? "hit" : "miss", path);
-
   if (m_config.debug()) {
+    LOG("Inode cache {}: {}", found ? "hit" : "miss", path);
     if (found) {
       ++m_sr->hits;
     } else {
       ++m_sr->misses;
     }
-    LOG("Accumulated stats for inode cache: hits={}, misses={}, errors={}",
-        m_sr->hits.load(),
-        m_sr->misses.load(),
-        m_sr->errors.load());
   }
   return found;
 }