Repository navigation
perf(parser): fast-bail the function-definition probe for plain commands - #1647
Conversation
parse_function_command_with_diagnostic is probed at every command start, and almost every probe is an ordinary simple command that walks the lt/bang name reassemblies and clones the candidate name token only to return None. Admit only the shapes that can answer Some -- a name token directly followed by () or (, a <(...)' name (RedirectIn <), or a !! name (Keyword !) -- and bail before the walk otherwise. The `function` keyword form keeps the full path. Zero behavior change: every entry the admission rejects provably fell through to None before. Measured (thread-CPU profile): the probe cost ~0.75us per command start on simple corpora (2.2ms of parse per 3000 commands).
eabd30e to
0f63a3e
Compare
|
Integration verification on current master
CPU battery (rusage children CPU,
Caliber statement (unchanged from the PR body): these are contention-environment indication values (machine load ~6.5–14 with parallel builds running), not formal benchmark results. Per-case ratios swing widely between samples and center on ~1.0 — this setup's noise floor is above the marginal effect the cluster estimated (~4% of total path), so the battery resolves no directional signal: no claimable speedup and no re-run-surviving regression signal either. The hard evidence stays the desk equivalence audit (admission set == exactly the shapes the original probe could return Full record: |
perf(parser): fast-bail the function-definition probe for plain commands
单文件改动
src/parser/function_command.rs(+22 行),基线 masterd15a02df(cherry-pick 自 perf-parse 簇交付 commit3849319,基线e8b65463,零冲突)。剖面结论摘要
shell -n {script}口径;插桩剖面(线程 CPU 时钟计数器,争用免疫)显示:脚本路径的成本由 feed / parse / exec 三段每行、每命令固定地板大致均分,parse 段内函数定义机器占 funcs1500 parse 的 64%。parse_function_command_with_diagnostic在每个命令起始处被探测,普通简单命令占绝大多数,却要先走 lt/bang 名字重组走查 + 候选名 Token 两次String克隆,才轮到括号检查并返回 None——剖面定版约 0.73µs/命令起始恒定付出(simple3000 语料 parse 段 2.2ms/3000 条)。function关键字形时,后续 token 是()/(、起始 token 是 RedirectIn<、或 Keyword!三者皆无则直接返回 None,跳过重组与克隆;function关键字形保持全路径。等价性 desk 审计结论(簇侧已完成)
准入放行集恰好等于原代码可返回 Some 的形状全集,逐 return 点核对:
function关键字形不走准入);<或!起始;()/(,且名字有效性检查之后还有一道括号检查兜底。被拒形状在原路径上必然落到 None,零行为变化。
验证状态(如实分列)
已过:
待跑(构建门 load<7 且 MemAvailable>1.5G,集成线正在门控执行,结果回填本 PR):
--skip login_posix_env(期望与 master 基线同集:771 过 / 1 失败 ownership_unary_operators_check_existing_file / 1 ignored);性能数字口径声明
d15a02df)vs 集成树二进制,parse 类五条shell -n,争用环境下采集——只作方向性指示,不得把争用环境数字写成结论。