Skip to content

perf(backend): fix top backend performance issues (P0)#157

Open
KillerX wants to merge 2 commits into
mainfrom
perf/backend-p0-fixes
Open

perf(backend): fix top backend performance issues (P0)#157
KillerX wants to merge 2 commits into
mainfrom
perf/backend-p0-fixes

Conversation

@KillerX

@KillerX KillerX commented Jul 3, 2026

Copy link
Copy Markdown
Member

Address the four highest-impact findings from the backend performance review:

  • Event.challenges N+1: add batched getVisibleEventChallenges (batch quiz session-access, enrollment, quiz loads and translations), mirroring the already-optimized project path. The event resolver now delegates to it; visibility semantics (incl. unauthenticated viewers) are preserved.
  • Cache KeyRegistry leak: ristretto eviction callbacks only expose the hashed key, so wrap stored values to carry their string key and prune the registry on OnEvict/OnReject. Prevents unbounded registry growth and DeletePrefix slowdown over time. Adds a regression test.
  • Push broadcast: use a shared HTTP client with a request timeout and a bounded worker pool so a stalled endpoint can't hang a broadcast and large fan-outs don't exhaust FDs/DB pool. Replace hand-rolled contains with strings.Contains.
  • Maintenance SyncUserData: process users through a bounded concurrency pool instead of sequential Members API lookups, keeping the cron response contract unchanged.

Assisted by Claude Opus 4.8 via Claude Code

KillerX added 2 commits July 3, 2026 19:54
Address the four highest-impact findings from the backend performance
review:

- Event.challenges N+1: add batched getVisibleEventChallenges (batch
  quiz session-access, enrollment, quiz loads and translations),
  mirroring the already-optimized project path. The event resolver now
  delegates to it; visibility semantics (incl. unauthenticated viewers)
  are preserved.
- Cache KeyRegistry leak: ristretto eviction callbacks only expose the
  hashed key, so wrap stored values to carry their string key and prune
  the registry on OnEvict/OnReject. Prevents unbounded registry growth
  and DeletePrefix slowdown over time. Adds a regression test.
- Push broadcast: use a shared HTTP client with a request timeout and a
  bounded worker pool so a stalled endpoint can't hang a broadcast and
  large fan-outs don't exhaust FDs/DB pool. Replace hand-rolled contains
  with strings.Contains.
- Maintenance SyncUserData: process users through a bounded concurrency
  pool instead of sequential Members API lookups, keeping the cron
  response contract unchanged.

Assisted by Claude Opus 4.8 via Claude Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant