This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Attempt to speed up the computation of the auth_difference#13037
Closed
DMRobertson wants to merge 3 commits into
Closed
Attempt to speed up the computation of the auth_difference#13037DMRobertson wants to merge 3 commits into
auth_difference#13037DMRobertson wants to merge 3 commits into
Conversation
added 2 commits
June 13, 2022 20:41
erikjohnston
approved these changes
Jun 15, 2022
Contributor
Author
|
I'm quite scared by this change. (Invoking Knuth, "Beware of bugs in the above code; I have only proved it correct, not tried it.") The one example is fine, and the tests are happy. But I wonder if there might be another way to build confidence... do you have any thoughts? |
Member
I have in the past taken a chunk of a large public room out of the DB and compared the resulting state at each event using both the old and new algorithm |
Contributor
Author
|
Maths was wrong, see the spec issue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.