Batch the profile page's viewer-relationship lookups (#3648) (#3649)
- Batch the profile page's viewer-relationship lookups (#3648)
The profile page was slow in two independent ways, both CPU/memcache-bound rather than SQL-bound.
format_userlink in views/profile/blocks.tt ran once per listed user and called remote.watches / remote.trusts (or memberof) for each, every one an uncached trustmask / checkrel memcache round-trip -- ~3,000 gets for a ~1,500-relationship profile (~6s logged in). Unlike #3646 these keys are all distinct, so memoizing trustmask wouldn't help; instead the controller now loads the viewer's circle once via watcheduserids / trusted_userids / member_of_userids into {id => 1} hashes and the template does an O(1) membership check.
Separately, sort_by_username recomputed display_name on every O(n log n) comparison (~31k calls, ~1s even logged out); it now uses a Schwartzian transform so each name is computed once.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- Trim change-narration and duplicate issue refs from the profile comments
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
