Changeset 43273c9 in Klonkt


Ignore:
Timestamp:
07/01/2026 06:38:05 PM (2 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
d18c60e
Parents:
dc41bef
Message:

refactor(fediverse): thread crawl one level per pass, like Mastodon

Match Mastodon's FetchReplies behaviour: crawl ONE hop of replies per pass instead
of a deep BFS. Deeper levels still fill in — a cached reply becomes a seed on the
next crawl, so its replies are pulled on a later view (Mastodon's per-status cascade).
More conservative + polite; same push-first + cache + bounded design.

  • src/services/ActivityPubService.js — THREAD_MAX_DEPTH 3 → 1; comment updated.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/services/ActivityPubService.js

    rdc41bef r43273c9  
    18401840// Most replies reach us by delivery, but replies-to-replies that live on other servers and
    18411841// aren't addressed to us are missed. This pulls the AS2 `replies` collections of the replies
    1842 // we DO have, caching any newly-found ones in ap_interactions. Bounded (depth/fetch caps),
    1843 // polite (serial), PULL only, and stale-while-revalidate: it never runs in a page request —
    1844 // the view renders from cache; a stale post kicks off a background refresh for the NEXT view.
     1842// we DO have, caching any newly-found ones in ap_interactions.
     1843//
     1844// Matches Mastodon's behaviour: ONE level per crawl (like its FetchRepliesService), not a deep
     1845// recursive walk. Deeper levels fill in incrementally across crawls — once a fetched reply is
     1846// cached it becomes a seed itself, so its own replies are pulled on a later view (Mastodon's
     1847// per-status cascade). Bounded + polite (serial), PULL only, and stale-while-revalidate: it
     1848// never runs in a page request — the view renders from cache; a stale post kicks off a
     1849// background refresh for the NEXT view.
    18451850const THREAD_TTL_MS = 15 * 60 * 1000;   // don't re-crawl a post more than ~4×/hour
    1846 const THREAD_MAX_DEPTH = 3;             // replies-to-replies-to-replies
     1851const THREAD_MAX_DEPTH = 1;             // one hop per crawl (like Mastodon); deeper fills in over crawls
    18471852const THREAD_MAX_FETCHES = 30;          // hard cap on remote GETs per crawl (be a good peer)
    18481853const _crawlingThreads = new Set();     // per-post in-flight lock (no stampede across views)
Note: See TracChangeset for help on using the changeset viewer.