Skip to content

Run logged install scripts in a subshell - #21996

Open
emirb wants to merge 1 commit into
quattrofrom
perf/run-logged-subshell
Open

emirb wants to merge 1 commit into
quattrofrom
perf/run-logged-subshell

Conversation

@emirb

@emirb emirb commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

What changes

Every install executes around 100 setup scripts through run_logged in install/helpers/logging.sh. Each call previously launched a new bash process via execve, paying ELF loading and startup cost on every leaf.

run_logged now runs each leaf in a forked subshell (_omarchy_run_logged_script), resetting set +u, set +o pipefail, IFS, and PS4 before enabling set -eE and sourcing the script. Inside the subshell, a zero-fork ERR trap probe checks whether the caller suppressed errexit (for example if ! run_logged in omarchy-provision-hardware) and falls back to exec bash -eE in the same PID so failures still abort immediately.

This keeps caller isolation intact, leaves OMARCHY_INSTALL_DEBUG=1 tracing unchanged, and reverts cleanly in one commit.

Verification

  • Before: new regression test in test/shell.d/pkg-drop-test.sh failed on origin/quattro because normal run_logged calls invoked bash on PATH.
  • After: pkg-drop-test.sh, hw-platform-test.sh, image-target-platform-test.sh, apply-lock-test.sh, dgx-spark-boot-test.sh, and platform-setup-test.sh all pass on Bash 5.3.
  • Benchmark (5 interleaved runs of 100 leaves on Bash 5.3): median dropped from 125.5 ms to 49.3 ms.
  • Not checked: full bare-metal ISO install with this commit (covered by CI and companion ISO install tests).

Screenshots

No visible change: internal installer helper in install/helpers/logging.sh.

Every install runs about 100 scripts through run_logged. Each call
previously spawned a fresh bash process via execve, adding ELF loading
and shell startup overhead on every leaf.

Run each script in a forked subshell instead, clearing nounset and
pipefail and resetting IFS before sourcing the leaf. A zero-fork ERR
trap probe detects when a caller invoked run_logged inside an
errexit-suppressed context such as `if ! run_logged` (used by
omarchy-provision-hardware) and falls back to `exec bash -eE` in the
same PID so `set -e` still aborts on failure.

100 empty leaves drop from 125.5 ms to 49.3 ms on Bash 5.3.
@greptile-apps

greptile-apps Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[Medium impact] The PR appears safe to merge; no actionable failures were found.

Summary

run_logged now sources setup scripts in a forked subshell instead of starting a fresh Bash process on every normal call.

  • The installer runs logged scripts in a forked subshell.

Diagram

%%{init: {'theme': 'neutral', 'htmlLabels': false}}%%
flowchart TD
  A["run_logged"] --> B{"Skip this platform?"}
  B -->|Yes| C["Return success"]
  B -->|No| D["Log start and fork subshell"]
  D --> E["Probe ERR trap"]
  E --> F{"Caller suppresses error exits?"}
  F -->|Yes| G["exec bash -eE"]
  F -->|No| H["Reset options and source script"]
  G --> I["Capture exit status"]
  H --> I
  I --> J["Log result and return status"]
Loading

Reviews (1) · Last reviewed commit: "Run logged install scripts in a subshell" · Reviewed by Greptile

@omarchybot omarchybot added enhancement New feature or request verified Omarchy Triage has verified that this issue is ready for final review labels Dec 6, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Recommend: Hold — the maintainer should weigh the measured speedup against maintaining two Bash execution contexts.

The CLI suite and six installer test files passed on an ISO worker. A benchmark of 100 empty leaves saved 51 ms. Direct setup now inherits caller variables and functions, and deferred first boot still starts a fresh Bash process. Codex High, Opus 5.5 High, and muse-wonder via pi (high effort) found no regression in the current leaves. The reviews could see the same session context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants