Skip to content

perf: reduce vp binary size#2043

Draft
fengmk2 wants to merge 1 commit into
mainfrom
perf/reduce-vp-binary-size
Draft

perf: reduce vp binary size#2043
fengmk2 wants to merge 1 commit into
mainfrom
perf/reduce-vp-binary-size

Conversation

@fengmk2

@fengmk2 fengmk2 commented Jul 4, 2026

Copy link
Copy Markdown
Member

Summary

  • limit tracing-subscriber to the fmt and std features used by the native binaries
  • limit zip to Deflate support required by official Node.js Windows archives
  • remove unused SQLite, bincode, and wax variants/dependencies from vite_error
  • feature-gate migration-only error conversions so they only enter binaries that expose migration APIs
  • add a native-size workflow that compares base/head vp, NAPI, and trampoline release artifacts and maintains a sticky PR comment with raw and gzip -9 sizes

Local size comparison

macOS ARM64 release builds:

Artifact Base PR Change
vp 8,421,152 B 7,991,184 B -429,968 B (-5.11%)
vp (gzip -9) 4,096,467 B 3,857,580 B -238,887 B (-5.83%)
NAPI 43,474,032 B 42,745,888 B -728,144 B (-1.67%)
NAPI (gzip -9) 17,586,473 B 17,185,652 B -400,821 B (-2.28%)

The workflow adds the authoritative Linux x64 vp/NAPI and Windows x64 trampoline comparison below. No optimization level or runtime behavior was changed.

Validation

  • cargo shear
  • just check
  • just lint
  • cargo test -p vite_migration (312 passed)
  • env -u NODE_OPTIONS cargo test -p vite_js_runtime --lib (119 passed, 2 ignored, including live Node download/extraction)
  • cargo build -p vite_global_cli --release
  • pnpm --filter=vite-plus build-native --target aarch64-apple-darwin --skip-format
  • load optimized NAPI module in Node.js (93 exports)
  • target/release/vp --help
  • target/release/vp --version
  • cargo fmt --all --check
  • actionlint .github/workflows/vp-binary-size.yml

@fengmk2 fengmk2 self-assigned this Jul 4, 2026
@netlify

netlify Bot commented Jul 4, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit ad948a7
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a48c94b80a6dc00081d8806

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Native binary sizes (ad948a7)

Release builds for the shipped Linux x64 CLI/NAPI artifacts and Windows x64 trampoline.

Artifact Format Base PR Change
vp (Linux x64) Binary 11,289,264 B (10.77 MiB) 10,759,288 B (10.26 MiB) -529,976 B (-4.69%)
vp (Linux x64) gzip -9 4,765,238 B (4.54 MiB) 4,492,853 B (4.28 MiB) -272,385 B (-5.72%)
NAPI (Linux x64) Binary 35,226,448 B (33.59 MiB) 35,063,504 B (33.44 MiB) -162,944 B (-0.46%)
NAPI (Linux x64) gzip -9 13,162,726 B (12.55 MiB) 13,090,179 B (12.48 MiB) -72,547 B (-0.55%)
Trampoline (Windows x64) Binary 207,872 B (0.20 MiB) 207,872 B (0.20 MiB) 0 B (0.00%)
Trampoline (Windows x64) gzip -9 97,498 B (0.09 MiB) 97,497 B (0.09 MiB) -1 B (-0.00%)

@fengmk2 fengmk2 force-pushed the perf/reduce-vp-binary-size branch from 87be261 to 49eecdc Compare July 4, 2026 08:07
@fengmk2 fengmk2 added test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw labels Jul 4, 2026
@fengmk2 fengmk2 force-pushed the perf/reduce-vp-binary-size branch from 49eecdc to ad948a7 Compare July 4, 2026 08:50
@fengmk2

fengmk2 commented Jul 4, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad948a7d08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +13 to +16
- 'crates/**'
- 'Cargo.lock'
- 'Cargo.toml'
- 'rust-toolchain.toml'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include all native build inputs in the trigger

This path filter watches crates/** and Cargo files, but the workflow also builds the NAPI crate from packages/cli/binding (cargo build -p vite-plus-cli) and the clone action reads packages/tools/.upstream-versions.json to choose the rolldown/vite revisions. A PR that changes either of those inputs can change the measured native artifacts without running this workflow at all, so the size report silently misses those regressions; add those paths to the filter or remove the filter.

Useful? React with 👍 / 👎.

comment:
name: Report binary size
needs: [base, head]
if: github.event.pull_request.head.repo.full_name == github.repository

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Avoid building fork PRs without reporting the result

When the PR comes from a fork, this job is skipped, but the base and head jobs above are not gated the same way. Since this skipped job is also the only place the comparison is emitted, including the job summary, fork PRs still spend CI time on both release builds and then produce no size output; either skip the build jobs for forks too or keep a read-only summary/report path for them.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test: create-e2e Run `vp create` e2e tests test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: sfw

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant