Repository navigation
Conversation
Every Mix command in a project with Hex deps starts Hex, which started :ssl, :inets and the :hex httpc profile even when nothing touches the network. Start them on the first request instead. Closes hexpm#1295.
ericmj
reviewed
Nov 3, 2026
| # network don't pay for starting them | ||
| def start_httpc() do | ||
| unless :persistent_term.get({__MODULE__, :httpc_started}, false) do | ||
| :global.trans({{__MODULE__, :start_httpc}, self()}, &do_start_httpc/0, [node()]) |
Member
There was a problem hiding this comment.
The :global.trans lock isn't needed. Each step in do_start_httpc/0 is safe to repeat, so the :persistent_term check is enough.
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.
Closes #1295.
Every Mix command in a project with Hex deps starts Hex while converging deps. Hex started
:ssl,:inets(+:public_key,:crypto) and the:hexhttpc profile even when nothing touches the network, e.g. a no-opmix compile.Changes:
:ssl/:inetsmoved fromextra_applicationstoincluded_applications: loaded and on the compile path (mix_hex_registry.erlincludespublic_key.hrl), but not startedHex.HTTP.start_httpc/0restores their code paths (Mix.ensure_application!/1, pruning), starts them and the:hexprofile once per VM, on the first request.:persistent_termfast path,:global.trans/3so concurrent registry fetches start it once:ssl_versionstate, which was computed on start (needed:sslloaded) and never readMeasured on macOS (Apple Silicon), OTP 30, Elixir 1.21.0-dev, fresh VM, median of 5:
Hex.start()mix test --exclude integrationpasses locally (no hexpm checkout here). Checkedmix hex.info,mix hex.outdatedagainst hex.pm with the built archive.