perf(runner): remove remaining run_test hot-path forks#782
Merged
Conversation
Convert the two per-test normalize_test_function_name captures in run_test to the existing fork-free normalize_test_function_name_to_slot variant, removing a command-substitution fork on the hot path (and a second on the hook-failure path). No behaviour change. Part of #774.
Add bashunit::clock::now_to_slot writing _BASHUNIT_CLOCK_NOW_OUT and make bashunit::clock::now delegate to it (single source of truth). The shell branch reads EPOCHREALTIME directly, folding in shell_time so the Bash 5.0+ hot path pays no command-substitution fork; date-seconds forks once instead of twice. Interpreter/date branches keep one internal fork. Convert both run_test clock captures (start_time, end_time) to the slot. _choose_impl selection and the #765 auto-skip behaviour are unchanged. Part of #774.
bashunit::parallel::is_enabled was re-evaluating the env layer plus four OS checks (and logging) on every call, several times per test. Resolve it once after arg parsing via bashunit::parallel::resolve_enabled into _BASHUNIT_PARALLEL_ENABLED; is_enabled is now a pure global read that falls back to a fresh, uncached compute only when unresolved (e.g. unit tests that toggle env directly). The internal_log now fires once, not per call. Part of #774.
Fold the per-file `grep -q '^# bashunit: no-parallel-tests'` probe into the existing build_provider_map awk pass, exposing the result via _BASHUNIT_PROVIDER_MAP_NO_PARALLEL. Removes one grep fork per test file. Also add the CHANGELOG entry for the #774 hot-path work. No behaviour change. Closes #774.
JesusValeraDev
approved these changes
Jul 13, 2026
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 #774
Follow-up to #764: the per-test
run_testloop still forked for label normalization, clock capture, and repeatedparallel::is_enabledchecks. This removes those remaining forks with no behaviour change.💡 Changes
bashunit::clock::now_to_slotreadsEPOCHREALTIMEdirectly on Bash 5.0+.is_enabledcall.no-parallel-testsopt-out is detected inside the existing single-pass file scan rather than a separate per-filegrep.