Skip to content

perf(console): build the colour palette without a fork per colour - #1286

Merged
Chemaclass merged 1 commit into
mainfrom
perf/1285-coldstart-color-palette-forks
Aug 17, 2026
Merged

perf(console): build the colour palette without a fork per colour#1286
Chemaclass merged 1 commit into
mainfrom
perf/1285-coldstart-color-palette-forks

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

🤔 Background

Related #1285

src/console/colors.sh built its sixteen palette entries with $(bashunit::sgr N) — a subshell fork each, at source time, on every invocation including --version and --help. It was the single largest cost in a cold start, and it outlived the #801#851 fork campaign because a PATH-shim census cannot see a subshell that execs no binary.

💡 Changes

  • The palette now comes from the _BASHUNIT_SGR_OUT return slot that bash-style.md already prescribes; the public echoing bashunit::sgr stays as a thin wrapper, so its contract is unchanged
  • Cold start drops ~9ms, about 15% — interleaved A/B, 3 rounds of 200 invocations in one tree, every round faster
  • New cold-start guard counts the function name in the trace, since the binary-path patterns the neighbouring guards use are blind to this fork class
  • perf-fork-budget.md records the blind spot, and replaces its "sourcing src/ is irreducible" claim with a measured per-source-file breakdown

Sixteen $(bashunit::sgr N) captures ran at source time, one subshell fork
each, on every invocation including --version and --help. The values are
constants, so they now come from the _BASHUNIT_SGR_OUT return slot; the
public echoing bashunit::sgr keeps its contract as a thin wrapper.

Interleaved A/B, 3 rounds of 200 invocations in one tree: ~9ms and ~15%
off every cold start.

Closes #1285
@Chemaclass Chemaclass added the enhancement New feature or request label Aug 16, 2026
@Chemaclass Chemaclass self-assigned this Aug 16, 2026
@Chemaclass
Chemaclass merged commit 2a6f725 into main Aug 17, 2026
37 checks passed
@Chemaclass
Chemaclass deleted the perf/1285-coldstart-color-palette-forks branch August 17, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant