diff options
author | Matthew Hodgson <matthew@matrix.org> | 2016-06-03 12:14:18 +0100 |
---|---|---|
committer | Matthew Hodgson <matthew@matrix.org> | 2016-06-03 12:14:18 +0100 |
commit | 8d740132f499b2c232716533ea786dfffacc1ec8 (patch) | |
tree | 5034a5aba0c6e604683080357ae6481803a4dea1 /synapse/util/caches/stream_change_cache.py | |
parent | brand the email from header (diff) | |
parent | Merge branch 'erikj/cache_perf' of github.com:matrix-org/synapse into develop (diff) | |
download | synapse-8d740132f499b2c232716533ea786dfffacc1ec8.tar.xz |
Merge branch 'develop' into matthew/brand-from-header
Diffstat (limited to 'synapse/util/caches/stream_change_cache.py')
-rw-r--r-- | synapse/util/caches/stream_change_cache.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/synapse/util/caches/stream_change_cache.py b/synapse/util/caches/stream_change_cache.py index ea8a74ca69..3c051dabc4 100644 --- a/synapse/util/caches/stream_change_cache.py +++ b/synapse/util/caches/stream_change_cache.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from synapse.util.caches import cache_counter, caches_by_name +from synapse.util.caches import register_cache from blist import sorteddict @@ -42,7 +42,7 @@ class StreamChangeCache(object): self._cache = sorteddict() self._earliest_known_stream_pos = current_stream_pos self.name = name - caches_by_name[self.name] = self._cache + self.metrics = register_cache(self.name, self._cache) for entity, stream_pos in prefilled_cache.items(): self.entity_has_changed(entity, stream_pos) @@ -53,19 +53,19 @@ class StreamChangeCache(object): assert type(stream_pos) is int if stream_pos < self._earliest_known_stream_pos: - cache_counter.inc_misses(self.name) + self.metrics.inc_misses() return True latest_entity_change_pos = self._entity_to_key.get(entity, None) if latest_entity_change_pos is None: - cache_counter.inc_hits(self.name) + self.metrics.inc_hits() return False if stream_pos < latest_entity_change_pos: - cache_counter.inc_misses(self.name) + self.metrics.inc_misses() return True - cache_counter.inc_hits(self.name) + self.metrics.inc_hits() return False def get_entities_changed(self, entities, stream_pos): @@ -82,10 +82,10 @@ class StreamChangeCache(object): self._cache[k] for k in keys[i:] ).intersection(entities) - cache_counter.inc_hits(self.name) + self.metrics.inc_hits() else: result = entities - cache_counter.inc_misses(self.name) + self.metrics.inc_misses() return result |