Repository navigation
Conversation
Search and invite recovery read the community's whole open-channel directory (kind 39000) from the relay. The list kept it in memory for 30 seconds, so every search session after that, and every launch, downloaded the whole directory again. Save the directory in a file per community and account, next to the media cache. Readers serve the saved copy at once. When a reader opens, at most once a minute, the app asks the relay only for directory changes since the newest saved one (less a minute of overlap). Once the last full read is a day old, the next check reads the whole directory in the background and replaces the copy, which drops channels that became private, unlisted or were deleted. Opening a channel the relay no longer serves drops it at once. Signing out or leaving the community deletes the file. Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@squareup.com>
Collaborator
Author
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Review fixes for the saved open-channel directory: - Encode, measure and decode the file's JSON in Isolate.run; the UI isolate only reads and writes bytes. - Readers opening while a background directory read is in flight share it, so a full read slower than the check interval is not displaced and restarted. - A catch-up that returns only held events (the overlap always returns the newest) saves nothing and leaves the list untouched. - A read in flight when a channel is dropped on open no longer brings it back: its response predates the drop. - Resolving the file waits at most 3 s and treats failure as no saved copy, as the image cache does. Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@squareup.com>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz.block.builderlab.xyz> Signed-off-by: Tom Brow <tomb@squareup.com>
This branch was successfully deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Search and invite recovery read a community's open-channel directory (every open, listed channel's kind 39000 metadata) from the relay, and match names on the device. Until now the app kept that directory in memory for 30 seconds only, so every search session after that, and the first search after every launch, downloaded the whole directory again. This follows #9466 directory-only search load and #9457 directory keeps message times, which made each of those downloads cheaper; this one makes most of them unnecessary.
Now the directory is saved in a file per community and account, next to the image cache, and search reads it from there:
The saved events omit signatures (the relay signed them; the copy is a cache of what it served). The file's JSON is encoded and decoded off the UI isolate, and an unavailable caches directory (or one that takes over 3 seconds) just means no saved copy. A file that is unreadable, from another version, or over 20,000 channels or 16 MiB is discarded and read again from the relay. There is no relay change.
CONTEXT.mdgains an "Open-channel directory" entry.Validation
Measured on an iOS simulator signed in to a test community, with a temporary local counter on each relay query response (not part of this PR), main at 6974237 vs this branch. The full read grows with the number of open channels (about 600 bytes each); the catch-up grows only with what changed. Search results were identical on both builds, and opening an unjoined result from the saved directory still showed its preview with Join.
Tests:
since, with a real file and a fake clock: the first reader saves the directory without signatures; more readers within a minute ask nothing; a minute later a reader asks only for changes since the newest saved one less a minute; after a relaunch the saved copy serves at once and the catch-up starts from it; a channel that turned private stays until the daily full read replaces the copy; the search status never shows loading for the background reads; a catch-up of only held events leaves the list identical and the file unwritten; a second search a minute into a slow full read shares it; and opening a channel the relay no longer serves drops it, even with a read in flight. Each guard was checked by breaking it: removing the once-a-minute limit, droppingsince, never doing the full read, merging the full read instead of replacing, removing the drop-on-open, the no-change check, the shared in-flight read, or the in-flight drop fence each fail the test.flutter analyzepass.No visible change, so no screenshots: the same results appear, just without a download on later searches.
Regressions