Fix initial feed load performance and relay timing#20
Merged
Conversation
…windows The initial feed was laggy because limit=100 is per-relay — with 30+ scored relays via outbox routing, thousands of events flooded in simultaneously, each triggering recompose. Changes: - Await at least 3 relay connections before subscribing (prevents messages being silently dropped by not-yet-connected relays) - Reduce initial feed limit from 100 to 25 per relay (loadMore handles pagination for older content) - Tighten adaptiveSince windows: 7d→2d for ≤20 follows, 48h→12h for ≤100, 12h→4h for ≤300, 3h→1h for ≤700, 30m→15m for 700+ - Single relay feed keeps limit=50 (only one relay, no multiplication) - Fix reconnectAll() not cleaning relayIndex for dead ephemeral relays - Fix O(n) ephemeralRelays.values scan → O(1) containsKey lookup
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.
Summary
subscribeFeed()was firing immediately afterupdateRelays(), but WebSocket connections are async —relay.send()silently drops messages when not connected. Now waits for at least 3 relays (5s timeout).limit=100per relay meant thousands of events flooding in simultaneously, each triggering processRelayEvent → addEvent → StateFlow → recompose. 25 per relay is plenty for the initial screen;loadMore()handles pagination.ephemeralRelaysbut notrelayIndex, causing sends to dead relays on subsequent lookups.!in ephemeralRelays.valuesscan withcontainsKeylookup.Test plan