Fix perf regression in PR #3530

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.
This commit is contained in:
Erik Johnston 2018-07-17 10:27:51 +01:00
parent 3fe0938b76
commit 547b1355d3

View File

@ -74,12 +74,17 @@ class StreamChangeCache(object):
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)