API hot spots under load: scheme list validation, review summary, recurrence horizon re-reading YAML #182

Open
opened 2026-09-26 13:31:15 +00:00 by claude-bot · 0 comments
Collaborator

From the py-spy profile taken while diagnosing #180. After fixing the N+1 settings read in list_schemes (#180), the remaining costs under a CPU-limited (0.5 CPU) parallel E2E run were:

endpoint / frame share of samples note
list_schemes pydantic validation 42.7% about 108 schemes a year, already selectin-loaded. Look at response-model validation cost (e.g. model_construct for trusted ORM rows, or a lighter list schema).
review_summary 22.8% plans 14+ nights through plan_for_range on every banner render. Cache per (date, settings version, scheme revision), or at least share one planner across the request.
get_recurrence_horizon 11.1% re-reads the recurrence YAML tables on every call. They're static data shipped in the image, so load them once.

Production has far less concurrency than 8 E2E workers, so this is headroom, not an outage. But the calendar, banner and Settings page all hit these on every load, and a small host shares its CPU with other services.

Done when: each is measured before and after, the season-preview and watchdog E2E specs are stable at 0.5 CPU with 8 workers, and nothing changes in behaviour.

From the py-spy profile taken while diagnosing #180. After fixing the N+1 settings read in `list_schemes` (#180), the remaining costs under a CPU-limited (0.5 CPU) parallel E2E run were: | endpoint / frame | share of samples | note | |---|---|---| | `list_schemes` pydantic validation | 42.7% | about 108 schemes a year, already `selectin`-loaded. Look at response-model validation cost (e.g. `model_construct` for trusted ORM rows, or a lighter list schema). | | `review_summary` | 22.8% | plans 14+ nights through `plan_for_range` on every banner render. Cache per (date, settings version, scheme revision), or at least share one planner across the request. | | `get_recurrence_horizon` | 11.1% | **re-reads the recurrence YAML tables on every call.** They're static data shipped in the image, so load them once. | Production has far less concurrency than 8 E2E workers, so this is headroom, not an outage. But the calendar, banner and Settings page all hit these on every load, and a small host shares its CPU with other services. **Done when:** each is measured before and after, the season-preview and watchdog E2E specs are stable at 0.5 CPU with 8 workers, and nothing changes in behaviour.
claude-bot added this to the v1.2.0 milestone 2026-09-26 13:31:26 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rbrooks/Iris-WLED#182
No description provided.