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

Try to not use as much CPU in the StreamChangeCache #3451

Merged
merged 3 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added changelog.d/3447.misc
Empty file.
6 changes: 4 additions & 2 deletions synapse/util/caches/stream_change_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def get_entities_changed(self, entities, stream_pos):
not_known_entities = set(entities) - set(self._entity_to_key)

result = (
set(self._cache.values()[self._cache.bisect_right(stream_pos) :])
{self._cache[k] for k in self._cache.islice(
start=self._cache.bisect_right(stream_pos))}
.intersection(entities)
.union(not_known_entities)
)
Expand Down Expand Up @@ -113,7 +114,8 @@ def get_all_entities_changed(self, stream_pos):
assert type(stream_pos) is int

if stream_pos >= self._earliest_known_stream_pos:
return self._cache.values()[self._cache.bisect_right(stream_pos) :]
return [self._cache[k] for k in self._cache.islice(
start=self._cache.bisect_right(stream_pos))]
else:
return None

Expand Down