[repo stats] add cache size stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 11 Mar 2010 16:41:43 +0100
branchstable
changeset 4862 0d0e5279f65e
parent 4858 8c886610e5ee
child 4863 f6cf0fcd40ae
[repo stats] add cache size
server/repository.py
--- a/server/repository.py	Wed Mar 10 12:08:45 2010 +0100
+++ b/server/repository.py	Thu Mar 11 16:41:43 2010 +0100
@@ -365,10 +365,15 @@
     def stats(self): # XXX restrict to managers session?
         import threading
         results = {}
-        for hits, misses, title in (
-            (self.querier.cache_hit, self.querier.cache_miss, 'rqlt_st'),
-            (self.system_source.cache_hit, self.system_source.cache_miss, 'sql'),
+        querier = self.querier
+        source = self.system_source
+        for size, maxsize, hits, misses, title in (
+            (len(querier._rql_cache), self.config['rql-cache-size'],
+            querier.cache_hit, querier.cache_miss, 'rqlt_st'),
+            (len(source._cache), self.config['rql-cache-size'],
+            source.cache_hit, source.cache_miss, 'sql'),
             ):
+            results['%s_cache_size' % title] =  '%s / %s' % (size, maxsize)
             results['%s_cache_hit' % title] =  hits
             results['%s_cache_miss' % title] = misses
             results['%s_cache_hit_percent' % title] = (hits * 100) / (hits + misses)