summary refs log tree commit diff
path: root/synapse/util/caches/lrucache.py (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add missing type hints to tests.config. (#14681)Patrick Cloke2022-12-161-7/+2
|
* Remove redundant types from comments. (#14412)Patrick Cloke2022-11-161-4/+4
| | | | | | | Remove type hints from comments which have been added as Python type hints. This helps avoid drift between comments and reality, as well as removing redundant information. Also adds some missing type hints which were simple to fill in.
* Optimise async get event lookups (#13435)Nick Mills-Barrett2022-08-041-0/+17
| | | | | | Still maintains local in memory lookup optimisation, but does any external lookup as part of the deferred that prevents duplicate lookups for the same event at once. This makes the assumption that fetching from an external cache is a non-zero load operation.
* Make DictionaryCache have better expiry properties (#13292)Erik Johnston2022-07-211-2/+88
|
* Async get event cache prep (#13242)Nick Mills-Barrett2022-07-151-0/+38
| | | | | Some experimental prep work to enable external event caching based on #9379 & #12955. Doesn't actually move the cache at all, just lays the groundwork for async implemented caches. Signed off by Nick @ Beeper (@Fizzadar)
* Type `tests.utils` (#13028)David Robertson2022-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Cast to postgres types when handling postgres db * Remove unused method * Easy annotations * Annotate create_room * Use `ParamSpec` to annotate looping_call * Annotate `default_config` * Track `now` as a float `time_ms` returns an int like the proper Synapse `Clock` * Introduce a `Timer` dataclass * Introduce a Looper type * Suppress checking of a mock * tests.utils is typed * Changelog * Whoops, import ParamSpec from typing_extensions * ditch the psycopg2 casts
* Add config flags to allow for cache auto-tuning (#12701)Shay2022-05-131-10/+69
|
* Track cache invalidations (#12000)Erik Johnston2022-02-151-1/+3
| | | Currently we only track evictions due to size or time constraints.
* Describe `prune_unread_entries` in docstrings (#11876)David Robertson2022-02-021-0/+6
| | | Should have been caught in #10826.
* Update to the current version of Black and run it on Synapse codebase (#11596)Shay2021-12-231-1/+0
| | | | | | | | | * update black version * run updated version of black on code * newsfragment * enumerate python versions
* Fix `LruCache` corruption bug with a `size_callback` that can return 0 (#11454)Sean Quah2021-11-301-1/+4
| | | | | | | | | | | When all entries in an `LruCache` have a size of 0 according to the provided `size_callback`, and `drop_from_cache` is called on a cache node, the node would be unlinked from the LRU linked list but remain in the cache dictionary. An assertion would be later be tripped due to the inconsistency. Avoid unintentionally calling `__len__` and use a strict `is None` check instead when unwrapping the weak reference.
* Eliminate a few `Any`s in `LruCache` type hints (#11453)Sean Quah2021-11-301-16/+21
|
* More types for synapse.util, part 1 (#10888)David Robertson2021-10-061-31/+26
| | | | | | | | | | | | | | The following modules now pass `disallow_untyped_defs`: * synapse.util.caches.cached_call * synapse.util.caches.lrucache * synapse.util.caches.response_cache * synapse.util.caches.stream_change_cache * synapse.util.caches.ttlcache pass * synapse.util.daemonize * synapse.util.patch_inline_callbacks pass `no-untyped-defs` * synapse.util.versionstring Additional typing in synapse.util.metrics. Didn't get this to pass `no-untyped-defs`, think I'll need to watch #10847
* Opt out of cache expiry for `get_users_who_share_room_with_user` (#10826)David Robertson2021-09-221-3/+13
| | | | * Allow LruCaches to opt out of time-based expiry * Don't expire `get_users_who_share_room` & friends
* Track why we're evicting from caches (#10829)David Robertson2021-09-221-2/+2
| | | So we can see distinguish between "evicting because the cache is too big" and "evicting because the cache entries haven't been recently used".
* Add types to synapse.util. (#10601)reivilibre2021-09-101-2/+3
|
* [pyupgrade] `synapse/` (#10348)Jonathan de Jong2021-07-191-2/+1
| | | | | | | | | This PR is tantamount to running ``` pyupgrade --py36-plus --keep-percent-format `find synapse/ -type f -name "*.py"` ``` Part of #9744
* Use inline type hints in `http/federation/`, `storage/` and `util/` (#10381)Jonathan de Jong2021-07-151-4/+4
|
* Add support for evicting cache entries based on last access time. (#10205)Erik Johnston2021-07-051-35/+202
|
* Combine `LruCache.invalidate` and `invalidate_many` (#9973)Richard van der Hoff2021-05-271-7/+11
| | | | | | | | | | * Make `invalidate` and `invalidate_many` do the same thing ... so that we can do either over the invalidation replication stream, and also because they always confused me a bit. * Kill off `invalidate_many` * changelog
* Remove `keylen` from `LruCache`. (#9993)Richard van der Hoff2021-05-241-6/+4
| | | | | | | `keylen` seems to be a thing that is frequently incorrectly set, and we don't really need it. The only time it was used was to figure out if we had removed a subtree in `del_multi`, which we can do better by changing `TreeCache.pop` to return a different type (`TreeCacheNode`). Commits should be independently reviewable.
* Optionally track memory usage of each LruCache (#9881)Erik Johnston2021-05-051-1/+47
| | | | | This will double count slightly in the presence of interned strings. It's off by default as it can consume a lot of resources.
* Reduce memory footprint of caches (#9886)Erik Johnston2021-04-281-18/+59
|
* Remove redundant "coding: utf-8" lines (#9786)Jonathan de Jong2021-04-141-1/+0
| | | | | | | Part of #9744 Removes all redundant `# -*- coding: utf-8 -*-` lines from files, as python 3 automatically reads source code as utf-8 now. `Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>`
* Bugbear: Add Mutable Parameter fixes (#9682)Jonathan de Jong2021-04-081-6/+8
| | | | | | | Part of #9366 Adds in fixes for B006 and B008, both relating to mutable parameter lint errors. Signed-off-by: Jonathan de Jong <jonathan@automatia.nl>
* Fix 'LruCache' object has no attribute '_on_resize' (#8591)Richard van der Hoff2020-10-191-1/+9
| | | We need to make sure we are readu for the `set_cache_factor` callback.
* Replace DeferredCache with LruCache where possible (#8563)Richard van der Hoff2020-10-191-0/+3
| | | Most of these uses don't need a full-blown DeferredCache; LruCache is lighter and more appropriate.
* review commentsRichard van der Hoff2020-10-161-3/+8
|
* Apply suggestions from code reviewRichard van der Hoff2020-10-161-1/+1
| | | Co-authored-by: Patrick Cloke <clokep@users.noreply.github.com>
* type annotations for LruCacheRichard van der Hoff2020-10-161-12/+61
|
* Make LruCache register its own metrics (#8561)Richard van der Hoff2020-10-161-11/+35
| | | | | rather than have everything that instantiates an LruCache manage metrics separately, have LruCache do it itself.
* Add some more type annotations to CacheRichard van der Hoff2020-10-141-1/+2
|
* Stop sub-classing object (#8249)Patrick Cloke2020-09-041-2/+2
|
* Don't apply cache factor to event cache. (#7578)Erik Johnston2020-05-271-0/+4
| | | | This is already correctly done when we instansiate the cache, but wasn't when it got reloaded (which always happens at least once on startup).
* Allow configuration of Synapse's cache without using synctl or environment ↵Amber Brown2020-05-111-9/+43
| | | | variables (#6391)
* Run Black. (#5482)Amber Brown2019-06-201-2/+12
|
* run isortAmber Brown2018-07-091-1/+1
|
* Add commentsErik Johnston2018-03-191-0/+7
|
* Fix bug where state cache used lots of memoryErik Johnston2018-03-151-4/+4
| | | | | | | | | The state cache bases its size on the sum of the size of entries. The size of the entry is calculated once on insertion, so it is important that the size of entries does not change. The DictionaryCache modified the entries size, which caused the state cache to incorrectly think it was smaller than it actually was.
* report metrics on number of cache evictionsRichard van der Hoff2018-02-051-3/+25
|
* Update LruCache size estimate on clearErik Johnston2017-01-181-0/+2
|
* Remove needless call to evict()Erik Johnston2017-01-171-1/+0
|
* Speed up cache size calculationErik Johnston2017-01-171-17/+25
| | | | | | | | | | | Instead of calculating the size of the cache repeatedly, which can take a long time now that it can use a callback, instead cache the size and update that on insertion and deletion. This requires changing the cache descriptors to have two caches, one for pending deferreds and the other for the actual values. There's no reason to evict from the pending deferreds as they won't take up any more memory.
* Optionally measure size of cache by sum of length of valuesErik Johnston2017-01-131-14/+18
|
* Ensure invalidation list does not grow unboundedlyErik Johnston2016-08-191-8/+8
|
* Add concept of cache contextsErik Johnston2016-08-191-7/+32
|
* Make LruCache use a dedicated _Node classErik Johnston2016-03-221-32/+41
|
* Remove spurious self.sizeErik Johnston2016-01-291-1/+0
|
* Make TreeCache keep track of its own size.Erik Johnston2016-01-291-6/+3
|
* Reset size on clearErik Johnston2016-01-291-0/+2
|
* Don't add the member functiopn if we're not using treecacheDavid Baker2016-01-221-1/+4
|
* docsDavid Baker2016-01-221-1/+5
|
* Revert all the bits changing keys of eeverything that used LRUCaches to tuplesDavid Baker2016-01-221-1/+1
|
* Make LRU cache not default to treecache & add options to use itDavid Baker2016-01-221-4/+5
|
* Change LRUCache to be tree-based so we can delete subtrees.David Baker2016-01-211-8/+35
|
* copyrightsMatthew Hodgson2016-01-071-1/+1
|
* Move all the caches into their own package, synapse.util.cachesErik Johnston2015-08-111-0/+149