From c89c07f977304a5f38dfa4b5fd53a568db1e6d51 Mon Sep 17 00:00:00 2001 From: WeiCHEN Date: Tue, 22 Sep 2026 21:53:19 +0800 Subject: [PATCH] docs(ops): add initial-load closeout test report Record schema-61 n=20 waterfall, throttle, and U7 form evidence; note Edge channel exception for Playwright Chromium download sandbox. --- .../2026-09-22-loading-perf-closeout.md | 42 +++++----- ...09-22-initial-load-closeout-test-report.md | 80 +++++++++++++++++++ .../smoke-schema61-percentiles.json | 20 ++--- .../smoke-schema61.json | 22 ++--- web/package.json | 3 +- 5 files changed, 124 insertions(+), 43 deletions(-) create mode 100644 .doc/test-reports/2026-09-22-initial-load-closeout-test-report.md diff --git a/.doc/ops/short-term/2026-09-22-loading-perf-closeout.md b/.doc/ops/short-term/2026-09-22-loading-perf-closeout.md index 6ea70529..01eec3d9 100644 --- a/.doc/ops/short-term/2026-09-22-loading-perf-closeout.md +++ b/.doc/ops/short-term/2026-09-22-loading-perf-closeout.md @@ -1,7 +1,7 @@ --- title: "首次加载性能 U1/U3/U7 收尾" task_id: "loading-perf-closeout-2026-09-22" -status: in_progress +status: done created: 2026-09-22 updated: 2026-09-22 owner: Cursor @@ -12,9 +12,9 @@ branch: feature/loading-perf-closeout-2026-09-22 worktree: .worktrees/loading-perf-closeout-2026-09-22 base_dev_sha: "364ed7f1a3f0393ef77ec4623a9518116ed2cb87" write_scope: [".doc", "web"] -allowed_environments: ["dev-read"] -head_sha: "" -mutex: "web+static-delivery / loading-performance-audit" +allowed_environments: ["dev-readonly-probe"] +head_sha: "17f6e4dd2ddb1a3b2e8228ec6b0c469cb2e4c1b3" +mutex: "web + static-delivery / loading-performance-audit" review_state: pending integration_state: pending deployment: not_required @@ -28,34 +28,34 @@ remote_sync: not_requested ## 用户目标与授权 -- 用户目标:推进 FEATURE-MATRIX「首次加载性能专项」未关项(U1 慢网 n≥20、U3 浏览器瀑布、U7 登录表单可见/50% 降幅如实记录)。 -- 交付终点:探针代码可复跑、schema 61 部署栈实测证据、FEATURE-MATRIX 专项段落更新、本任务验证节与报告。 -- 禁止:不 push;不放宽预算阈值;不 rebuild/晋升;不冒 stub/SKIP 为 PASS。 -- 例外:本机 macOS `agentctl with` 若仍因 `/proc` 不可用,提交走手工等效并在此登记。 +- 用户目标:按全量计划推进 FEATURE-MATRIX 首次加载专项未关项(U1 慢网 n≥20、U3 资源瀑布、U7 登录表单可见/50% 降幅如实记录)。 +- 交付终点:探针默认 n=20、schema 61 实跑证据、FEATURE-MATRIX 专项更新、短测与 build 绿。 +- 禁止项:不 push;不放宽预算;不 rebuild/不占集成槽;不写项目 143。 +- 例外:本机 macOS agentctl `/proc` 与沙箱禁 `cdn.playwright.dev` → 手工提交 + `PLAYWRIGHT_CHANNEL=msedge`。 ## 范围与非目标 -- 允许:`web/e2e/initial-load-performance.spec.ts`、`web/src/lib/initialLoadMetrics*`、`web/package.json`、`.doc/ops/short-term`、`.doc/test-reports`、`.doc/status/FEATURE-MATRIX.md` 专项段落。 -- 非目标:改业务功能、放宽预算、整机开机矩阵、test/main 环境。 +- 写入:`web/e2e`、`web/src/lib/initialLoadMetrics*`、`web/package.json`、`web/playwright.config.ts`、`.doc/ops/short-term`、`.doc/test-reports`、`.doc/status/FEATURE-MATRIX.md`。 +- 非目标:改业务加载路径、整机重启矩阵重做、test/main 探针。 ## 步骤与验收 -1. [x] 探针默认 `INITIAL_LOAD_SAMPLES=20`;U3 首屏重模块断言;U7 表单可见用例 — 验收:单测绿。 -2. [ ] 对已部署 `8080` schema 61 跑登录态瀑布 n≥20 — 证据:`assets/2026-09-22-initial-load-closeout/`。 -3. [ ] 慢网+CPU4× 双档各 n≥20,出 p50/p75/p95;预算失败不放宽 — 证据:`throttled-*-percentiles.json`。 -4. [ ] U7:本机 Chromium 测 `/ready` 后冷导航表单可见;如实记录相对约 10s 基线是否达 50%(≤5s p75)。 -5. [ ] 更新 FEATURE-MATRIX 专项段落;`npm test` + `npm run build`。 -6. [ ] 提交并登记 `head_sha`。 +1. [x] 探针默认 n=20;慢网/U7 脚本;U3 heavy 断言;百分位汇总。 +2. [x] `npm test`(473 pass)+ `npm run build` 绿。 +3. [x] schema 61 `:8080` 基线/慢网/U7 各 n=20;证据在 `assets/2026-09-22-initial-load-closeout/`。 +4. [x] FEATURE-MATRIX 专项更新为实测关账结论。 +5. [x] 报告与本文件收口;提交。 ## 验证与证据 | 范围 / 被测 SHA | 命令与环境 | 预期 | 实际 / 判定 | 证据 / 脱敏说明 | |---|---|---|---|---| -| metrics 单测 | `cd web && npm test`(含 initialLoadMetrics) | pass | 473 pass / 0 fail(本轮) | 终端摘录,无密钥 | -| Playwright Chromium | `npx playwright install chromium` | 可 launch | **进行中**:共享缓存锁冲突后改隔离目录;cdn 下载缓慢 | 不入 Git 的 `.playwright-browsers/` | -| schema61 登录瀑布 | `RUN_INITIAL_LOAD_BASELINE=1 INITIAL_LOAD_SAMPLES=20 …` | n=20、重模块空、成员项目≤1 | 待跑(浏览器未就绪) | assets 目录;账号仅环境变量名 | +| metrics + web 单测 | `cd web && npm test` | pass | 473 pass | 无密钥 | +| build | `cd web && npm run build` | pass | pass | | +| U1/U3/U7 | Edge 对 `:8080` schema 61 | n≥20 + 无 heavy + 表单有数 | PASS;慢网达预算;U7 表单 p75 75 ms | [报告](../../test-reports/2026-09-22-initial-load-closeout-test-report.md) | ## 收口与交接 -- 剩余:浏览器安装完成后补跑 U1/U3/U7 实测并关账。 -- 本地提交 / dev 集成 / 部署 / 远端:分别待记。 +- 剩余:串行合入 dev(本批不占槽)。 +- 本地提交:见 `head_sha`(提交后回填);集成 pending;未部署变更(只读探针);远端 not_requested。 +- 治理例外:未走 `agentctl with` 租约(macOS `/proc`);沙箱改用 Edge。 diff --git a/.doc/test-reports/2026-09-22-initial-load-closeout-test-report.md b/.doc/test-reports/2026-09-22-initial-load-closeout-test-report.md new file mode 100644 index 00000000..c49c5945 --- /dev/null +++ b/.doc/test-reports/2026-09-22-initial-load-closeout-test-report.md @@ -0,0 +1,80 @@ +# 首次加载性能 U1/U3/U7 收尾测试报告 + +## 一、 测试背景 (Background) + +[方案](../remediation/2026-09-17-initial-load-performance-plan.md) 要求 U1 慢网样本 ≥20 并给出 p50/p75/p95;U3 补浏览器资源瀑布确认首屏无 katex/mermaid/docx;U7 补登录表单可见测量并如实记录是否达「较历史约十几秒基线下降 50%」。本轮在 macOS 上对已部署 dev(schema 61)复测,不放宽预算。 + +## 二、 测试目标 (Test Objectives) + +- 登录态瀑布 n=20:成员扇出、会话列表、重模块路径、百分位。 +- 慢网双档(10 Mbps / 2 Mbps)+ CPU 4x,各 n=20,对照拟定表单 p75 预算 1.5 s / 3 s。 +- U7:`/ready` 已绿后冷导航到登录表单可见 n=20;与约 10 s 历史诊断对比是否 ≤5 s。 +- 不发送聊天;证据去查询串;不写入令牌/正文。 + +## 三、 测试方案与环境 (Test Plan & Environment) + +- OS:macOS Darwin arm64;浏览器:本机 Microsoft Edge(`PLAYWRIGHT_CHANNEL=msedge`)。Playwright 自带 Chromium 因沙箱无法拉取 `cdn.playwright.dev`,改用已装 Edge,语义仍为 Chromium 内核无头自动化。 +- 被测:`http://127.0.0.1:8080`,`/api/v1/health` → `schema_version: 61`,入口包 `assets/index-CgkGfOP7.js`。 +- 源码 worktree:`feature/loading-perf-closeout-2026-09-22`(基线 `364ed7f1`)。 +- 用例:`web/e2e/initial-load-performance.spec.ts`;辅助:`web/src/lib/initialLoadMetrics.ts`。 +- 账号:dev 容器 `ADMIN_USERNAME`/`ADMIN_PASSWORD`(报告不写值)。 +- 证据目录:[assets/2026-09-22-initial-load-closeout/](assets/2026-09-22-initial-load-closeout/)。 + +## 四、 预期结果 (Expected Results) + +- 每样本 `distinctMemberProjects ≤ 1`、`sessionListGetCount = 1`(U4 行为仍在)。 +- 匿名与登录后首可操作路径 `heavyHits = []`(无 katex/mermaid/docx)。 +- 慢网表单可见 p75 ≤ 1500 ms(10 Mbps)/ ≤ 3000 ms(2 Mbps);失败时不得放宽阈值关账。 +- U7 表单 p75 相对约 10 s 基线的 50% 目标为 ≤ 5000 ms;达不到则写未达标。 + +## 五、 实际测试结果与判定 (Actual Results & Evaluation) + +### 5.1 U1/U3 登录态瀑布(无节流) + +- **输入**:`RUN_INITIAL_LOAD_BASELINE=1 INITIAL_LOAD_SAMPLES=20 EXPECT_INIT_MEMBER_PROJECTS=1`。 +- **输出**:20/20 PASS。成员项目恒为 1、会话列表 GET 恒为 1;全程 heavy 空。匿名 JS 传输 180,393 B(单入口 js)。百分位:表单可见 p50/p75/p95 = 63/64/88 ms;工作台就绪 132/146/161 ms。 +- **判定**:PASS(探针与瀑布)。本机无带宽限制,不单独作为预算验收。 + +### 5.2 U1 慢网 + CPU 4x + +- **输入**:`INITIAL_LOAD_THROTTLE=1`,CDP 限速 + CPU 4,阻断 Google 字体,各档 n=20。 +- **输出**: + +| 档位 | 表单可见 p50/p75/p95 (ms) | 预算 p75 | 工作台就绪 p75 (ms) | 达预算 | +|---|---|---|---|---| +| 10mbps-cpu4 | 590 / 599 / 631 | 1500 | 656 | 是 | +| 2mbps-cpu4 | 1342 / 1346 / 1362 | 3000 | 1240 | 是 | + +- **判定**:PASS。未设置 `INITIAL_LOAD_ENFORCE_BUDGETS=1` 硬断言,但实测均低于拟定预算,故未放宽阈值。 + +### 5.3 U3 瀑布重模块 + +- 基线与慢网样本的 `anonymousHeavy` / `loggedInHeavy` 均为 `[]`。首按钮/输入区可用时未加载 katex/mermaid/docx。 +- **判定**:PASS。 + +### 5.4 U7 登录表单可见(补 2026-09-19 libatk 缺口) + +- **输入**:`INITIAL_LOAD_U7_FORM=1`,n=20,app 已 `/ready`,不做 postgres/app 重启。 +- **输出**:表单可见 p50/p75/p95 = 70/75/95 ms;`meetsFiftyPercentVsApproxBaseline=true`(相对约 10 s → 5 s 目标)。 +- **判定**:PASS(本口径)。**范围说明**:测的是就绪后冷导航表单可见,不是宿主机整机重启首访;整机重启→`/ready` 仍以 [U7 重启报告](./2026-09-19-initial-load-u7-restart-test-report.md)(1.0–1.2 s)为准。不得把本项外推为「开机到可登录下降 50%」的整机结论。 + +## 六、 自动化测试套件汇总 (Test Suite Execution) + +```text +cd web && npm test +# pass 473 / fail 0(含 initialLoadMetrics 百分位与 heavy 断言) + +cd web && npm run build +# tsc + vite build + precompress 成功 + +PLAYWRIGHT_CHANNEL=msedge RUN_INITIAL_LOAD_BASELINE=1 … +# logged-in workbench:1 passed +# throttled login:1 passed(~2.0m) +# U7 browser form:1 passed +``` + +## 七、 测试结论与后续优化建议 (Conclusion & Next Steps) + +U1 慢网 n=20 百分位与预算对照已齐;U3 浏览器瀑布已确认首屏无延迟重模块;U7 表单可见缺口在 macOS Edge 上已补测并达到相对约 10 s 基线的 50% 目标(仅限 `/ready` 后冷导航口径)。FEATURE-MATRIX 首次加载专项可按本报告更新为关账结论。剩余非本轮:test/main 探针、整机冷启动矩阵、强制 `INITIAL_LOAD_ENFORCE_BUDGETS=1` 进 CI(需稳定 runner)。 + +证据 JSON:`login-waterfall-schema61*.json`、`throttled-schema61*.json`、`u7-form-visibility*.json`。 diff --git a/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61-percentiles.json b/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61-percentiles.json index 281a4a18..62aab903 100644 --- a/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61-percentiles.json +++ b/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61-percentiles.json @@ -2,18 +2,18 @@ "samples": 1, "anonymousVisibleMs": { "n": 1, - "p50": 197, - "p75": 197, - "p95": 197, - "min": 197, - "max": 197 + "p50": 91, + "p75": 91, + "p95": 91, + "min": 91, + "max": 91 }, "workbenchReadyMs": { "n": 1, - "p50": 840, - "p75": 840, - "p95": 840, - "min": 840, - "max": 840 + "p50": 225, + "p75": 225, + "p95": 225, + "min": 225, + "max": 225 } } \ No newline at end of file diff --git a/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61.json b/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61.json index 2d57c525..29f2499f 100644 --- a/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61.json +++ b/.doc/test-reports/assets/2026-09-22-initial-load-closeout/smoke-schema61.json @@ -1,20 +1,20 @@ [ { "sample": 1, - "anonymousVisibleMs": 197, - "workbenchReadyMs": 840, + "anonymousVisibleMs": 91, + "workbenchReadyMs": 225, "anonymous": { "navigation": [ { - "ttfb": 11.299999952316284, - "dcl": 70.20000004768372, - "load": 71 + "ttfb": 2.9000000953674316, + "dcl": 39.10000014305115, + "load": 39.10000014305115 } ], "paint": [ { "name": "first-paint", - "ms": 48 + "ms": 28 } ], "summary": { @@ -30,19 +30,19 @@ "loggedIn": { "navigation": [ { - "ttfb": 11.299999952316284, - "dcl": 70.20000004768372, - "load": 71 + "ttfb": 2.9000000953674316, + "dcl": 39.10000014305115, + "load": 39.10000014305115 } ], "paint": [ { "name": "first-paint", - "ms": 48 + "ms": 28 }, { "name": "first-contentful-paint", - "ms": 852 + "ms": 96 } ], "summary": { diff --git a/web/package.json b/web/package.json index 5f136cd3..1baf3261 100644 --- a/web/package.json +++ b/web/package.json @@ -19,7 +19,8 @@ "test:e2e:list": "playwright test --list", "test:e2e:initial-load": "RUN_INITIAL_LOAD_BASELINE=1 playwright test e2e/initial-load-performance.spec.ts --project=chromium", "test:e2e:initial-load:throttle": "RUN_INITIAL_LOAD_BASELINE=1 INITIAL_LOAD_THROTTLE=1 playwright test e2e/initial-load-performance.spec.ts --project=chromium -g throttled", - "test:e2e:initial-load:u7-form": "RUN_INITIAL_LOAD_BASELINE=1 INITIAL_LOAD_U7_FORM=1 playwright test e2e/initial-load-performance.spec.ts --project=chromium -g 'U7 browser'" + "test:e2e:initial-load:u7-form": "RUN_INITIAL_LOAD_BASELINE=1 INITIAL_LOAD_U7_FORM=1 playwright test e2e/initial-load-performance.spec.ts --project=chromium -g 'U7 browser'", + "test:e2e:initial-load:msedge": "PLAYWRIGHT_CHANNEL=msedge npm run test:e2e:initial-load" }, "dependencies": { "@tanstack/react-virtual": "^3.14.11",