perf(backfill): stop the prefetch worker from throttling itself (Tier 1) #88

Merged
root merged 1 commits from dev into main 2026-06-03 18:29:06 +03:00
Owner

The worker's own upstream fetches called touchActivity(), setting the
prefetch:activity: cooldown key (TTL 300s) that checkCooldown then
honoured — so after each fetch the worker paused itself for up to ~5 minutes
(re-checking every 60s, ~5 empty cycles per key). At ~1 fetch / 5 min the
3387-job backlog needed ~6 days to drain.

  • Wrap each worker job in an AsyncLocalStorage backfill context; touchActivity
    skips the cooldown key when invoked from the worker, so the cooldown reflects
    only real user requests (worker yields to users, never to itself).
  • Cooldown TTL 300s -> 90s (a request 5 min ago isn't "active").
  • checkCooldown pauses for the key's actual remaining TTL (one wait) instead of
    a fixed 60s re-check loop.

No extra upstream load — only removes the worker's self-imposed idle time.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

The worker's own upstream fetches called touchActivity(), setting the prefetch:activity:<source> cooldown key (TTL 300s) that checkCooldown then honoured — so after each fetch the worker paused itself for up to ~5 minutes (re-checking every 60s, ~5 empty cycles per key). At ~1 fetch / 5 min the 3387-job backlog needed ~6 days to drain. - Wrap each worker job in an AsyncLocalStorage backfill context; touchActivity skips the cooldown key when invoked from the worker, so the cooldown reflects only real user requests (worker yields to users, never to itself). - Cooldown TTL 300s -> 90s (a request 5 min ago isn't "active"). - checkCooldown pauses for the key's actual remaining TTL (one wait) instead of a fixed 60s re-check loop. No extra upstream load — only removes the worker's self-imposed idle time. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
root added 1 commit 2026-06-03 18:29:00 +03:00
perf(backfill): stop the prefetch worker from throttling itself (Tier 1)
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
1e3953417e
The worker's own upstream fetches called touchActivity(), setting the
prefetch:activity:<source> cooldown key (TTL 300s) that checkCooldown then
honoured — so after each fetch the worker paused itself for up to ~5 minutes
(re-checking every 60s, ~5 empty cycles per key). At ~1 fetch / 5 min the
3387-job backlog needed ~6 days to drain.

- Wrap each worker job in an AsyncLocalStorage backfill context; touchActivity
  skips the cooldown key when invoked from the worker, so the cooldown reflects
  only real user requests (worker yields to users, never to itself).
- Cooldown TTL 300s -> 90s (a request 5 min ago isn't "active").
- checkCooldown pauses for the key's actual remaining TTL (one wait) instead of
  a fixed 60s re-check loop.

No extra upstream load — only removes the worker's self-imposed idle time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
root merged commit d1ad33c26a into main 2026-06-03 18:29:06 +03:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: root/sase.tr#88