Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 2.73 KB

File metadata and controls

70 lines (50 loc) · 2.73 KB

tswn-core 项目性能优化准则

核心准则

所有性能优化都必须建立在行为不回退的前提下。tswn_core 0.5.0 已删除旧执行器, 正确性判断统一使用主 Runtime 的冻结 corpus,不再通过生产 CLI 或辅助 binary 切换执行器对账。

Release profile 选择

  • --release:正式 benchmark 和发布口径,使用 fat LTO、codegen-units = 1 与默认 mimalloc。
  • --profile release-fast:日常快速验证口径,使用 thin LTO 和更多 codegen units;结果不能写入正式性能表。
  • no_debug:正式性能与发布构建必须启用,避免诊断逻辑进入热路径。

行为验证

日常修改至少运行相关测试;准备发布时必须运行完整门禁:

cargo test --workspace
python scripts/check_runtime_release.py --corpus

第二条命令同时检查旧源码路径与禁用 API 未回流,并执行 87 个 JS exact trace 和 37 个冻结压力 golden。C、Python、WASM 和 OpenBox 等包装层修改还应运行:

cargo test --workspace --all-targets --no-run
python scripts/verify_py_cli_api.py --release

0.5.0 之前使用的 tswn_case_minertrack_perf_casestrack_score_perf 和 legacy/runtime parity 工具已经随旧执行器删除,不得继续把历史文档中的命令作为当前门禁。

Benchmark 方法

当前仓库可直接复测的 core 单线程胜率口径:

cargo run -p tswn_core --release --features no_debug --bin tswn-cli -- `
  bench win-rate -f input.txt -n 13000 -s --perf

OpenBox CQP/CQD 可使用 openbox_mem_probe

cargo build -p tswn_openbox --release --bin openbox_mem_probe
target\release\openbox_mem_probe.exe `
  --players docs\perf\cqp\sqp6000_first20.txt `
  --targets crates\tswn_openbox\assets\targets\target1.txt `
  --limit all --target-limit all --count 1000 --threads 0

0.5.0 的 fixed30、score、win-rate 与 OpenBox 完整发版数据、环境和 A/B 判定见 docs/perf/runtime_0.5.0_749fcd1_release_benchmark.md。fixed30 与 score 当时使用的临时 外部 harness 不属于发布源码,因此不能用已删除的旧 binary 复跑。

正式结果必须记录被测 commit、rustc/Cargo 版本、feature、输入哈希、线程口径和原始轮次; 机器状态变化时,以同一会话中交替顺序的旧版/新版 A/B 为准。

采样

Windows 上可用 samply 直接采样公开 CLI:

cargo build -p tswn_core --release --features no_debug --bin tswn-cli
samply record --save-only --unstable-presymbolicate `
  --windows-symbol-server https://msdl.microsoft.com/download/symbols `
  -o target\samply_tswn_cli.json.gz -- `
  target\release\tswn-cli.exe bench win-rate -f input.txt -n 13000 -s --perf