Skip to content

perf(runner): use 'wait -n' for parallel job slot on Bash 4.3+#671

Merged
Chemaclass merged 2 commits into
mainfrom
perf/667-wait-n-job-slot
May 12, 2026
Merged

perf(runner): use 'wait -n' for parallel job slot on Bash 4.3+#671
Chemaclass merged 2 commits into
mainfrom
perf/667-wait-n-job-slot

Conversation

@Chemaclass
Copy link
Copy Markdown
Member

Summary

  • Add bashunit::runner::_supports_wait_n version probe.
  • When Bash supports wait -n (4.3+), wait_for_job_slot blocks until any child exits instead of polling jobs -r on a 50–200ms cadence.
  • Bash 3.x keeps the existing adaptive-poll path unchanged — full back-compat preserved.

Why

  • Eliminates sleep-induced wakeup latency every time a parallel test finishes.
  • Cuts jobs -r | wc -l subshell invocations on the hot scheduling path.

Test plan

  • tests/unit/parallel_test.sh extended with:
    • test_supports_wait_n_matches_running_bash_version
    • test_wait_for_job_slot_releases_when_background_job_finishes (exercises both paths)
  • ./bashunit tests/unit/ green (816 passed)
  • ./bashunit --parallel tests/ green (1051 passed, 46s — was 48s baseline)
  • make sa clean
  • make lint clean
  • Bash 3.0+ fallback path preserved

Closes #667

@Chemaclass Chemaclass added enhancement New feature or request refactoring Refactoring or cleaning related labels May 12, 2026
@Chemaclass Chemaclass self-assigned this May 12, 2026
Add bashunit::runner::_supports_wait_n version probe. When supported,
wait_for_job_slot blocks on next-child-exit instead of polling 'jobs -r'
on a 50-200ms cadence. Bash 3.x keeps the existing adaptive-poll path.

Eliminates sleep-induced wakeup latency on every released slot and cuts
'jobs -r | wc -l' subshell invocations.

Closes #667
@Chemaclass Chemaclass force-pushed the perf/667-wait-n-job-slot branch from 37aefe9 to aa2b498 Compare May 12, 2026 08:52
@Chemaclass Chemaclass merged commit f81c7e4 into main May 12, 2026
25 of 26 checks passed
@Chemaclass Chemaclass deleted the perf/667-wait-n-job-slot branch May 12, 2026 08: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 refactoring Refactoring or cleaning related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(runner): use 'wait -n' for parallel job slot when available

1 participant