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

_auth_and_persist_outliers could do with being optimised #11013

Open
richvdh opened this issue Oct 7, 2021 · 1 comment
Open

_auth_and_persist_outliers could do with being optimised #11013

richvdh opened this issue Oct 7, 2021 · 1 comment
Labels
A-Performance Performance, both client-facing and admin-facing T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.

Comments

@richvdh
Copy link
Member

richvdh commented Oct 7, 2021

As part of my work on #9595, I've ended up making some of the code which persists events received over federation a bit more conservative. (Specifically, this is the code for handling batches of outliers, in FederationEventHandler._auth_and_persist_outliers).

#10896 (comment) raised the concern that this could result in a lot of round-trips between the federation inbound worker and the event persister.

It should be possible to optimise all this, so that we do all the event auth first, and then persist everything in one big chunk.

@richvdh
Copy link
Member Author

richvdh commented Oct 7, 2021

The main gotcha here is that we do not currently set event.rejected_reason on events until they have been persisted and reloaded. Instead, we currently set a flag in EventContext, which check_auth_rules_for_event doesn't consider.

It might be worth considering getting rid of EventContext.rejected, and just setting event.rejected_reason. The two are a source of confusion. (For example: I think that the condition at

if marker_event.rejected_reason is not None:
will always be false.)

@MadLittleMods MadLittleMods added the T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks. label Oct 7, 2021
@DMRobertson DMRobertson added A-Performance Performance, both client-facing and admin-facing and removed A-Performance labels Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Performance Performance, both client-facing and admin-facing T-Task Refactoring, removal, replacement, enabling or disabling functionality, other engineering tasks.
Projects
None yet
Development

No branches or pull requests

3 participants