28 class StatsService(Service): |
28 class StatsService(Service): |
29 """Return a dictionary containing some statistics about the repository |
29 """Return a dictionary containing some statistics about the repository |
30 resources usage. |
30 resources usage. |
31 """ |
31 """ |
32 |
32 |
33 __regid__ = 'repo_stats' |
33 __regid__ = 'repo_stats' |
34 __select__ = match_user_groups('managers', 'users') |
34 __select__ = match_user_groups('managers', 'users') |
35 |
35 |
36 def call(self): |
36 def call(self): |
37 repo = self._cw.repo # Service are repo side only. |
37 repo = self._cw.repo # Service are repo side only. |
38 results = {} |
38 results = {} |
39 querier = repo.querier |
39 querier = repo.querier |
40 source = repo.system_source |
40 source = repo.system_source |
41 for size, maxsize, hits, misses, title in ( |
41 for size, maxsize, hits, misses, title in ( |
42 (len(querier._rql_cache), repo.config['rql-cache-size'], |
42 (len(querier._rql_cache), repo.config['rql-cache-size'], |
43 querier.cache_hit, querier.cache_miss, 'rqlt_st'), |
43 querier.cache_hit, querier.cache_miss, 'rqlt_st'), |
44 (len(source._cache), repo.config['rql-cache-size'], |
44 (len(source._cache), repo.config['rql-cache-size'], |
45 source.cache_hit, source.cache_miss, 'sql'), |
45 source.cache_hit, source.cache_miss, 'sql'), |
46 ): |
46 ): |
47 results['%s_cache_size' % title] = {'size': size, 'maxsize': maxsize} |
47 results['%s_cache_size' % title] = {'size': size, 'maxsize': maxsize} |
48 results['%s_cache_hit' % title] = hits |
48 results['%s_cache_hit' % title] = hits |
49 results['%s_cache_miss' % title] = misses |
49 results['%s_cache_miss' % title] = misses |
50 results['%s_cache_hit_percent' % title] = (hits * 100) / (hits + misses) |
50 results['%s_cache_hit_percent' % title] = (hits * 100) / (hits + misses) |
51 results['type_cache_size'] = len(repo._type_cache) |
51 results['type_cache_size'] = len(repo._type_cache) |
59 class GcStatsService(Service): |
59 class GcStatsService(Service): |
60 """Return a dictionary containing some statistics about the repository |
60 """Return a dictionary containing some statistics about the repository |
61 resources usage. |
61 resources usage. |
62 """ |
62 """ |
63 |
63 |
64 __regid__ = 'repo_gc_stats' |
64 __regid__ = 'repo_gc_stats' |
65 __select__ = match_user_groups('managers') |
65 __select__ = match_user_groups('managers') |
66 |
66 |
67 def call(self, nmax=20): |
67 def call(self, nmax=20): |
68 """Return a dictionary containing some statistics about the repository |
68 """Return a dictionary containing some statistics about the repository |
69 memory usage. |
69 memory usage. |