You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Leftover of #607/#661: per-execute_command fixed cost is shape-independent (~2.8us; if = 3 traversals vs 2 for ;-sequence explains the ratio vs GNU's ~0.3us frame). Plus set_current_command render scaling with node size and the if…fi >/dev/null redirect path (+52us vs GNU +5.4us). All measured during #661 (see PR #673). This is cross-cutting command-dispatch machinery, not one construct — needs its own attribution pass before any slice. Do not start from a diff count.
RUBASH_EXEC_PROFILE split per : (flat-80k): dispatch 2.34µs · jobs 1.07 · chain 1.34 · linecmd 0.64 · scans 0.15. #981's literal fast render shows — linecmd is already small.
One bounded slice landed → PR #989: take_pending_signals polled the signal-hint kernel event (WaitForSingleObject(,0), a real syscall 0.5-0.7µs) at every command boundary; GNU's catch_flag is a memory flag (trap.c:336). Auto-reset latches the pulse, so sampling every 8th boundary loses no delivery — jobs bucket 298→99ms/420k cmds, : marginal 3.43→3.2µs, loop-5colon −11.5%. Delivery batteries green (issue357 6/6 incl. busy-loop TERM trap, issue382 6/6, 343_345 9/9, 524 12/12, cli kill|signal|trap 21/21; issue526's two -1 asserts fail identically on baseline — Windows has no signaled ExitStatus).
Remaining floor (post-PR ~3.2µs vs GNU ~0.3µs) is structural, no clean P3 slice: dispatch's ~2.3µs is ~20 sequential semantic checks (no single item); chain ~1.3µs is the alias/compound matcher family already gated by alias_chain_applicable; double set_current_line (ast_exec + execute_command) ~0.3µs needs a stamped-by-caller contract; the if…fi >/dev/null +72µs needs the leaf-splice redirect model replaced with entry-bound fd binding. Suggest keeping the issue open as the ledger for those; each wants its own attribution pass per the frozen plan.
Status (master a42ec29): #989 landed the audit + the largest bounded slice (signal-hint event sampled every 8th boundary; loop-base -15.8%, marginal : 3.43->~3.2us/cmd). Floor is NOT closed — remaining ledger per #989: if-traversal ~3.9us/slot, compound-redirect model (+72us vs plain if), top-level parse ~10us/cmd, dispatch ~20 sequential checks ~2.3us. Keeping open as the tracking issue for those.
Floor re-measurement on master a3343c0 (measurement only — frozen item)
Method: same as the audit pass on this issue — loop-body marginal cost, flat-file
slope, and the RUBASH_EXEC_PROFILE split. Caveat: this host's rubash binary is a debug (unoptimized) build on a shared 2-core VM, so absolute µs are ~30–100× the
release figures and cannot confirm/deny the release ~2.8–3.2µs floor; primary metric
below is rusage user time. What transfers across build profiles is the shape:
relative costs and the profile composition.
shape
rubash debug (user/unit)
GNU 5.3.20 (user/unit)
flat file, 20000× : (all-in slope)
65.7 µs/cmd
1.6 µs/cmd
marginal 2nd : in a loop body
≈103 µs/cmd
—
true in a loop body
71.9 µs/cmd
2.8 µs/cmd
x=1 in a loop body
≈32 µs/cmd
—
if :; then :; fi in a loop
169 µs/stmt ≈ 3 slots × ~56 µs
3.6 µs/stmt
: >/dev/null in a loop
119 µs/cmd
5.1 µs/cmd
if…fi >/dev/null in a loop
520 µs/stmt (+351 µs vs plain if)
5.9 µs/stmt
f(){ :; }; f
195 µs/call
5.6 µs/call
Exec-profile split, flat 20000× : (exec side, per command; buckets are nested
timers and overlap): total 43.6 µs — dispatch 31.8 · jobs 22.5 · chain 13.8 ·
matcmd 13.4 · linecmd 7.3 · scans 3.1 · expand 2.2. Same families, same order as
this issue's ledger: dispatch dominates, linecmd is already small (#981's fast
render shows), the compound-redirect splice is still the big adder on if…fi >/dev/null.
Methodological trap found while measuring: an arithmetic-for whose body is a
single : runs at ≈1 µs/iteration (user) even in debug — that is a trivial-body
internal fast path, not an execute_command floor sample; do not quote it as one.
Relation to the recent #914 fix batch (p2): that batch removed shape-dependent
costs (per-command re-parsing that grows with array size). None of the buckets
above shrank or vanished as a side effect of that batch: the shape-independent
floor and p2's shape-dependent tax are separate ledgers, and the floor is
unaffected by it.
Final attribution — Android/aarch64 release (master c31b357). Closing as architectural.
Method: brace-expansion loop bodies (for i in {1..20000}; do …; done), N=20000, min of 5 runs, getrusage(RUSAGE_CHILDREN).ru_utime, release build, Termux aarch64 tablet.
Methodology trap worth recording: for ((i=0;i<N;i++)); do :; done hits rubash's trivial-body fast path (0.75 µs/iter at N=100k — the body really runs, counter verified). A naive arith-for sample therefore reports "marginal 2nd : = 31.9 µs", which is an artifact of comparing a fast-pathed loop against a normal one. Brace loops give the real number; this matches the caveat already noted in the Oct 24 pass.
shape (per iteration)
rubash
GNU 5.3.20
ratio
: (loop base)
9.65 µs
2.00 µs
4.8x
2nd : in the body (marginal)
+5.8 µs
+0.9 µs
6.4x
x=1
9.77 µs
1.40 µs
7.0x
: >/dev/null
16.89 µs
3.75 µs
4.5x
if :; then :; fi
26.9 µs
3.08 µs
8.7x
if :; then :; fi >/dev/null
57.3 µs
3.71 µs
15.4x
f(){ :; }; f
24.2 µs
4.44 µs
5.4x
flat file, 100k × : (all-in)
13.8 µs/cmd
1.3 µs/cmd
10.6x
Reading:
Marginal simple-command cost is 5.8 µs on ARM release (the Windows release figure was 2.8–3.2 µs); the delta is platform/allocation, the composition is the same. if costs 3 slots: +17 µs ≈ 3 × 5.7 µs. The per-item attribution from the audit stands: dispatch, linecmd, chain matcher family, line stamp, jobs — all O(1) shares, no single hot line.
An observation for whoever profiles next: while ((i++ < N)) costs 23.7 µs/iter vs 10.4 µs for the brace loop — the arithmetic-condition path is worth its own attribution pass, but it is not this issue either.
Decision: the shape-independent floor (~5.8 µs/cmd on ARM) is compositional and architectural; there is no bounded P3 slice left to land. Closing the ledger rather than leaving it open indefinitely. Reopen only when a real workload shows per-command dispatch as its bottleneck (then the reopen comment should include that workload, not a microbenchmark).
Activity
caomengxuan666 commentedon Oct 16, 2026
Attribution (frozen here — no implementation until the correctness queue is empty):
command_execute.rs:execute_command+ast_exec.rs:execute_ast_inner; GNUexecute_cmd.c:624): floor base; slice = skip chain matchers when node kind known (risk: compound bypass).compound_exec.rs:execute_if_command; GNU:3862/:5200): structural +1 walk; slice = stored slices by reference (risk: inline-arith-for normalize).public_accessors.rs:set_current_line; GNU:629/:907): slice = stamp only on change (risk: stale LINENO).ast_exec.rs:P_JOBS,job_builtins.rs:533; GNU:643/:2983): empty-table early return landed; slice = gate trap/notify on no-child flag.parse.y): stateless empty-table slice kept; stateful cache rejected (needs generation invalidation).:3862 CMD_IGNORE_RETURN).command_text.rs:443; GNU:699fork-path only): slice = lazy render for BASH_COMMAND/verbose/xtrace readers.:827/:853): risk = new redirect field escaping the gate predicate.Landed slices already cover 5/6/8 partially; 1/2/3/4/7 await their own attribution passes. Do not start from a diff count.
caomengxuan666 commentedon Oct 17, 2026
Noting for the floor ledger (not a slice): prompt-identity probe during triage found uid_value() hardcoding root; fixed separately as #695.
caomengxuan666 commentedon Oct 17, 2026
Correction: the uid fix PR is #698, not #695.
caomengxuan666 commentedon Oct 22, 2026
Audit pass on current master (6a38de0 / rebased onto ce62721), release build, rotating-interleaved min-of-9/11, D-series Windows host. Method: loop-body marginal cost (body parsed once → exec-only) + flat-file exec−noexec slope. Raw samples:
target/perf-682/results/*.jsonin the perf/682 worktree.Floor status: ~3.4-3.5µs per
:/true(issue's ~2.8µs recorded during #661 — same ballpark; #967/#981 moved render but not the floor)::/true(loop body):flat file, exec−noexec:flat file, all-inif :;then :;fi;-seq holdsif … >/dev/nullif(issue recorded +52): splice>>into every leaf + each leaf re-opens + cmd/if_command clones — redirect architecture, not a slice: >/dev/nullf(){ :; }; fRUBASH_EXEC_PROFILEsplit per:(flat-80k): dispatch 2.34µs · jobs 1.07 · chain 1.34 · linecmd 0.64 · scans 0.15.#981's literal fast render shows — linecmd is already small.One bounded slice landed → PR #989:
take_pending_signalspolled the signal-hint kernel event (WaitForSingleObject(,0), a real syscall0.5-0.7µs) at every command boundary; GNU's3.2µs, loop-5colon −11.5%. Delivery batteries green (issue357 6/6 incl. busy-loop TERM trap, issue382 6/6, 343_345 9/9, 524 12/12, cli kill|signal|trap 21/21; issue526's twocatch_flagis a memory flag (trap.c:336). Auto-reset latches the pulse, so sampling every 8th boundary loses no delivery — jobs bucket 298→99ms/420k cmds,:marginal 3.43→-1asserts fail identically on baseline — Windows has no signaled ExitStatus).Remaining floor (post-PR ~3.2µs vs GNU ~0.3µs) is structural, no clean P3 slice: dispatch's ~2.3µs is ~20 sequential semantic checks (no single item); chain ~1.3µs is the alias/compound matcher family already gated by
alias_chain_applicable; doubleset_current_line(ast_exec + execute_command) ~0.3µs needs a stamped-by-caller contract; theif…fi >/dev/null+72µs needs the leaf-splice redirect model replaced with entry-bound fd binding. Suggest keeping the issue open as the ledger for those; each wants its own attribution pass per the frozen plan.Merge pull request #989 from unixwin/perf/682
caomengxuan666 commentedon Oct 22, 2026
Status (master a42ec29): #989 landed the audit + the largest bounded slice (signal-hint event sampled every 8th boundary; loop-base -15.8%, marginal : 3.43->~3.2us/cmd). Floor is NOT closed — remaining ledger per #989: if-traversal ~3.9us/slot, compound-redirect model (+72us vs plain if), top-level parse ~10us/cmd, dispatch ~20 sequential checks ~2.3us. Keeping open as the tracking issue for those.
caomengxuan666 commentedon Oct 24, 2026
Floor re-measurement on master a3343c0 (measurement only — frozen item)
Method: same as the audit pass on this issue — loop-body marginal cost, flat-file
slope, and the
RUBASH_EXEC_PROFILEsplit. Caveat: this host's rubash binary is adebug (unoptimized) build on a shared 2-core VM, so absolute µs are ~30–100× the
release figures and cannot confirm/deny the release ~2.8–3.2µs floor; primary metric
below is rusage user time. What transfers across build profiles is the shape:
relative costs and the profile composition.
:(all-in slope):in a loop bodytruein a loop bodyx=1in a loop bodyif :; then :; fiin a loop: >/dev/nullin a loopif…fi >/dev/nullin a loopif)f(){ :; }; fExec-profile split, flat 20000×
:(exec side, per command; buckets are nestedtimers and overlap): total 43.6 µs — dispatch 31.8 · jobs 22.5 · chain 13.8 ·
matcmd 13.4 · linecmd 7.3 · scans 3.1 · expand 2.2. Same families, same order as
this issue's ledger: dispatch dominates, linecmd is already small (#981's fast
render shows), the compound-redirect splice is still the big adder on
if…fi >/dev/null.Methodological trap found while measuring: an arithmetic-
forwhose body is asingle
:runs at ≈1 µs/iteration (user) even in debug — that is a trivial-bodyinternal fast path, not an execute_command floor sample; do not quote it as one.
Relation to the recent #914 fix batch (p2): that batch removed shape-dependent
costs (per-command re-parsing that grows with array size). None of the buckets
above shrank or vanished as a side effect of that batch: the shape-independent
floor and p2's shape-dependent tax are separate ledgers, and the floor is
unaffected by it.
Merge pull request #2160 from unixwin/perf/682-command-floor
docs(perf): F4/F5 status lines updated to the residual-round verdicts
caomengxuan666 commentedon Oct 30, 2026
Final attribution — Android/aarch64 release (master c31b357). Closing as architectural.
Method: brace-expansion loop bodies (
for i in {1..20000}; do …; done), N=20000, min of 5 runs,getrusage(RUSAGE_CHILDREN).ru_utime, release build, Termux aarch64 tablet.Methodology trap worth recording:
for ((i=0;i<N;i++)); do :; donehits rubash's trivial-body fast path (0.75 µs/iter at N=100k — the body really runs, counter verified). A naive arith-for sample therefore reports "marginal 2nd:= 31.9 µs", which is an artifact of comparing a fast-pathed loop against a normal one. Brace loops give the real number; this matches the caveat already noted in the Oct 24 pass.:(loop base):in the body (marginal)x=1: >/dev/nullif :; then :; fiif :; then :; fi >/dev/nullf(){ :; }; f:(all-in)Reading:
ifcosts 3 slots: +17 µs ≈ 3 × 5.7 µs. The per-item attribution from the audit stands: dispatch, linecmd, chain matcher family, line stamp, jobs — all O(1) shares, no single hot line.ifclone bypass), perf(expand): multi-word literal command fast path #967/perf(bash-command): whitelist fast render for literal commands #981 (render), perf(1.4.1): if/case no-redirect pointer-walk fast path (if -53%, case -47%) #624 (redirect gate), perf(executor): if-condition dispatch residual (#661) #673 (alias/condition), jobs empty-table early return.if…fi >/dev/nullis +30.4 µs over plainif, and even: >/dev/nullcosts +7.2 µs:execute_if_command_with_redirectsclones theCommandNodeand deep-clones theIfCommand, then applies redirects leaf-by-leaf. That is an architecture item, not a per-command floor slice → filed as [perf] compound redirects deep-clone + splice into every leaf: if…fi >/dev/null +30µs over plain if #2246 so it is not lost with this ledger.while ((i++ < N))costs 23.7 µs/iter vs 10.4 µs for the brace loop — the arithmetic-condition path is worth its own attribution pass, but it is not this issue either.Decision: the shape-independent floor (~5.8 µs/cmd on ARM) is compositional and architectural; there is no bounded P3 slice left to land. Closing the ledger rather than leaving it open indefinitely. Reopen only when a real workload shows per-command dispatch as its bottleneck (then the reopen comment should include that workload, not a microbenchmark).