Lazily load mixlib-shellout - #436
Open
tas50 wants to merge 1 commit into
Open
Conversation
mixlib-shellout costs ~9ms to require and pulls in etc, fileutils, tmpdir and fcntl (7 files). It is used in exactly one place -- shelling out from `Mixlib::Install.detect_platform` -- so load it there rather than making every consumer pay for it at require time. Measured on Ruby 4.0.6 (min of 15 fresh subprocesses): before 54.79 ms 240 loaded features after 45.40 ms 233 loaded features Compatibility note: this is the one deferral in this series with an observable effect. Code that called `Mixlib::ShellOut` after only requiring mixlib-install, without requiring mixlib-shellout itself, will now get a NameError until it adds the require. Our own functional spec did exactly that, and is fixed here. Please drop this commit if that risk is not worth ~9ms. Generated output is unchanged: all 176 golden SHA256 digests match main. Signed-off-by: Tim Smith <tsmith84@proton.me>
tas50
force-pushed
the
perf/lazy-shellout
branch
from
August 28, 2026 03:58
f594d47 to
675b7d8
Compare
tpowell-progress
approved these changes
Aug 28, 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.
Summary
mixlib-shellout costs ~9 ms to require and pulls in
etc,fileutils,tmpdirandfcntl— 7 files. It is used in exactly one place: shelling out fromMixlib::Install.detect_platform. This loads it there instead of making every consumer pay for it at require time.Measurements
Ruby 4.0.6, minimum of 15 fresh subprocesses:
Compatibility note — please read
This is the one deferral in this series with an externally observable effect, so it is deliberately split into its own PR.
Code that calls
Mixlib::ShellOutafter only requiringmixlib-install, without requiringmixlib-shelloutitself, will now get aNameErroruntil it adds the require. That is relying on a transitive require, but it is easy to do by accident — our own functional spec did exactly that, and is fixed in this PR.The three main consumers (chef, chef-cli, test-kitchen) all require mixlib-shellout directly, so I believe the risk is low. But it is a real behaviour change for ~9 ms, and it is entirely reasonable to close this one and keep the other load-time PRs in this series. Happy either way.
Verification
chefstyleclean.Mixlib::Install.detect_platformverified working in a bare process:Mixlib::ShellOutis undefined at load, defined after the call, and the returned platform hash is correct.main.