perf: optimize artifact dependencies, and fail the build when a consumer does not - #597
Merged
Merged
Conversation
fspy benchmarklinuxmacoswindows |
wan9chi
force-pushed
the
claude/fspy-artifact-opt-level
branch
from
August 9, 2026 01:11
b155abe to
18f0aa2
Compare
wan9chi
force-pushed
the
claude/fspy-artifact-opt-level
branch
from
August 9, 2026 01:28
18f0aa2 to
f8754c5
Compare
…mer does not Cargo compiles artifact dependencies declared under [build-dependencies] with the build-override profile — opt-level 0, default codegen-units — even in release builds (rust-lang/cargo#16719), and it only reads profiles from the root manifest of the workspace being built. Their output still lands under target/<triple>/release/, so nothing reports the omission. Three workspace artifacts are build-dependencies and have been shipping unoptimized: fspy_preload_unix and fspy_preload_windows (injected into every traced process, running inside every intercepted libc call), and vt_client_napi. Set opt-level 3 for them, restore codegen-units 1 (the host profile drops it), and restate strip = "symbols" (a package override otherwise resets inherited strip to "debuginfo"). Because those profile entries live in the root manifest, they do not reach workspaces that consume these crates as dependencies — vite-plus builds the preload at opt-level 0 today and would keep doing so. So each artifact crate now checks its own OPT_LEVEL in its build script and fails a release build that is unoptimized, printing the exact profile block to add. Debug builds are unaffected, and ALLOW_UNOPTIMIZED_ARTIFACTS=1 waives the check. Measured on x86_64 Linux, tracked opens with the optimized unix preload (batch median per 8 opens): access -24.8%, access-relative -19.1%. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
wan9chi
force-pushed
the
claude/fspy-artifact-opt-level
branch
from
August 9, 2026 01:33
f8754c5 to
dbccfd2
Compare
wan9chi
marked this pull request as ready for review
August 9, 2026 01:41
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Motivation
Cargo compiles artifact dependencies declared under
[build-dependencies]with the build-override profile — opt-level 0 — even in release builds. It is the[build-dependencies]placement, not theartifact = ...key, that triggers this (artifact deps under[dependencies]get the normal profile). The output still lands undertarget/<triple>/release/, so nothing reports the omission. See rust-lang/cargo#16719; the per-package override used here is what maintainers recommend (rust-lang/cargo#11680).Three workspace artifacts are build-dependencies and have been shipping unoptimized: the two preload libraries — injected into every traced process, running inside every intercepted libc call — and
vt_client_napi.What this does
Sets the profile. A
[profile.release.package.<name>]block per artifact, withopt-level = 3,codegen-units = 1(the host profile drops the workspace setting), andstrip = "symbols"(a package override otherwise resets an inheritedstripto"debuginfo", which would leave the preload.so— embedded into thefspybinary — larger than intended).Then checks that it worked. Profiles only take effect from the root manifest of the workspace being built, so these entries do not reach workspaces that consume these crates. vite-plus builds the preload at opt-level 0 today and would keep doing so after this merges, silently. Rather than rely on every consumer knowing, each artifact crate now inspects its own
OPT_LEVELin its build script and fails a release build that is unoptimized:Debug builds are unaffected, since opt-level 0 is correct there.
Only the optimization level is checked: Cargo passes
OPT_LEVEL,DEBUGandPROFILEto build scripts, but notcodegen-unitsorstrip, so those cannot be verified — which is why the message prints the whole block rather than the one setting it can see. The check lives in each artifact crate rather than inmaterialized_artifact_buildbecause that crate runs from the consuming build script, which reports its ownOPT_LEVEL(3) while the artifact it just embedded was built at 0.This is a breaking change for downstream workspaces. vite-plus will fail to build until it adds the three blocks to its root
Cargo.toml— it already uses that pattern forvite_trampolineandvite_installer. That failure is the point: the alternative is shipping a preload that costs ~25% on every intercepted call, with no signal at all.Measurements
x86_64 Linux, benchmark launcher built with vs. without the profile change, batch median per 8 tracked opens:
Raising the dependency subtree's pre-LTO opt-level on top of this measured within noise — fat LTO re-optimizes the merged module at the cdylib's opt-level — so this keeps the smaller, cdylib-only override set.
🤖 Generated with Claude Code