Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

V2 bootstrap takes ~5s: optimize /api/v2/bootstrap backend and first paint

オープン
#1,725 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@paullizer がすでに取り組んでいます。

2026年10月8日 から。

評価

この issue はまだ評価されていません。

説明

enhancement P1 python

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_catalog and 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_settings read and the first groups query (per-user feature checks, settings and sanitize work).
    • Gap 2, p50 ~1.8s: between the agent governance checks and the first prompts query. This is _build_chat_model_catalog, which makes no Cosmos calls (endpoint normalize/sanitize with json.loads(json.dumps()) copies, model profile projection, reasoning policy, per-endpoint governance).
  • N+1 query patterns: per-group groups reads; per-group group_actions/group_agents/group_prompts queries; ~4 governance_item_policies calls per agent.
  • get_settings() has no in-process cache. Each call does a Redis GET, json.loads, several deepcopies, and a full normalize_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

  1. Use the phase timings added by the quick fix ([V2_BOOTSTRAP] Phase timings log event) to confirm where the 4s goes before changing code.
  2. Per-request memoization of get_settings() and governance policy lookups; avoid repeated deepcopy/normalize.
  3. Cache the built model catalog keyed by settings version, user, and group membership, or make its normalization cheaper.
  4. Batch the N+1 queries (per-group and per-agent) into IN queries.
  5. 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.
  6. Optional ops: run background pollers outside the web workers (SIMPLECHAT_RUN_BACKGROUND_TASKS=false on 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/bootstrap p50 under 2s in production telemetry
  • V2 home LCP measurably lower; shell renders before heavy catalogs where split
  • Legacy /chats unaffected 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/scope read, bootstrap reads use cache: '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

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/simplechat のほかの issue

microsoft/simplechat の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。