summary refs log tree commit diff
path: root/synapse/state
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2022-06-15 15:19:49 +0100
committerGitHub <noreply@github.com>2022-06-15 15:19:49 +0100
commit941dc3db13f1c4c4b89da14a0dc60b4f7b54228c (patch)
tree89430ae50816b322ae8e4044210839cf808b4099 /synapse/state
parentFix a long-standing bug which meant that rate limiting was not restrictive en... (diff)
downloadsynapse-941dc3db13f1c4c4b89da14a0dc60b4f7b54228c.tar.xz
Track a histogram of state res durations (#13036)
Diffstat (limited to 'synapse/state')
-rw-r--r--synapse/state/__init__.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/state/__init__.py b/synapse/state/__init__.py
index da25f20ae5..9d3fe66100 100644
--- a/synapse/state/__init__.py
+++ b/synapse/state/__init__.py
@@ -444,6 +444,15 @@ _biggest_room_by_db_counter = Counter(
     "expensive room for state resolution",
 )
 
+_cpu_times = Histogram(
+    "synapse_state_res_cpu_for_all_rooms_seconds",
+    "CPU time (utime+stime) spent computing a single state resolution",
+)
+_db_times = Histogram(
+    "synapse_state_res_db_for_all_rooms_seconds",
+    "Database time spent computing a single state resolution",
+)
+
 
 class StateResolutionHandler:
     """Responsible for doing state conflict resolution.
@@ -609,6 +618,9 @@ class StateResolutionHandler:
         room_metrics.db_time += rusage.db_txn_duration_sec
         room_metrics.db_events += rusage.evt_db_fetch_count
 
+        _cpu_times.observe(rusage.ru_utime + rusage.ru_stime)
+        _db_times.observe(rusage.db_txn_duration_sec)
+
     def _report_metrics(self) -> None:
         if not self._state_res_metrics:
             # no state res has happened since the last iteration: don't bother logging.