Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Fix perf regression in PR #3530
Browse files Browse the repository at this point in the history
The get_entities_changed function was changed to return all changed
entities since the given stream position, rather than only those changed
from a given list of entities. This resulted in the function incorrectly
returning large numbers of entities that, for example, caused large
increases in database usage.
  • Loading branch information
erikjohnston committed Jul 17, 2018
1 parent 3fe0938 commit 547b135
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion synapse/util/caches/stream_change_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,17 @@ def get_entities_changed(self, entities, stream_pos):
assert type(stream_pos) is int

if stream_pos >= self._earliest_known_stream_pos:
result = {
changed_entities = {
self._cache[k] for k in self._cache.islice(
start=self._cache.bisect_right(stream_pos),
)
}

result = {
e for e in entities
if e in changed_entities
}

self.metrics.inc_hits()
else:
result = set(entities)
Expand Down

0 comments on commit 547b135

Please sign in to comment.