Skip to content

perf(control-plane): add 2-lane TS test runner and cut coordination test CPU - #9537

Open
loopx-agent wants to merge 1 commit into
mainfrom
codex/speedup-ts-control-plane-tests-20261128
Open

loopx-agent wants to merge 1 commit into
mainfrom
codex/speedup-ts-control-plane-tests-20261128

Conversation

@loopx-agent

Copy link
Copy Markdown
Collaborator

Summary

Speeds up npm run test:control-plane (~317.23s baseline -> 190.06s on final rebased HEAD, cutting user CPU from 546.50s to 353.91s) with zero weakened assertions, zero weakened File fsync or SQLite PRAGMA synchronous = FULL durability guarantees, and full coverage compatibility.

Changes

  1. Adaptive 2-lane TS test runner (scripts/run_control_plane_ts_tests.mjs, scripts/run_control_plane_ts_tests.d.mts, package.json, tsconfig.control-plane.json):
    • Resolves total worker concurrency via LOOPX_TS_TEST_CONCURRENCY (positive integer override) or Math.min(8, Math.max(4, Math.floor(availableParallelism / 2))).
    • Creates a private run-scoped NODE_COMPILE_CACHE directory (mode 0o700, cleaned up on exit and SIGINT/SIGTERM/SIGHUP) unless NODE_COMPILE_CACHE, NODE_DISABLE_COMPILE_CACHE=1, or NODE_V8_COVERAGE is set.
    • Uses 2-lane heavy-first scheduling for the default full suite when totalConcurrency >= 6, no explicit file/flag args are supplied, and NODE_V8_COVERAGE is unset:
      • Heavy lane (--test-concurrency=2): runs only the 2 fsync-intensive conformance suites (tests/control_plane_ts/sqlite_authority_store.test.ts and tests/control_plane_ts/authority_store.test.ts) concurrently from t=0, preventing them from serializing behind each other or saturating APFS fsync.
      • Standard lane (--test-concurrency=(totalConcurrency - 2)): runs all remaining tests/control_plane_ts/*.test.ts files concurrently from t=0.
    • Falls back cleanly to single-process node --test when totalConcurrency < 6, explicit files/flags are passed, or NODE_V8_COVERAGE is active (preserving npm run test:control-plane:coverage with c8).
  2. Runner unit & subprocess tests (tests/control_plane_ts/run_control_plane_ts_tests.test.ts) & e2e alignment (tests/control_plane/test_shared_goal_authority_e2e.py):
    • Covers [4, 8] clamping, LOOPX_TS_TEST_CONCURRENCY overrides and invalid fallbacks, 2-lane partitioning and single-lane fallbacks, 0o700 NODE_COMPILE_CACHE lifecycle/opt-outs, forwarded args/exit codes, heavy-lane failure propagation, and SIGTERM cleanup.
    • Updates test_native_ladder_suites_remain_in_the_regular_typescript_test_job to inspect buildNodeTestArgs([]).
  3. Lossless coordination & test-setup CPU optimizations:
    • loopx/control_plane/coordination/authority_store_codec.ts: code-unit < 0xD800 fast path in authorityUnicodeCompare, sorted-key short-circuit in sortCanonicalKeys, and ordinary hidden-class {} cloning (preserving inherited-setter safety via Object.defineProperty and sparse-array hole semantics).
    • loopx/control_plane/coordination/coordination_state_contract.ts: WeakMap-cached allowed-field sets for frozen RecordContract descriptors.
    • loopx/control_plane/coordination/coordination_projection.ts: removes duplicate full-graph validateCoordinationTodoReadModel during commit preparation and validates only mutated Todos incrementally during projection reduction.
    • loopx/control_plane/coordination/nokv_authority_store.ts: reuses module-level FATAL_UTF8_DECODER.
    • tests/control_plane_ts/production_scale_coordination_fixture.ts: memoizes immutable base fixtures with structuredClone.
    • tests/control_plane_ts/authority_archive_audit.test.ts: runs archive audit consumer recovery tests concurrently (concurrency: 4) via async spawn.
    • tests/fixtures/nokv_fake_sdk/nokv/__init__.py & tests/control_plane_ts/nokv_jsonl_transport.test.ts: keys fake NoKV blob storage by (workbench, path) and pools 6 reusable nokv_jsonl_helper.py processes across conformance cases with isolated tenants.

Benchmark Results (18-CPU / 6P+12E Apple Silicon Mac)

Configuration Wall Clock User / Sys CPU Total / Pass / Skip / Fail
origin/main (2302e42d9cad, --test-concurrency=4, no compile cache) 317.23s 546.50s / 107.80s 6,890 / 6,886 / 4 / 0
Pre-rebase Option 1A Run 1 (2302e42d9cad base, 2-lane 2+6) 210.28s 357.57s / 131.58s 6,898 / 6,894 / 4 / 0
Pre-rebase Option 1A Run 2 (2302e42d9cad base, 2-lane 2+6) 215.36s 365.75s / 133.14s 6,898 / 6,894 / 4 / 0
Final Rebased HEAD (3930e76db0b, origin/main 509360fb0d3 base, 2-lane 2+6) 190.06s (1.67x) 353.91s / 119.99s 6,899 / 6,895 / 4 / 0

Verification

  • npm run test:control-plane on 3930e76db0b: 0 failures (190.06s; standard lane 366 files 6,084 pass / 4 skipped in 189.63s with sqlite_capacity in 50.81s; heavy lane authority_store.test.ts 398 pass in 170.40s and sqlite_authority_store.test.ts 413 pass in 188.24s).
  • npm run typecheck:control-plane: passed (0 errors).
  • npm run test:control-plane:coverage -- tests/control_plane_ts/run_control_plane_ts_tests.test.ts tests/control_plane_ts/authority_store_codec.test.ts tests/control_plane_ts/coordination_projection.test.ts tests/control_plane_ts/coordination_state_contract.test.ts: passed (c8 compatibility confirmed).
  • uv run --extra test pytest -q -n 4 tests/control_plane/test_shared_goal_authority_e2e.py tests/test_nokv_jsonl_helper.py tests/canary/test_runner_compile_cache.py tests/architecture/test_nokv_qualified_pin_single_owner.py tests/control_plane/test_coordination_authority_core.py tests/control_plane/test_local_coordination_authority.py tests/control_plane/test_authority_archive.py tests/control_plane/test_sqlite_authority_cli.py: 360 passed, 3 skipped in 33.93s.
  • uv run --extra test ruff check tests/control_plane/test_shared_goal_authority_e2e.py tests/fixtures/nokv_fake_sdk/nokv/__init__.py: passed.
  • uv run --extra test mypy --no-incremental --follow-imports=silent tests/fixtures/nokv_fake_sdk/nokv/__init__.py: 0 issues.
  • uv run --extra test python scripts/check_rfc_bilingual.py --base origin/main --head HEAD: passed.
  • uv run --extra test loopx check --scan-path ... (all 14 changed/new files): errors=0, warnings=0, public boundary scan clean: 14 files.
  • uv run --extra test loopx canary premerge --from-git-diff --git-diff-base origin/main: passed (selected=17, failures=0, merge_gate_passed=true).

…est CPU

Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>

@loopx-agent loopx-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh

Approval conclusion (author-owned PR; GitHub blocks formal self-approval)

通过。 本范围无阻塞发现。默认运行、规范字节和存储恢复得到独立验证。

动机 / Motivation

维护者运行控制面测试,已有 File/SQLite 权威存储继续读写历史 Todo 和回执。TS 套件由一个 Node 运行器发起,Reducer 对已验证投影重复做整份规范化和后置读模型校验。 独立合成旧字段契约并经新旧 Reducer 对照,普通更新保留旧字段列表,使用新字段时升级。含 Unicode 和 proto 自有属性的规范 JSON 与两个摘要逐字节一致。 未知字段仍拒绝。File/SQLite 实际读写套件覆盖 CAS、租约护栏和提交过程退出。独立 SIGTERM 回归观测到候选按信号退出,所属 Node 测试 worker 已退出。 本机真实 File、SQLite、Node 和有限 Python 集成。NoKV 仅用测试 SDK 与 JSONL 回归,外部服务和跨平台性能未复验。

改动思路 / Approach

将默认测试切分为互斥的两个进程组,将安全的重复规范化局部移除,仍由已有 codec 和存储持久化边界生成摘要。 继续由现有 provider 提交和读模型 schema 负责兼容性,优化解析和密集测试的执行分配。 本机真实 File、SQLite、Node 和有限 Python 集成。NoKV 仅用测试 SDK 与 JSONL 回归,外部服务和跨平台性能未复验。

具体改动 / Changes

精确提交 3930e76db0b9937424b633d3397cbc2fc84fa053。GitHub 目标基线 509360fb0d3e9e6e578ddf5c12db587886016b23,行为对照 509360fb0d3e9e6e578ddf5c12db587886016b23。14 个文件,增加 1,604 行、删除 275 行。 测试与质量契约 评审条件 authority-history、test-targets。

关键代码讲解

  • buildControlPlaneRunPlan。默认把两个重存储套件各分配一次,参数和覆盖率路径保持单 runner。 源码
  • runControlPlaneTests。在工作运行期间管理 Node 子进程和私有编译缓存,转发退出信号。 源码
  • reduceCoordinationProjection。验证旧模型和新写记录,保留旧字段清单直到新字段实际写入。 源码
  • authorityUnicodeCompare。对无代理码元的字符串使用快路径,其他输入继续按 Unicode 码点比较。 源码

对主干的风险 / Risks

独立合成旧字段契约并经新旧 Reducer 对照,普通更新保留旧字段列表,使用新字段时升级。含 Unicode 和 proto 自有属性的规范 JSON 与两个摘要逐字节一致。 原生 npm 默认两组共 6,895 项 TS 测试通过、4 项因本机环境等条件跳过。所选 Python 集成 352 项通过、3 项按本地环境跳过。TS 类型检查通过。c8 显式目标中的两项旧 manifest 测试通过并生成 LCOV。Git diff --check 通过。 未知字段仍拒绝。File/SQLite 实际读写套件覆盖 CAS、租约护栏和提交过程退出。独立 SIGTERM 回归观测到候选按信号退出,所属 Node 测试 worker 已退出。

语义与 CI 对齐

独立运行与其他任务并行,未复核作者的提速倍率。NoKV 使用合成 SDK,未连接外部服务。安装和 SQLite 测试跳过项保留在本机验证范围内。

我的整体评价 / Verdict

APPROVE。 默认测试入口与权威投影的兼容性回归通过。 保持现有发布版字段验证、排序、摘要和持久化责任。 独立运行与其他任务并行,未复核作者的提速倍率。NoKV 使用合成 SDK,未连接外部服务。安装和 SQLite 测试跳过项保留在本机验证范围内。

English verdict: APPROVE at 3930e76. The normal runner and canonical state, legacy schemas, and storage recovery passed independent validation.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant