summary refs log tree commit diff
path: root/synapse/util/caches (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #3093 from matrix-org/rav/response_cache_wrapRichard van der Hoff2018-04-201-14/+74
|\ | | | | Refactor ResponseCache usage
| * ResponseCache: fix handling of completed resultsRichard van der Hoff2018-04-131-13/+19
| | | | | | | | | | Turns out that ObservableDeferred.observe doesn't return a deferred if the result is already completed. Fix handling and improve documentation.
| * Refactor ResponseCache usageRichard van der Hoff2018-04-121-2/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a `.wrap` method to ResponseCache which wraps up the boilerplate of a (get, set) pair, and then use it throughout the codebase. This will be largely non-functional, but does include the following functional changes: * federation_server.on_context_state_request: drops use of _server_linearizer which looked redundant and could cause incorrect cache misses by yielding between the get and the set. * RoomListHandler.get_remote_public_room_list(): fixes logcontext leaks * the wrap function includes some logging. I'm hoping this won't be too noisy on production.
* | Revert "Use sortedcontainers instead of blist"Richard van der Hoff2018-04-131-2/+2
|/ | | | | | | | | | | This reverts commit 9fbe70a7dc3afabfdac176ba1f4be32dd44602aa. It turns out that sortedcontainers.SortedDict is not an exact match for blist.sorteddict; in particular, `popitem()` removes things from the opposite end of the dict. This is trivial to fix, but I want to add some unit tests, and potentially some more thought about it, before we do so.
* Merge pull request #3092 from matrix-org/rav/response_cache_metricsRichard van der Hoff2018-04-121-1/+13
|\ | | | | Add metrics for ResponseCache
| * Add metrics for ResponseCacheRichard van der Hoff2018-04-101-1/+13
| |
* | Merge pull request #3059 from matrix-org/rav/doc_response_cacheRichard van der Hoff2018-04-121-0/+32
|\ \ | | | | | | Document the behaviour of ResponseCache
| * | Document the behaviour of ResponseCacheRichard van der Hoff2018-04-041-0/+32
| | | | | | | | | | | | | | | | | | it looks like everything that uses ResponseCache expects to have to `make_deferred_yieldable` its results. It's debatable whether that is the best approach, but let's document it for now to avoid further confusion.
* | | Use sortedcontainers instead of blistVincent Breitmoser2018-04-101-2/+2
| |/ |/| | | | | | | | | | | | | This commit drop-in replaces blist with SortedContainers. They are written in pure python so work with pypy, but perform as good as native implementations, at least in a couple benchmarks: http://www.grantjenks.com/docs/sortedcontainers/performance.html
* | Fix overzealous cache invalidationRichard van der Hoff2018-04-051-26/+38
|/ | | | | Fixes an issue where a cache invalidation would invalidate *all* pending entries, rather than just the entry that we intended to invalidate.
* Add commentsErik Johnston2018-03-191-0/+7
|
* Fix bug where state cache used lots of memoryErik Johnston2018-03-152-5/+9
| | | | | | | | | 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-053-4/+34
|
* Increase default cache factor size.Erik Johnston2017-07-041-1/+1
|
* Define CACHE_SIZE_FACTOR onceErik Johnston2017-07-042-9/+2
|
* Use an ExpiringCache for storing registration sessionsErik Johnston2017-06-291-0/+3
| | | | | This is because pruning them was a significant performance drain on matrix.org
* Rewrite conditionalErik Johnston2017-06-091-1/+1
|
* Fix has_any_entity_changedErik Johnston2017-06-091-4/+4
| | | | | | | | Occaisonally has_any_entity_changed would throw the error: "Set changed size during iteration" when taking the max of the `sorteddict`. While its uncertain how that happens, its quite inefficient to iterate over the entire dict anyway so we change to using the more traditional `bisect_*` functions.
* Add stream change cacheErik Johnston2017-05-311-0/+15
|
* Pull out if statement from for loopErik Johnston2017-05-221-6/+14
|
* Update list cache to handle one arg caseErik Johnston2017-05-221-17/+33
| | | | | | We update the normal cache descriptors to handle caches with a single argument specially so that the key wasn't a 1-tuple. We need to update the cache list to be aware of this.
* Make get_state_groups_from_groups faster.Erik Johnston2017-05-171-11/+46
| | | | | | | | | Most of the time was spent copying a dict to filter out sentinel values that indicated that keys did not exist in the dict. The sentinel values were added to ensure that we cached the non-existence of keys. By updating DictionaryCache to keep track of which keys were known to not exist itself we can remove a dictionary copy.
* Don't update event cache hit ratio from get_joined_usersErik Johnston2017-05-081-3/+6
| | | | | Otherwise the hit ration of plain get_events gets completely skewed by calls to get_joined_users* functions.
* Optimise caches with single keyErik Johnston2017-05-041-9/+33
|
* Remove DEBUG_CACHESErik Johnston2017-04-251-2/+0
|
* Reduce cache size by not storing deferredsErik Johnston2017-04-251-18/+21
| | | | | | | | | | | | | | | | | | | | Currently the cache descriptors store deferreds rather than raw values, this is a simple way of triggering only one database hit and sharing the result if two callers attempt to get the same value. However, there are a few caches that simply store a mapping from string to string (or int). These caches can have a large number of entries, under the assumption that each entry is small. However, the size of a deferred (specifically the size of ObservableDeferred) is signigicantly larger than that of the raw value, 2kb vs 32b. This PR therefore changes the cache descriptors to store the raw values rather than the deferreds. As a side effect cached storage function now either return a deferred or the actual value, as the cached list decriptor already does. This is fine as we always end up just yield'ing on the returned value eventually, which handles that case correctly.
* Only intern ascii stringsErik Johnston2017-04-241-18/+11
|
* Remove unused instance variableErik Johnston2017-03-311-4/+0
|
* Doc new instance variablesErik Johnston2017-03-301-1/+8
|
* Manually calculate cache key as getcallargs is expensiveErik Johnston2017-03-301-6/+28
| | | | | This is because getcallargs recomputes the getargspec, amongst other things, which we don't need to do as its already been done
* Don't convert to deferreds when not necessaryErik Johnston2017-03-301-1/+4
|
* Fix the logcontext handling in the cache wrappers (#2077)Richard van der Hoff2017-03-301-16/+14
| | | | | | | The cache wrappers had a habit of leaking the logcontext into the reactor while the lookup function was running, and then not restoring it correctly when the lookup function had completed. It's all the fault of `preserve_context_over_{fn,deferred}` which are basically a bit broken.
* Fix caching of remote servers' signature keysRichard van der Hoff2017-03-221-63/+72
| | | | | | | | | The `@cached` decorator on `KeyStore._get_server_verify_key` was missing its `num_args` parameter, which meant that it was returning the wrong key for any server which had more than one recorded key. By way of a fix, change the default for `num_args` to be *all* arguments. To implement that, factor out a common base class for `CacheDescriptor` and `CacheListDescriptor`.
* Fix assertion to stop transaction queue getting wedgedRichard van der Hoff2017-03-151-1/+1
| | | | | | | | ... and update some docstrings to correctly reflect the types being used. get_new_device_msgs_for_remote can return a long under some circumstances, which was being stored in last_device_list_stream_id_by_dest, and was then upsetting things on the next loop.
* Add setdefault key to ExpiringCacheErik Johnston2017-03-101-0/+7
|
* CommentErik Johnston2017-02-021-1/+4
|
* CommentErik Johnston2017-02-021-0/+2
|
* Update LruCache size estimate on clearErik Johnston2017-01-181-0/+2
|
* Measure metrics of string_cacheErik Johnston2017-01-171-3/+8
|
* Fix typo in return typeErik Johnston2017-01-171-3/+2
|
* Rename and comment tree_to_leaves_iteratorErik Johnston2017-01-172-5/+8
|
* Remove needless call to evict()Erik Johnston2017-01-171-1/+0
|
* Speed up cache size calculationErik Johnston2017-01-175-46/+128
| | | | | | | | | | | 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.
* Use OrderedDict in ExpiringCacheErik Johnston2017-01-161-10/+4
|
* Add support for 'iterable' to ExpiringCacheErik Johnston2017-01-161-9/+17
|
* Optionally measure size of cache by sum of length of valuesErik Johnston2017-01-132-19/+38
|
* Change get_pos_of_last_change to return upper boundErik Johnston2016-09-151-3/+4
|
* Use stream_change cache to make get_forward_extremeties_for_room cache more ↵Erik Johnston2016-09-151-0/+5
| | | | effective
* Ensure invalidation list does not grow unboundedlyErik Johnston2016-08-192-20/+16
|
* Rename to on_invalidateErik Johnston2016-08-191-16/+10
|
* Make cache_context an explicit optionErik Johnston2016-08-191-8/+27
|
* Remove lru optionErik Johnston2016-08-191-23/+8
|
* Add concept of cache contextsErik Johnston2016-08-193-20/+99
|
* Cache federation state responsesErik Johnston2016-07-211-2/+11
|
* Merge branch 'erikj/cache_perf' of github.com:matrix-org/synapse into developErik Johnston2016-06-031-10/+25
|\
| * Pull out update_results_dictErik Johnston2016-06-031-8/+7
| |
| * Small optimisation to CacheListDescriptorErik Johnston2016-06-031-2/+2
| |
| * Make cachedList go a bit fasterErik Johnston2016-06-031-10/+34
| |
* | Change CacheMetrics to be quickerErik Johnston2016-06-035-25/+44
|/ | | | | | 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.
* Deduplicate joinsErik Johnston2016-04-071-1/+1
|
* Make the cache objects be per instance rather than being globalMark Haines2016-04-061-21/+24
|
* Fix typoMark Haines2016-03-241-1/+1
|
* Deduplicate identical /sync requestsMark Haines2016-03-241-0/+46
|
* Simplify intern_dictErik Johnston2016-03-231-17/+10
|
* Intern all the thingsErik Johnston2016-03-231-1/+57
|
* String internErik Johnston2016-03-231-0/+8
|
* Make LruCache use a dedicated _Node classErik Johnston2016-03-221-32/+41
|
* Return list, not generator.Erik Johnston2016-03-141-3/+1
|
* Use syntax that works on both py2.7 and py3Mark Haines2016-03-071-1/+1
|
* Limit stream change cache size tooErik Johnston2016-03-011-1/+5
|
* Move cache size fiddling to descriptors only. Fix testsErik Johnston2016-03-011-2/+2
|
* Add enviroment variable SYNAPSE_CACHE_FACTOR, default it to 0.1Erik Johnston2016-03-011-0/+6
|
* Reraise exceptionErik Johnston2016-03-011-0/+1
|
* Correct cache miss detectionErik Johnston2016-03-011-1/+1
|
* Report size of ExpiringCacheErik Johnston2016-02-231-2/+13
|
* Change the way we figure out presence updates for small deltasErik Johnston2016-02-231-0/+16
|
* Fix up logcontextsErik Johnston2016-02-082-6/+13
|
* Fix flake8 warnings for new flake8Daniel Wagner-Hall2016-02-023-4/+4
|
* If stream pos is greater then earliest known key and entity hasn't changed, ↵Erik Johnston2016-01-291-8/+3
| | | | then entity hasn't changed
* Prefill stream change cachesErik Johnston2016-01-291-1/+4
|
* Merge pull request #536 from matrix-org/erikj/syncErik Johnston2016-01-291-0/+107
|\ | | | | Make /sync "better".
| * If the same as the earliest key, assume nothing has changed.Erik Johnston2016-01-281-0/+5
| |
| * Correctly update _entity_to_keyErik Johnston2016-01-281-4/+5
| |
| * Fix inequalitiesErik Johnston2016-01-281-2/+2
| |
| * Include cache hits with has_entity_changedErik Johnston2016-01-281-0/+4
| |
| * Change name and doc has_entity_changedErik Johnston2016-01-281-1/+3
| |
| * Cache tags and account dataErik Johnston2016-01-282-92/+95
| |
| * Ensure keys to RoomStreamChangeCache are intsErik Johnston2016-01-281-0/+6
| |
| * Invalidate caches properly. Remove unused argErik Johnston2016-01-281-2/+2
| |
| * Add cache to room streamErik Johnston2016-01-271-0/+86
| |
* | Directly set self.valueErik Johnston2016-01-291-1/+1
| |
* | Remove spurious self.sizeErik Johnston2016-01-291-1/+0
| |
* | Correctly bookkeep the size of TreeCacheErik Johnston2016-01-291-3/+28
| |
* | Make TreeCache keep track of its own size.Erik Johnston2016-01-292-6/+10
| |
* | 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-222-6/+6
|
* Make LRU cache not default to treecache & add options to use itDavid Baker2016-01-222-10/+19
|
* Add __contains__David Baker2016-01-221-0/+3
|
* Docs for treecacheDavid Baker2016-01-221-0/+5
|
* Add invalidate_many here tooDavid Baker2016-01-221-0/+1
|
* peppateDavid Baker2016-01-211-2/+2
|
* Change LRUCache to be tree-based so we can delete subtrees.David Baker2016-01-214-14/+102
|
* copyrightsMatthew Hodgson2016-01-076-6/+6
|
* Add some docstring explaining the snapshot cache doesMark Haines2015-12-231-1/+23
|
* Add a unit test for the snapshot cacheMark Haines2015-12-231-2/+2
|
* Add a cache for initialSync responses that expires after 5 minutesMark Haines2015-12-221-0/+71
|
* Don't assume @cachedList function returns keys for everythingErik Johnston2015-08-181-1/+1
|
* DocstringErik Johnston2015-08-121-0/+27
|
* Merge branch 'develop' of github.com:matrix-org/synapse into ↵Erik Johnston2015-08-121-1/+3
| | | | erikj/dictionary_cache
* Wire up the dictionarycache to the metricsErik Johnston2015-08-123-45/+41
|
* Move all the caches into their own package, synapse.util.cachesErik Johnston2015-08-115-0/+746