Batch nostr subscriptions / profile fetches (subscription grouping) #123

Open
opened 2026-06-18 11:21:02 +00:00 by padreug · 0 comments
Owner

From the nostr-patterns review — future deeper dig (not urgent).

Observation

NDK groups subscriptions by filter fingerprint with a short delay (~10ms) to merge similar REQs into one (subscription/grouping.ts); welshman batches loaders and tracks event→relay provenance. Our RelayHub opens one subscription per subscribe() call (no cross-caller merging), and ProfileService fetches one subscription per pubkey (getProfile) rather than batching via its existing bulk path.

At our current scale this is fine (a handful of subs: feed, detail, likes, bookmarks; useEventLikes already batches coords). But as surfaces grow it's worth:

  • Batching ProfileService.getProfile calls within a small window into one authors:[...] REQ (the bulk path already exists).
  • Optionally, filter-fingerprint grouping in RelayHub (à la NDK), and event→relay tracking (welshman Tracker) for provenance/failover.

Scope

Future optimization / deeper dig — measure first. Not correctness.

Gap #3 of the nostr-patterns review; left as an issue per decision.

From the nostr-patterns review — future deeper dig (not urgent). ## Observation NDK groups subscriptions by **filter fingerprint** with a short delay (~10ms) to merge similar REQs into one (`subscription/grouping.ts`); welshman batches loaders and tracks event→relay provenance. Our `RelayHub` opens one subscription per `subscribe()` call (no cross-caller merging), and `ProfileService` fetches **one subscription per pubkey** (`getProfile`) rather than batching via its existing bulk path. At our current scale this is fine (a handful of subs: feed, detail, likes, bookmarks; `useEventLikes` already batches coords). But as surfaces grow it's worth: - Batching `ProfileService.getProfile` calls within a small window into one `authors:[...]` REQ (the bulk path already exists). - Optionally, filter-fingerprint grouping in `RelayHub` (à la NDK), and event→relay tracking (welshman `Tracker`) for provenance/failover. ## Scope Future optimization / deeper dig — measure first. Not correctness. _Gap #3 of the nostr-patterns review; left as an issue per decision._
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/webapp#123
No description provided.