This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Attempt to speed up the computation of the auth_difference
#13037
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In matrix-org/matrix-spec#1118 I noted that one can ignore the events in the unconflicted state map when computing the auth difference, because their auth chains will never appear in the auth difference. This change changes Synapse to take advantage of this fact.
In highly unscientific testing, I reproduced the state resolution of an event with two parents whose conflicted state set contained 255 events (239 type/state-key pairs) and whose auth difference contains 250 events.
Before:
After:
I repeated these a handful of times and found those numbers (~10sec, ~8sec) to be fairly reproducible. But I'm afraid I don't have any rigorous statistics to justify this.
It's also worth nothing that I'm running this on my local machine connected remotely to a postgres database (circa 15 ms RTT) so that might be exaggerating time spent waiting for the DB.
I have no evidence to performance which shows what happens in a typical or average case. (Though see #13036.)
I checked my example that the outcome of state resolution was unchanged, but I'm relying on the unit test coverage to assert that is the case more broadly.