Merge pull request #6255 from matrix-org/erikj/stats_config

Remove repeated calls to config.stats_enabled.
This commit is contained in:
Erik Johnston 2019-10-25 11:34:38 +01:00 committed by GitHub
commit 87259b3a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

1
changelog.d/6255.misc Normal file
View File

@ -0,0 +1 @@
Small performance improvement by removing repeated config lookups in room stats calculation.

View File

@ -45,6 +45,8 @@ class StatsHandler(StateDeltasHandler):
self.is_mine_id = hs.is_mine_id self.is_mine_id = hs.is_mine_id
self.stats_bucket_size = hs.config.stats_bucket_size 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 # The current position in the current_state_delta stream
self.pos = None self.pos = None
@ -61,7 +63,7 @@ class StatsHandler(StateDeltasHandler):
def notify_new_event(self): def notify_new_event(self):
"""Called when there may be more deltas to process """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 return
self._is_processing = True self._is_processing = True

View File

@ -607,6 +607,7 @@ class StatsRoomTests(unittest.HomeserverTestCase):
""" """
self.hs.config.stats_enabled = False self.hs.config.stats_enabled = False
self.handler.stats_enabled = False
u1 = self.register_user("u1", "pass") u1 = self.register_user("u1", "pass")
u1token = self.login("u1", "pass") u1token = self.login("u1", "pass")
@ -618,6 +619,7 @@ class StatsRoomTests(unittest.HomeserverTestCase):
self.assertIsNone(self._get_current_stats("user", u1)) self.assertIsNone(self._get_current_stats("user", u1))
self.hs.config.stats_enabled = True self.hs.config.stats_enabled = True
self.handler.stats_enabled = True
self._perform_background_initial_update() self._perform_background_initial_update()