Skip to content

perf(events): skip RSVP and photo hydration on calendar reads - #1411

Merged
timkwist merged 3 commits into
mainfrom
fix-event-load-memory
Aug 13, 2026
Merged

perf(events): skip RSVP and photo hydration on calendar reads#1411
timkwist merged 3 commits into
mainfrom
fix-event-load-memory

Conversation

@timkwist

Copy link
Copy Markdown
Collaborator

Overview

Staging gunicorn workers grew tens of MB each time someone opened the calendar or a new event. The list endpoint hydrated every RSVP and invitee and presigned photos the calendar never renders; event detail did the same for viewers who cannot see the guest list.

This keeps the same JSON shape (list photo_url / created_by_photo_url / co_host_photo_urls stay in the schema as empty values). Counts come from SQL subqueries. List prefetches only the viewer's RSVP. Detail loads guests and invitees only when the viewer is allowed to see them. Hosts and people with an active RSVP still get the full guest list.

Test plan

  • tests/test_event_list_memory.py — list does not instantiate every RSVP; photo fields empty; my_rsvp still works; invite-only stays hidden; detail skips RSVP hydration when guests are hidden
  • Related event/RSVP/visibility/capacity tests (132 passed)
  • make agent-lint / make agent-typecheck / make agent-complexity / schema checks
  • make agent-frontend-ci (no frontend changes)
  • Local A/B vs main on 40 events / 1,001 RSVPs: list media_path 200→0 and RSVP inits 1,001→0; stranger detail RSVP inits 26→0 and media_path 31→5; host/attendee detail unchanged
  • On staging with PDA_MEMORY_PROFILE=1, open the calendar then several events as a non-guest and confirm list media_path_calls is ~0 and RSS no longer jumps tens of MB per new event

🤖 Created with Cursor

Staging workers grew tens of MB per calendar load and event open because list/detail hydrated every RSVP, invitee, and presigned photo. Count in SQL, prefetch only the viewer's RSVP, and skip guest photos the UI never shows.
Keep list RSVPs on _viewer_rsvps so the relation is not a filtered cache,
honor existing prefetches in _event_out, and check invite-only membership
with exists() instead of loading every invitee.
Calendar list and non-host detail never render invited names, so counting invitees for everyone was wasted work. Can't-go still counts as RSVP'd — those viewers can see who is going. Host-removed RSVPs stay hidden.
@timkwist
timkwist merged commit 3cf2107 into main Aug 13, 2026
3 checks passed
@timkwist
timkwist deleted the fix-event-load-memory branch August 13, 2026 13:07
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