Просмотр исходного кода

test(perf): allow the joined-text share in the fold scaling bound

A records-proportional fold still joins 20x more text in the large window,
which measured about 2.5x the small fold; the per-delta replay measured
about 11x. A 5x bound separates the two on a noisy runner.
Tianyi Cui 1 месяц назад
Родитель
Сommit
3285850ee5

+ 2 - 2
.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.i18n.yaml

@@ -2,5 +2,5 @@
 # side as of the last confirmed-consistent state. Both languages carry equal authority;
 # after editing either side, bring the other along and re-record with:
 #   pnpm run verify-translation-pairing --write .agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md
-2026-09-04-session-open-performance-gate.md: 65f997a2a0e6ff5b69b2513126b85b752db2d9fb
-2026-09-04-session-open-performance-gate.zh.md: 565ec3ed2a37c88fdf7fe8abb1d02baca0d5d499
+2026-09-04-session-open-performance-gate.md: ea6a9434dd0f16d9e92a2ff14be4cd9699667007
+2026-09-04-session-open-performance-gate.zh.md: b1db1ca730a73fe503dd476401fcd44ab9a9cda4

+ 1 - 1
.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.md

@@ -19,7 +19,7 @@ The first two gates cover the two regressed paths:
 | Benchmark | Workload | Gates |
 |---|---|---|
 | `packages/session/session-persistence-jsonl/tests/open-generation.bench.ts` | 200 turns × (500 text + 125 reasoning deltas) = 127,400 released-v0 events, about 2.8 MB, encoded through the frozen v0 codec with packed rows | migrating first `open()` ≤ 3,000 ms under a 128 MB heap; fresh-process open of the published current generation ≤ 500 ms; minimum of three attempts |
-| `packages/client/ui-chat/tests/conversation-fold.bench.client.ts` | 200 replies whose compact streams hold 2,000 text + 500 reasoning deltas each (500,000 deltas in 1,600 records), folded through every Chat Definition by the real `ConversationNodeAssembler` | large fold ≤ 150 ms; large fold ≤ 3× the fold of the same window with 100 deltas per reply |
+| `packages/client/ui-chat/tests/conversation-fold.bench.client.ts` | 200 replies whose compact streams hold 2,000 text + 500 reasoning deltas each (500,000 deltas in 1,600 records), folded through every Chat Definition by the real `ConversationNodeAssembler` | large fold ≤ 150 ms; large fold ≤ 5× the fold of the same window with 100 deltas per reply |
 
 Measured on the reference machine at the commit that introduced the gate, the migration benchmark exhausted the 128 MB heap and the fold benchmark scaled 11× between the small and large windows, so both gates fail on the regressed code and pass once the paths do O(records) work.
 

+ 1 - 1
.agents/notes/implemented/testing/2026-09-04-session-open-performance-gate.zh.md

@@ -19,7 +19,7 @@ Linux pull request 运行必需的 `node 24 / benchmarks` job,执行 `pnpm run
 | 基准 | 负载 | Gate |
 |---|---|---|
 | `packages/session/session-persistence-jsonl/tests/open-generation.bench.ts` | 200 轮 ×(500 text + 125 reasoning delta)= 127,400 个 released-v0 事件,约 2.8 MB,经冻结 v0 codec 以 packed row 编码 | 迁移的首次 `open()` 在 128 MB 堆下 ≤ 3,000 ms;新进程打开已发布 current generation ≤ 500 ms;三次尝试取最小值 |
-| `packages/client/ui-chat/tests/conversation-fold.bench.client.ts` | 200 个回复,每个紧凑 stream 含 2,000 text + 500 reasoning delta(1,600 条记录中 500,000 个 delta),由真实 `ConversationNodeAssembler` 经全部 Chat Definition fold | 大窗口 fold ≤ 150 ms;大窗口 fold ≤ 每回复 100 delta 的同一窗口的 3 倍 |
+| `packages/client/ui-chat/tests/conversation-fold.bench.client.ts` | 200 个回复,每个紧凑 stream 含 2,000 text + 500 reasoning delta(1,600 条记录中 500,000 个 delta),由真实 `ConversationNodeAssembler` 经全部 Chat Definition fold | 大窗口 fold ≤ 150 ms;大窗口 fold ≤ 每回复 100 delta 的同一窗口的 5 倍 |
 
 在引入该 gate 的提交上于参考机器测得:迁移基准耗尽 128 MB 堆,fold 基准在小窗口与大窗口之间缩放 11 倍,因此两个 gate 都在回归代码上失败,并在两条路径改为 O(records) 工作后通过。
 

+ 4 - 3
packages/client/ui-chat/tests/conversation-fold.bench.client.ts

@@ -54,10 +54,11 @@ const LARGE_FOLD_BUDGET_MS = 150
 /**
  * Maximum ratio between folding the large and the small window. Both windows
  * hold the same number of events and compact records, so a fold that scales
- * with records stays near 1; a fold that replays every delta grows with the
- * 20× delta count.
+ * with records plus the joined text stays a few times the small fold
+ * (about 2.5× measured); a fold that replays every delta grows with the 20×
+ * delta count (about 11× measured).
  */
-const MAX_DELTA_SCALING = 3
+const MAX_DELTA_SCALING = 5
 
 /** Attempts per workload; the gate compares minima so scheduler noise only adds. */
 const ATTEMPTS = 3