perf(ci): build heph bin + both cdylibs in one cargo invocation#126
Merged
Conversation
The build step ran three sequential `cargo build` calls (heph bin,
plugin-go-cdylib, plugin-gha-cdylib). They share nearly the whole
workspace dep graph, so the deps already compiled once — but under the
release profile (thin-LTO + opt-level=3) each artifact's final
codegen/LTO pass is heavy, and three separate invocations serialize
those passes and re-pay cargo startup + freshness resolution each time.
Collapse them into a single invocation:
cargo build --bin heph --lib -p heph -p plugin-go-cdylib -p plugin-gha-cdylib
`--bin heph` selects the binary; `--lib` adds every selected package's
lib target (both cdylibs). heph's own lib is already built as the bin's
dependency, so it costs nothing extra. cargo's jobserver can now overlap
the three artifacts' codegen — one artifact's link tail fills cores
while the next codegens — instead of running them back to back.
This does NOT split the build across parallel jobs: that would force
each runner to recompile the shared dep graph cold (sccache is restored
at job start, so concurrent jobs don't see each other's fresh writes),
trading the serialized-LTO tail for a duplicated dep compile.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
What
The
buildjob ran three sequentialcargo buildcalls —hephbin,plugin-go-cdylib,plugin-gha-cdylib. Collapse them into one:--bin hephselects the binary;--libadds every selected package's lib target (both cdylibs). heph's own lib is already built as the bin's dependency, so it costs nothing extra.Why
The three crates share nearly the whole workspace dep graph, so deps already compiled once. But under the release profile (
lto = "thin",opt-level = 3) each artifact's final codegen/LTO pass is heavy — three separate invocations serialize those passes and re-pay cargo startup + freshness resolution each time. A single invocation lets cargo's jobserver overlap them: one artifact's link tail fills cores while the next codegens.Why not split into parallel jobs
The original question was whether splitting core CLI + the 2 plugins into separate parallel jobs would be faster. It would not in the common case: each runner would have to recompile the shared dep graph cold (sccache is restored at job start, so concurrent jobs don't see each other's fresh writes), trading the serialized-LTO tail for a duplicated dep compile plus per-job nix-setup + artifact-download overhead. A job split only pays off in the warm-sccache + dominant-LTO regime, and even then is overhead-gated — worth measuring separately, not assuming.
Test
CI-only YAML change. Validated locally that cargo accepts the combined target selection and compiles all three targets (
--bin heph --lib -p heph -p plugin-go-cdylib -p plugin-gha-cdylib). The build matrix on this PR exercises it end-to-end.🤖 Generated with Claude Code