mirror of
https://mau.dev/maunium/synapse.git
synced 2024-08-27 12:42:39 +00:00
Add metrics to the receipts cache
This commit is contained in:
parent
7e77a82c5f
commit
5db5677969
@ -151,5 +151,12 @@ class CacheMetric(object):
|
|||||||
def inc_misses(self, *values):
|
def inc_misses(self, *values):
|
||||||
self.total.inc(*values)
|
self.total.inc(*values)
|
||||||
|
|
||||||
|
def inc_hits_by(self, inc, *values):
|
||||||
|
self.hits.inc_by(inc, *values)
|
||||||
|
self.total.inc_by(inc, *values)
|
||||||
|
|
||||||
|
def inc_misses_by(self, inc, *values):
|
||||||
|
self.total.inc_by(inc, *values)
|
||||||
|
|
||||||
def render(self):
|
def render(self):
|
||||||
return self.hits.render() + self.total.render() + self.size.render()
|
return self.hits.render() + self.total.render() + self.size.render()
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
from ._base import SQLBaseStore
|
from ._base import SQLBaseStore
|
||||||
from synapse.util.caches.descriptors import cachedInlineCallbacks
|
from synapse.util.caches.descriptors import cachedInlineCallbacks
|
||||||
|
from synapse.util.caches import cache_counter, caches_by_name
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
@ -305,6 +306,8 @@ class _RoomStreamChangeCache(object):
|
|||||||
self._room_to_key = {}
|
self._room_to_key = {}
|
||||||
self._cache = sorteddict()
|
self._cache = sorteddict()
|
||||||
self._earliest_key = None
|
self._earliest_key = None
|
||||||
|
self.name = "ReceiptsRoomChangeCache"
|
||||||
|
caches_by_name[self.name] = self._cache
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_rooms_changed(self, store, room_ids, key):
|
def get_rooms_changed(self, store, room_ids, key):
|
||||||
@ -321,6 +324,9 @@ class _RoomStreamChangeCache(object):
|
|||||||
else:
|
else:
|
||||||
result = room_ids
|
result = room_ids
|
||||||
|
|
||||||
|
cache_counter.inc_hits_by(len(result), self.name)
|
||||||
|
cache_counter.inc_misses_by(len(room_ids) - len(result), self.name)
|
||||||
|
|
||||||
defer.returnValue(result)
|
defer.returnValue(result)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
|
Loading…
Reference in New Issue
Block a user