perf(console): build the colour palette without a fork per colour - #1286
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 Background
Related #1285
src/console/colors.shbuilt its sixteen palette entries with$(bashunit::sgr N)— a subshell fork each, at source time, on every invocation including--versionand--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
_BASHUNIT_SGR_OUTreturn slot thatbash-style.mdalready prescribes; the public echoingbashunit::sgrstays as a thin wrapper, so its contract is unchangedperf-fork-budget.mdrecords the blind spot, and replaces its "sourcingsrc/is irreducible" claim with a measured per-source-file breakdown