diff options
author | Andrew Morgan <andrew@amorgan.xyz> | 2020-03-16 15:31:12 +0000 |
---|---|---|
committer | Andrew Morgan <andrew@amorgan.xyz> | 2020-03-16 15:31:12 +0000 |
commit | 1b5ea48ed28646502b0c59a05e9fe36f11c59d60 (patch) | |
tree | 2f4fd4b4fe3a035ad9e73c263b1550e057ffb63c | |
parent | Merge pull request #6256 from matrix-org/erikj/fix_e2e_workers (diff) | |
parent | Merge pull request #6255 from matrix-org/erikj/stats_config (diff) | |
download | synapse-1b5ea48ed28646502b0c59a05e9fe36f11c59d60.tar.xz |
Merge pull request #6255 from matrix-org/erikj/stats_config
* commit '87259b3a3': Fix tests Newsfile Remove repeated calls to config.stats_enabled.
-rw-r--r-- | changelog.d/6255.misc | 1 | ||||
-rw-r--r-- | synapse/handlers/stats.py | 4 | ||||
-rw-r--r-- | tests/handlers/test_stats.py | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/changelog.d/6255.misc b/changelog.d/6255.misc new file mode 100644 index 0000000000..45bc493648 --- /dev/null +++ b/changelog.d/6255.misc @@ -0,0 +1 @@ +Small performance improvement by removing repeated config lookups in room stats calculation. diff --git a/synapse/handlers/stats.py b/synapse/handlers/stats.py index 466daf9202..26bc276692 100644 --- a/synapse/handlers/stats.py +++ b/synapse/handlers/stats.py @@ -45,6 +45,8 @@ class StatsHandler(StateDeltasHandler): 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 @@ -61,7 +63,7 @@ class StatsHandler(StateDeltasHandler): 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 diff --git a/tests/handlers/test_stats.py b/tests/handlers/test_stats.py index c4a29e3355..a7a18d7adc 100644 --- a/tests/handlers/test_stats.py +++ b/tests/handlers/test_stats.py @@ -611,6 +611,7 @@ class StatsRoomTests(unittest.HomeserverTestCase): """ self.hs.config.stats_enabled = False + self.handler.stats_enabled = False u1 = self.register_user("u1", "pass") u1token = self.login("u1", "pass") @@ -622,6 +623,7 @@ class StatsRoomTests(unittest.HomeserverTestCase): self.assertIsNone(self._get_current_stats("user", u1)) self.hs.config.stats_enabled = True + self.handler.stats_enabled = True self._perform_background_initial_update() |