perf(runner): order test functions in pure bash, drop 5 forks per file#809
Merged
Conversation
Two per-file fork clusters in discovery became pure bash / awk-internal: - functions_for_script piped 'declare -F' through awk | sort | awk (three forks) and the pipeline ran twice per file. A file's function list is small (tens of names), so filter + insertion-sort by definition line in bash — and enable extdebug only inside the capture subshell so the caller's setting is untouched. - check_duplicate_functions piped its awk pass through 'sort' just to keep the (usually empty) duplicate list deterministic; the awk END block sorts it now. 9 -> 5 forks per test file (awk 7 -> 5, sort 2 -> 0), on every file of every run including the acceptance suite's ~258 nested ones. Measured with a PATH shim: bash -x trace counts also pick up re-echoed test output and overcount. No behaviour change.
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
Continuing the fork-reduction series (#801-#808). Ground-truth profiling with a PATH shim (bash -x trace counts overcount by re-echoed test output) showed 7
awk+ 2sortforks per test file, dominated by discovery:functions_for_scriptran anawk | sort | awkpipeline twice per file, and the duplicate check piped awk throughsort.💡 Changes
functions_for_script: filter + insertion-sort the file's functions by definition line in pure bash (a file's function list is tens of names); extdebug now enabled only inside the capture subshell, leaving the caller's setting untouched.check_duplicate_functions: sort the (usually empty) duplicate list inside the awk END block instead of piping throughsort.