diff options
author | Erik Johnston <erik@matrix.org> | 2016-06-02 11:29:44 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-06-03 11:26:52 +0100 |
commit | 73c711243382a48b9b67fddf5ed9df2d1ee1be43 (patch) | |
tree | 39f18b1d92254b6265a23b959e3492676566b8ff /synapse/metrics/__init__.py | |
parent | Merge pull request #811 from matrix-org/erikj/state_users_in_room (diff) | |
download | synapse-73c711243382a48b9b67fddf5ed9df2d1ee1be43.tar.xz |
Change CacheMetrics to be quicker
We change it so that each cache has an individual CacheMetric, instead of having one global CacheMetric. This means that when a cache tries to increment a counter it does not need to go through so many indirections.
Diffstat (limited to 'synapse/metrics/__init__.py')
-rw-r--r-- | synapse/metrics/__init__.py | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/synapse/metrics/__init__.py b/synapse/metrics/__init__.py index 5664d5a381..c38f24485a 100644 --- a/synapse/metrics/__init__.py +++ b/synapse/metrics/__init__.py @@ -33,11 +33,7 @@ from .metric import ( logger = logging.getLogger(__name__) -# We'll keep all the available metrics in a single toplevel dict, one shared -# for the entire process. We don't currently support per-HomeServer instances -# of metrics, because in practice any one python VM will host only one -# HomeServer anyway. This makes a lot of implementation neater -all_metrics = {} +all_metrics = [] class Metrics(object): @@ -53,7 +49,7 @@ class Metrics(object): metric = metric_class(full_name, *args, **kwargs) - all_metrics[full_name] = metric + all_metrics.append(metric) return metric def register_counter(self, *args, **kwargs): @@ -84,12 +80,12 @@ def render_all(): # TODO(paul): Internal hack update_resource_metrics() - for name in sorted(all_metrics.keys()): + for metric in all_metrics: try: - strs += all_metrics[name].render() + strs += metric.render() except Exception: - strs += ["# FAILED to render %s" % name] - logger.exception("Failed to render %s metric", name) + strs += ["# FAILED to render"] + logger.exception("Failed to render metric") strs.append("") # to generate a final CRLF |