perf(forecast): per-request memoization cache — §22 cold build (#1129) #1160
No reviewers
Labels
No labels
admin
analytics
auth
automation
bug
business
chore
ci
compliance
data
data-moat
docs
duplicate
dx
enhancement
Fable 5 ревью
feedback/max
generative
GG-форсайт
needs-discussion
needs-human
observability
pause-bots
performance
priority/p0
priority/p1
priority/p2
priority/p3
scope/backend
scope/db
scope/devops
scope/frontend
scope/qa
scrapers
security
site-finder
stage/1
stage/2
status/blocked
status/done
status/needs-analysis
status/needs-fix
status/qa
status/ready
status/review
status/wip
tech-debt
tradein
ux
week ревью 1
wontfix
вторичка
ИРД
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lekss361/gendesign#1160
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "perf/forecast-parallel-horizons-1129"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Что
#1129: холодный §22-прогноз ~215-233с (~4 мин) на проде → per-request memoization-кэш. Это «Прогноз рассчитывается…» 4 минуты на демо.
Профиль (корень)
§9.x-слои массово пере-вызывают ОДНИ И ТЕ ЖЕ горизонт/сегмент-инвариантные БД-загрузки с идентичными аргументами: get_competitors ×69, market_metrics ×124, get_monthly_macro ×290 на ОДИН отчёт. Это case (c): общая дорогая загрузка пере-выполняется N раз.
Решение (безопасное — без конкурентности)
forecast_request_cache.py—forecast_cache()(ContextVar, открывается ОДИН раз в orchestrator на сборку отчёта) +@cached(key_builder)на дорогих §9.x-loader'ах. Уникальная загрузка считается ОДИН раз, переиспользуется тот же frozen-инстанс.Качество
code-reviewer: ✅ APPROVE — оба gate: ключи корректны (каждый key-builder включает все result-affecting args; horizon_months/rate_future/window_months keyed где нужно) + mutation-safe (8 продьюсеров frozen, все consumers read-only). Нет вектора «тихо неверного прогноза».Замер
Механизм доказан тестом (×N→1). Wall-clock замерю на проде post-deploy (baseline 215-233с → цель ≤90с).
Refs #1129.