V2 bootstrap takes ~5s: optimize /api/v2/bootstrap backend and first paint
メンテナーはふだん 1 日以内に返信
@paullizer がすでに取り組んでいます。
2026年10月8日 から。
評価
この issue はまだ評価されていません。
説明
Summary
Make GET /api/v2/bootstrap faster so V2 renders sooner. Today the V2 shell (including the home logo, the LCP element) waits on this single call, which takes about 5s in production. Legacy pages that share the same catalog code, like /chats (p50 ~9.1s), are slow for the same reason.
User Value
- V2 first paint: ~5.6s LCP today; the target is about 1.5–2.5s.
- Legacy
/chats,/workspace, and admin pages that share_build_chat_model_catalogand the settings helpers get faster too.
Evidence (App Insights, simplechat-20260506, 3–7 days)
GET /api/v2/bootstrap: n≈877, p50 5.1s / p90 7.1s / p99 10.4s. It's the same at idle and busy hours, so it is deterministic per-request work, not load.- About 125 sequential Cosmos calls per bootstrap total only ~0.75s. Roughly 4s is uninstrumented time:
- Gap 1, p50 ~2.0s: between the
user_settingsread and the firstgroupsquery (per-user feature checks, settings and sanitize work). - Gap 2, p50 ~1.8s: between the agent governance checks and the first
promptsquery. This is_build_chat_model_catalog, which makes no Cosmos calls (endpoint normalize/sanitize withjson.loads(json.dumps())copies, model profile projection, reasoning policy, per-endpoint governance).
- Gap 1, p50 ~2.0s: between the
- N+1 query patterns: per-group
groupsreads; per-groupgroup_actions/group_agents/group_promptsqueries; ~4governance_item_policiescalls per agent. get_settings()has no in-process cache. Each call does a Redis GET,json.loads, several deepcopies, and a fullnormalize_loaded_settings.- Background pollers run inside every gunicorn web worker (2 workers × 3 instances). The workflow scheduler polls every 5s, and plan CPU averages ~12% (about one core busy). This may add GIL contention to CPU-bound request work.
Proposed Behavior
- Use the phase timings added by the quick fix (
[V2_BOOTSTRAP] Phase timingslog event) to confirm where the 4s goes before changing code. - Per-request memoization of
get_settings()and governance policy lookups; avoid repeated deepcopy/normalize. - Cache the built model catalog keyed by settings version, user, and group membership, or make its normalization cheaper.
- Batch the N+1 queries (per-group and per-agent) into
INqueries. - Split bootstrap: return critical shell data (user, branding, navigation, features, scope) first, and load the heavy catalogs (models, agents, prompts) separately so the shell and logo paint early.
- Optional ops: run background pollers outside the web workers (
SIMPLECHAT_RUN_BACKGROUND_TASKS=falseon web plus a dedicated worker), relax the 5s workflow poll, enable HTTP/2 on the App Service, and use route-level code splitting in the V2 bundle.
Acceptance Criteria
- Phase timing data reviewed and the top contributors to Gap 1 and Gap 2 identified
-
GET /api/v2/bootstrapp50 under 2s in production telemetry - V2 home LCP measurably lower; shell renders before heavy catalogs where split
- Legacy
/chatsunaffected or faster - Functional tests, version bump, fix doc and release notes per repo rules
Notes
- Related quick fix (separate change): the V2 group switch no longer waits on a full bootstrap. It uses a lightweight
/api/v2/scoperead, bootstrap reads usecache: 'no-store'so the browser can't serialize them, and bootstrap phase timing logs are added. - Key files:
route_backend_v2.py(v2_bootstrap),route_frontend_chats.py(_build_chat_model_catalog,_build_chat_prompt_catalog),functions_settings.py(get_settings,normalize_model_endpoints,sanitize_settings_for_user),app_settings_store.py,background_tasks.py,app.py(start_background_tasks),application/v2_ui/src/App.tsx. - Size estimate: L (cross-cutting backend plus frontend, shared legacy code paths).
- 主要言語
- Python
- スター
- 155
- フォーク
- 116
- 平均マージ
- 7時間 40分
- マージ済み PR(30日)
- 175
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/simplechat のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/simplechat#1491 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
microsoft/simplechat#1370 ·
メンテナーはふだん 1 日以内に返信
-
Serve the new UI at the main URLs, move the legacy UI under /legacy, and let admins control interface access対応中かも @paullizer が 6 日前に担当しました。 オープンCreated By Copilot enhancement P1
microsoft/simplechat#1723 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
V2 parity: replace the remaining hand-offs to the legacy interface so "New UI only" loses nothing対応中かも @paullizer が 6 日前に担当しました。 オープンCreated By Copilot enhancement P1
microsoft/simplechat#1722 · コメント 6 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
microsoft/simplechat#1719 ·
メンテナーはふだん 1 日以内に返信
microsoft/simplechat の issue をすべて見る
似ている issue
-
customer-reported question
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
Azure/azure-sdk-for-python#49548 · コメント 1 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
btclib-org/btclib-wallet#409 ·
メンテナーはふだん 1 日以内に返信
-
Phase 2 PSA Capability & Career Profile
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
bcgov/digital-journeys#2310 ·
-
bug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fastmachinelearning/hls4ml#1582 ·
メンテナーはふだん 3 日以内に返信
-
Sort modelsオープンenhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信