Cut game page queries and cold-start work after deploys #5015
All Vouch review confidence checks passed
Residual risk 0.49 = Change Risk (0.76) × (1 − Review Confidence (0.35)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.76 · 553 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 32% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.378
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.076
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #5015"
general
weight: 0.35
connorshea
<!-- claude-projects-attribution: {"github_login":"connorshea"} -->
_Requested by Connor · project thread_
What I found
MemoryStorewrite took 22 ms, there was 700 ms of middleware before the controller started, andSELECT games WHERE id = $1took 280 ms. That looks like CPU contention and cold processes, not slow resolvers.Changes (one commit each)
1. Load model schemas in Puma's master before forking (
ProcessWarmup, abefore_forkhook). Columns, attribute methods and the operation allowlist's canonical documents are built once and inherited by both workers. It never raises: if it fails, the workers just do the work themselves as before. Locally, the first page load after boot went from ~260 ms to ~175 ms with a ~0.1 ms database round trip. In prod each saved query is also a network round trip.2. Load both kinds of library events in one query per table.
preload_eventablesgrouped events by category, soadd_to_libraryandchange_completion_statuseach loadedevents_game_purchase_events, their library entries, owners, games and covers separately.3. Only preload activity events' games when the query reads them. The
nodesfield onEventConnectionTypenow gets the lookahead. A game's activity list never selectseventable.game, so it no longer loads every event's game plus cover attachment, blob and variant records. The global and profile feeds are unchanged. GetGameActivity: 21 → 9 queries, 26 → 16 ms locally.4.
game(wikidataId: null)returns null. Before, an explicit null passed validation and returned whichever game without that ID Postgres found first. This also keeps the next commit's un-LIMITed query safe.5. Load a game and its cover URL's records in one query. When
coverUrlis selected, the resolver eager loads attachment → blob → variant record → variant attachment → variant blob in the same joined query as the game, instead of five serial round trips. GetGame: 31 → 26 queries.| Operation (local, warm) | Before | After |
|---|---|---|
| GetGame | 31 queries, ~45 ms | 26 queries, ~46 ms |
| GetGameActivity | 21 queries, ~26 ms | 9 queries, ~16 ms |
| GetGameReviews | 11 queries, ~28 ms | unchanged |
| GetStores | 1 query, ~4 ms | unchanged |
The local ms barely move for GetGame because local round trips are ~0.1 ms. In prod, five fewer serial round trips matter more.
Not changed
Testing
bundle exec rspec: 1461 examples, 0 failures.bundle exec rubocop: no offenses.ProcessWarmup, the one-query library event preload, activity skipping and keeping game preloads, the one-query game + cover, a Steam App ID lookup with cover, and the null ID case. I checked that each new query-count spec fails without its change.After this deploys, the 2 vCPU instance and the extra traces from #5011 should show whether the slow samples were cold starts. If warm GetGame is still over ~300 ms in Sentry, the next step would be a Sentry profile of a warm request.
---
_Generated by Claude Code_