diff options
author | Erik Johnston <erik@matrix.org> | 2022-08-23 15:53:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 14:53:27 +0000 |
commit | f7ddfe17a30a50205a23bf5ca4d7d71e691e1e48 (patch) | |
tree | 3af1cd2f62868f6e1fe0f455e7cf19739161fdfa /synapse/util/caches/treecache.py | |
parent | Fix regression caused by #13573 (#13600) (diff) | |
download | synapse-f7ddfe17a30a50205a23bf5ca4d7d71e691e1e48.tar.xz |
Speed up `@cachedList` (#13591)
This speeds things up by ~2x. The vast majority of the time is now spent in `LruCache` moving things around the linked lists. We do this via two things: 1. Don't create a deferred per-key during bulk set operations in `DeferredCache`. Instead, only create them if a subsequent caller asks for the key. 2. Add a bulk lookup API to `DeferredCache` rather than use a loop.
Diffstat (limited to 'synapse/util/caches/treecache.py')
-rw-r--r-- | synapse/util/caches/treecache.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/synapse/util/caches/treecache.py b/synapse/util/caches/treecache.py index c1b8ec0c73..fec31da2b6 100644 --- a/synapse/util/caches/treecache.py +++ b/synapse/util/caches/treecache.py @@ -135,6 +135,9 @@ class TreeCache: def values(self): return iterate_tree_cache_entry(self.root) + def items(self): + return iterate_tree_cache_items((), self.root) + def __len__(self) -> int: return self.size |