perf(trampoline): build vp-shim with build-std to shrink it to 72KB - #2465
Draft
fengmk2 wants to merge 2 commits into
Draft
perf(trampoline): build vp-shim with build-std to shrink it to 72KB#2465fengmk2 wants to merge 2 commits into
fengmk2 wants to merge 2 commits into
Conversation
Move crates/vp_trampoline out of the workspace: cargo ignores `panic` in per-package profile overrides, so the crate needs its own release profile with panic = "immediate-abort". A crate-local .cargo/config.toml enables build-std, which recompiles std under the size profile and compiles out the panic formatting, unwinding, and backtrace machinery. The source is unchanged. vp-shim.exe: 212,992 B to 73,728 B on x86_64-pc-windows-msvc, 190,976 B to 71,168 B on aarch64-pc-windows-msvc. The crate config keeps artifacts in the repo-root target/ directory, so CI steps, the snapshot runner, and install-global-cli find vp-shim.exe in the same place as before. Every former `cargo build -p vp_trampoline` call site now builds from the crate directory so the config applies. rust-toolchain.toml adds the rust-src component (build-std needs the std sources). The root Cargo.lock drops the stale vp_trampoline entry, which --locked commands require. The trampoline RFC records the measured variant table down to a 7KB raw-Win32 recipe for future size work.
✅ Deploy Preview for viteplus-preview canceled.
|
Contributor
Native binary sizes (
|
| Artifact | Format | Base | PR | Change |
|---|---|---|---|---|
vp (Linux x64) |
Binary | 10.67 MiB | 10.68 MiB | +4.00 KiB (+0.04%) |
vp (Linux x64) |
gzip -9 | 4.62 MiB | 4.62 MiB | +566 B (+0.01%) |
| NAPI (Linux x64) | Binary | 32.02 MiB | 32.03 MiB | +8.00 KiB (+0.02%) |
| NAPI (Linux x64) | gzip -9 | 12.61 MiB | 12.61 MiB | -476 B (-0.00%) |
vp (macOS ARM64) |
Binary | 7.98 MiB | 7.98 MiB | +16 B (+0.00%) |
vp (macOS ARM64) |
gzip -9 | 4.03 MiB | 4.03 MiB | +312 B (+0.01%) |
| NAPI (macOS ARM64) | Binary | 39.68 MiB | 39.68 MiB | +32 B (+0.00%) |
| NAPI (macOS ARM64) | gzip -9 | 16.92 MiB | 16.92 MiB | +893 B (+0.01%) |
vp (Windows x64) |
Binary | 8.55 MiB | 8.56 MiB | +7.00 KiB (+0.08%) |
vp (Windows x64) |
gzip -9 | 3.73 MiB | 3.73 MiB | +1.87 KiB (+0.05%) |
| NAPI (Windows x64) | Binary | 26.89 MiB | 26.90 MiB | +8.50 KiB (+0.03%) |
| NAPI (Windows x64) | gzip -9 | 10.68 MiB | 10.69 MiB | +1.79 KiB (+0.02%) |
| Trampoline (Windows x64) | Binary | 205.00 KiB | 72.00 KiB | -133.00 KiB (-64.88%) |
| Trampoline (Windows x64) | gzip -9 | 99.00 KiB | 39.79 KiB | -59.20 KiB (-59.80%) |
| Installer (Windows x64) | Binary | 4.47 MiB | 4.47 MiB | +5.50 KiB (+0.12%) |
| Installer (Windows x64) | gzip -9 | 2.09 MiB | 2.09 MiB | +1.48 KiB (+0.07%) |
The Build Windows tests archive step enumerates crates/*/ and passed -p vp_trampoline, which is no longer a workspace member; skip it like the justfile test recipe does (its only test module is unix-only, so it has nothing to contribute to the Windows archive). Also apply oxfmt 0.63.0 to the RFC tables, which vp check flagged on the CLI E2E jobs.
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.
Shrinks the Windows shim
vp-shim.exefrom 213KB to 72KB with zero source changes.The size was set by the precompiled
std:lang_startinit, panic formatting, and backtrace support stay linked no matter what the crate code does, andopt-level = "z"cannot remove code a prebuilt rlib already contains. The fix recompilesstdunder the crate's own size profile:crates/vp_trampolineleaves the workspace (cargo ignorespanicin per-package profile overrides, so the crate needs its own profile withpanic = "immediate-abort"; uv excludesuv-trampolinefor the same reason)..cargo/config.tomlenables-Zbuild-stdand keeps artifacts in the repo-roottarget/, so CI steps, the snapshot runner, andinstall-global-clifindvp-shim.exein the same place as before.rust-toolchain.tomladds therust-srccomponent. The repo already pins the nightly toolchain, so no toolchain change.cargo build -p vp_trampolinecall site (bootstrap-cli, justfile, both CI composite actions) now builds from the crate directory so the config applies. The rootCargo.lockdrops the stalevp_trampolineentry, which--lockedcommands require.Measured with cargo-xwin:
For reference: uv-trampoline ships 45KB, Scoop's default C shim is 136KB. The trampoline RFC now records the full measured variant table, including a verified 6.6KB raw-Win32 recipe and its gotchas (the
atexitpull on current nightlies under#![no_main], the required subsystem attribute, the+crt-staticsize trap), as reference for future size work.Verified locally: release builds for both Windows targets and the host, crate clippy/fmt/test,
cargo metadata --lockedon the workspace, and dry-runs of the edited just recipes. The trampoline source is unchanged, so the Windows CI leg (PTY snapshot suite) is the remaining behavior gate; the vp-binary-size workflow should show the drop on this PR.