perf(runner): unset each file's test functions after processing#830
Merged
Conversation
Test files are sourced into the main shell and their functions stayed defined for the whole run. Every test executes in a $() subshell, so each fork copied an ever-growing shell and multi-file runs slowed down quadratically: bashunit's own unit suite spent ~2s/file on its last files vs 0.3s/file on its first (the last 18 files take 8.7s standalone but ~38s as the tail of the full run). Unset a file's test functions (full pre-tag/rerun list) next to the existing hook cleanup. In parallel mode the file's workers have already forked with their own copy by the time the parent unsets, so it is race-free. unset -f is a builtin: no new forks, Bash 3.0-safe. Unit suite: ~64s -> ~21.5s sequential, ~26s -> ~7s parallel. Full suite: ~2m48s -> ~2m07s sequential, ~55s -> ~24.5s parallel. Closes #829
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 #829
Test files are sourced into the main shell and their functions stayed defined for the whole run. Every test executes in a
$()subshell, so each fork copied an ever-growing shell — multi-file runs slowed down quadratically (last 18 unit files: 8.7s standalone, ~38s as the tail of the full run).💡 Changes
unset -fis a builtin — no new forks, Bash 3.0-safe, fork-budget tests untouchedhttps://claude.ai/code/session_01JSeB8UzLCpqst55hAK6dED