Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6255 from matrix-org/erikj/stats_config
Browse files Browse the repository at this point in the history
Remove repeated calls to config.stats_enabled.
  • Loading branch information
erikjohnston authored Oct 25, 2019
2 parents 67290fa + 7e7a146 commit 87259b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/6255.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Small performance improvement by removing repeated config lookups in room stats calculation.
4 changes: 3 additions & 1 deletion synapse/handlers/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(self, hs):
self.is_mine_id = hs.is_mine_id
self.stats_bucket_size = hs.config.stats_bucket_size

self.stats_enabled = hs.config.stats_enabled

# The current position in the current_state_delta stream
self.pos = None

Expand All @@ -61,7 +63,7 @@ def __init__(self, hs):
def notify_new_event(self):
"""Called when there may be more deltas to process
"""
if not self.hs.config.stats_enabled or self._is_processing:
if not self.stats_enabled or self._is_processing:
return

self._is_processing = True
Expand Down
2 changes: 2 additions & 0 deletions tests/handlers/test_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ def test_initial_background_update(self):
"""

self.hs.config.stats_enabled = False
self.handler.stats_enabled = False

u1 = self.register_user("u1", "pass")
u1token = self.login("u1", "pass")
Expand All @@ -618,6 +619,7 @@ def test_initial_background_update(self):
self.assertIsNone(self._get_current_stats("user", u1))

self.hs.config.stats_enabled = True
self.handler.stats_enabled = True

self._perform_background_initial_update()

Expand Down

0 comments on commit 87259b3

Please sign in to comment.