用途:当需要基准测试 Pyrefly 性能、运行 pyrefly bench、比较冷启动与错误传播延迟,或更新 PyTorch 基准固定版本时使用本技能。所有基准位于 pyrefly/pyrefly/benches/,使用 Criterion。
主要能力:微基准为确定性的单线程类型检查器内部测试,快速且成本低。PyTorch 基准包含三个真实场景:cold_start(全新服务器,代理首索引时间)、error_propagation(热服务器,代理增量编辑传播延迟)、full_check(全新 State,代理全项目批处理吞吐),均在固定的多 GB PyTorch 检出上运行。TSP 基准为快速回归覆盖,无需固定检出。
必要用法:必须使用优化构建,否则结果无意义。Buck 使用 @fbcode//mode/opt(最终数字用 @fbcode//mode/opt-clang-thinlto);Cargo bench 已用优化 profile。禁止并行运行两个基准。示例:buck2 run @fbcode//mode/opt fbcode//pyrefly/pyrefly:micro_bench -- --bench;cargo bench --bench micro。PyTorch 全部基准:buck2 run @fbcode//mode/opt fbcode//pyrefly/pyrefly:pytorch_bench -- --bench 或 cargo bench --bench pytorch,用 Criterion 名称过滤器选单个。常用标志:--list、--quick、--noplot(无头环境必需)。
限制:PyTorch 基准较慢,单次迭代 cold_start 约 3-5 秒、error_propagation 约 2-3 秒、full_check 约 1-1.5 秒,每个基准预算约 2-4 分钟;默认不应在 CI Sandcastle 运行。调试构建慢 3-10 倍。更新固定版本需 github 访问。输出写入 target/criterion/,不应提交。