This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add developer documentation to explain room DAG concepts like outliers and state_groups
#10464
Merged
richvdh
merged 15 commits into
develop
from
madlittlemods/document-outliers-and-state-groups
Aug 3, 2021
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a2d3aff
Add developer FAQ to explain outliers and state_groups
MadLittleMods 785abe4
Add a note about ex_outliers
MadLittleMods 63fd9cc
Add changelog
MadLittleMods 3127f20
Add developer to FAQ table of contents
MadLittleMods 2d68492
Move to room DAG concept page
MadLittleMods 12c0b89
Merge branch 'develop' into madlittlemods/document-outliers-and-state…
MadLittleMods 7392b63
Updates from feedback and more concepts
MadLittleMods abe66d1
Update changelog
MadLittleMods 885a880
Wrap lines
MadLittleMods e79502c
Fix floating outlier grammar
MadLittleMods 85e66d6
Add some more context around depth/stream_ordering with API endpoint …
MadLittleMods 997a4be
Grammar and better clarify a few statements
MadLittleMods 64ebf42
Wrap and address some review clarifications
MadLittleMods 9e1e92c
No distinction for floating outliers
MadLittleMods e9f58df
Simplify some extremity language and review touches
MadLittleMods File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,39 +13,43 @@ A (oldest) <---- B <---- C (most recent) | |||||||||||
|
|
||||||||||||
| ## Depth and stream ordering | ||||||||||||
|
|
||||||||||||
| Events are sorted by `(topological_ordering, stream_ordering)` where | ||||||||||||
| Events are normally sorted by `(topological_ordering, stream_ordering)` where | ||||||||||||
| `topological_ordering` is just `depth`. In other words, we first sort by `depth` | ||||||||||||
| and then tie-break based on `stream_ordering`. `depth` is incremented as new | ||||||||||||
| messages are added to the DAG. Normally, `stream_ordering` is an auto | ||||||||||||
| incrementing integer but for `backfilled=true` events, it decrements. | ||||||||||||
|
|
||||||||||||
| `depth` is not re-calculated if a message is inserted into the middle of the DAG. | ||||||||||||
| incrementing integer, but backfilled events start with `stream_ordering=-1` and decrement. | ||||||||||||
|
|
||||||||||||
| --- | ||||||||||||
|
|
||||||||||||
| - `/sync` returns things in the order they arrive at the server (`stream_ordering`). | ||||||||||||
| - `/backfill` returns them in the order determined by the event graph `(topological_ordering, stream_ordering)`. | ||||||||||||
| - `/messages` (and `/backfill in the federation API) return them in the order determined by the event graph `(topological_ordering, stream_ordering)`. | ||||||||||||
|
|
||||||||||||
| The general idea is that, if you're following a room in real-time (i.e. `/sync`), you probably want to see the messages as they arrive at your server, rather than skipping any that arrived late; whereas if you're looking at a historical section of timeline (i.e. `/messages`), you want to see the best representation of the state of the room as others were seeing it at the time. | ||||||||||||
| The general idea is that, if you're following a room in real-time (i.e. | ||||||||||||
| `/sync`), you probably want to see the messages as they arrive at your server, | ||||||||||||
| rather than skipping any that arrived late; whereas if you're looking at a | ||||||||||||
| historical section of timeline (i.e. `/messages`), you want to see the best | ||||||||||||
| representation of the state of the room as others were seeing it at the time. | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| ## Forward extremity | ||||||||||||
|
|
||||||||||||
| Most-recent-in-time events in the DAG which are not referenced by any `prev_events` yet. | ||||||||||||
| Most-recent-in-time events in the DAG which are not referenced by any other events' `prev_events` yet. | ||||||||||||
|
|
||||||||||||
| The forward extremities of a room are used as the `prev_events` when the next event is sent. | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| ## Backwards extremity | ||||||||||||
|
|
||||||||||||
| The current marker of where we have backfilled up to. | ||||||||||||
|
|
||||||||||||
| A backwards extremity is a place where the oldest-in-time events of the DAG | ||||||||||||
| The current marker of where we have backfilled up to and will generally be the | ||||||||||||
| oldest-in-time events we know of in the DAG. | ||||||||||||
|
|
||||||||||||
| This is an event where we haven't fetched all of the `prev_events` for. | ||||||||||||
|
|
||||||||||||
| Once we have fetched all of it's `prev_events`, it's unmarked as backwards | ||||||||||||
| extremity and those `prev_events` become the new backwards extremities. | ||||||||||||
| Once we have fetched all of its `prev_events`, it's unmarked as a backwards | ||||||||||||
| extremity and those `prev_events` become the new backwards extremities (unless | ||||||||||||
| we have already persisted them). Also in reality, we backfill in batches of 20 | ||||||||||||
| events or so, so only the `prev_events` of the last oldest-in-time event will | ||||||||||||
| become the backwards extremeties. | ||||||||||||
|
||||||||||||
| extremity and those `prev_events` become the new backwards extremities (unless | |
| we have already persisted them). Also in reality, we backfill in batches of 20 | |
| events or so, so only the `prev_events` of the last oldest-in-time event will | |
| become the backwards extremeties. | |
| extremity (although we may have formed new backwards extremities during the backfilling process). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I tweaked it slightly to include the prev event chain,
Once we have fetched all of its
prev_events, it's unmarked as a backwards
extremity (although we may have formed new backwards extremities from the prev
events during the backfilling process).
MadLittleMods marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
MadLittleMods marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
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.
Uh oh!
There was an error while loading. Please reload this page.