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

Refactor store.have_events #3117

Merged
merged 1 commit into from
Apr 20, 2018
Merged

Refactor store.have_events #3117

merged 1 commit into from
Apr 20, 2018

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Apr 17, 2018

It turns out that most of the time we were calling have_events, we were only
using half of the result. Replace have_events with have_seen_events and
get_rejection_reasons, so that we can see what's going on a bit more clearly.

@@ -394,7 +394,7 @@ def get_events(self, destinations, room_id, event_ids, return_local=True):
seen_events = yield self.store.get_events(event_ids, allow_rejected=True)
signed_events = seen_events.values()
else:
seen_events = yield self.store.have_events(event_ids)
seen_events = yield self.store.get_rejection_reasons(event_ids)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be have_seen_events?

Copy link
Member Author

Choose a reason for hiding this comment

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

looks like

)
defer.returnValue(results)

def get_rejection_reasons(self, event_ids):
Copy link
Member

Choose a reason for hiding this comment

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

Reading through this PR I've been a bit confused about this name. I keep expecting it to just return the rejected events, rather than all events we've seen. Maybe something like get_seen_events_with_rejections? Its horrific but I suck at naming :/

Copy link
Member Author

Choose a reason for hiding this comment

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

agrreed, will change.

# break the input up into chunks of 100
input_iterator = iter(event_ids)
for chunk in iter(lambda: list(itertools.islice(input_iterator, 100)),
[]):
Copy link
Member

Choose a reason for hiding this comment

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

We tend to do:

        chunks = [
            iterable[i:i + batch_size]
            for i in xrange(0, len(iterable), batch_size)
        ]

which I think is quite a bit clearer?

Copy link
Member Author

Choose a reason for hiding this comment

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

clearer, but doesn't actually work when iterable is an iterable rather than a sequence.

Copy link
Member Author

Choose a reason for hiding this comment

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

(and involves copying the input)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, right, yes.

@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Apr 18, 2018
@richvdh
Copy link
Member Author

richvdh commented Apr 18, 2018

retest this please

@richvdh
Copy link
Member Author

richvdh commented Apr 18, 2018

ok the postgres build failed because postgres wasn't running. PTAL @erikjohnston

@richvdh richvdh assigned erikjohnston and unassigned richvdh Apr 18, 2018
@erikjohnston erikjohnston assigned richvdh and unassigned erikjohnston Apr 19, 2018
It turns out that most of the time we were calling have_events, we were only
using half of the result. Replace have_events with have_seen_events and
get_rejection_reasons, so that we can see what's going on a bit more clearly.
@richvdh richvdh force-pushed the rav/refactor_have_events branch from 61e1c35 to b1dfbc3 Compare April 20, 2018 09:26
@richvdh richvdh merged commit bc381d5 into develop Apr 20, 2018
@richvdh richvdh deleted the rav/refactor_have_events branch April 20, 2018 09:26
neilisfragile added a commit that referenced this pull request Apr 27, 2018
Changes in synapse v0.28.0-rc1 (2018-04-26)
===========================================

Bug Fixes:

* Fix quarantine media admin API and search reindex (PR #3130)
* Fix media admin APIs (PR #3134)

Changes in synapse v0.28.0-rc1 (2018-04-24)
===========================================

Minor performance improvement to federation sending and bug fixes.

(Note: This release does not include state resolutions discussed in matrix live)

Features:

* Add metrics for event processing lag (PR #3090)
* Add metrics for ResponseCache (PR #3092)

Changes:

* Synapse on PyPy (PR #2760) Thanks to @Valodim!
* move handling of auto_join_rooms to RegisterHandler (PR #2996) Thanks to @krombel!
* Improve handling of SRV records for federation connections (PR #3016) Thanks to @silkeh!
* Document the behaviour of ResponseCache (PR #3059)
* Preparation for py3 (PR #3061, #3073, #3074, #3075, #3103, #3104, #3106, #3107, #3109, #3110) Thanks to @NotAFile!
* update prometheus dashboard to use new metric names (PR #3069) Thanks to @krombel!
* use python3-compatible prints (PR #3074) Thanks to @NotAFile!
* Send federation events concurrently (PR #3078)
* Limit concurrent event sends for a room (PR #3079)
* Improve R30 stat definition (PR #3086)
* Send events to ASes concurrently (PR #3088)
* Refactor ResponseCache usage (PR #3093)
* Clarify that SRV may not point to a CNAME (PR #3100) Thanks to @silkeh!
* Use str(e) instead of e.message (PR #3103) Thanks to @NotAFile!
* Use six.itervalues in some places (PR #3106) Thanks to @NotAFile!
* Refactor store.have_events (PR #3117)

Bug Fixes:

* Return 401 for invalid access_token on logout (PR #2938) Thanks to @dklug!
* Return a 404 rather than a 500 on rejoining empty rooms (PR #3080)
* fix federation_domain_whitelist (PR #3099)
* Avoid creating events with huge numbers of prev_events (PR #3113)
* Reject events which have lots of prev_events (PR #3118)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants