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

Fix perf regression in PR #3530 #3544

Merged
merged 4 commits into from
Jul 17, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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/3544.misc
Empty file.
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 = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it'll be quicker to do result = changed_entities.intersection(entities) here, since intersection is an optimised bit of C (which does do the right thing when given a non-set argument)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh, cool

e for e in entities
if e in changed_entities
}

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