Skip to content

perf(trampoline): raw Win32 rewrite shrinks vp-shim to 14KB - #2466

Merged
fengmk2 merged 11 commits into
mainfrom
perf/trampoline-raw-win32
Aug 25, 2026
Merged

perf(trampoline): raw Win32 rewrite shrinks vp-shim to 14KB#2466
fengmk2 merged 11 commits into
mainfrom
perf/trampoline-raw-win32

Conversation

@fengmk2

@fengmk2 fengmk2 commented Aug 16, 2026

Copy link
Copy Markdown
Member

This PR is an alternative to #2465. It keeps build-std and replaces std::process::Command with raw Win32 API calls.

The canonical CI build produced these x64 results:

Artifact Base This PR Change
vp-shim.exe 214.00 KiB 14.00 KiB -200.00 KiB (-93.46%)
gzip -9 103.20 KiB 7.09 KiB -96.11 KiB (-93.13%)

On Windows, the executable imports only KERNEL32. It uses #![no_main], mainCRTStartup, and an atexit stub to exclude CRT startup code.

  • The shim reads the adjacent <name>.shim file. It supports versioned single-root and split layouts.
  • It normalizes drive-letter and UNC paths before Win32 API calls. This permits paths longer than 260 characters.
  • It passes the original UTF-16 argument tail to CreateProcessW. It keeps quotation marks unchanged.
  • It inherits redirected standard handles. The child handles console control events. The shim returns the child exit code.
  • It reports the failed operation, the related path, and the GetLastError code. A missing vp.exe message gives repair instructions.

Non-Windows builds use the portable implementation. Unit tests cover sidecar parsing, path handling, and command-line parsing.

@netlify

netlify Bot commented Aug 16, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

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

@fengmk2 fengmk2 added preview-build Publish this PR's commits to the registry bridge as preview builds and removed preview-build Publish this PR's commits to the registry bridge as preview builds labels Aug 16, 2026
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Native binary sizes (2d4a47d)

Final release artifacts built by the canonical build-upstream and build-windows-cli actions.

Artifact Format Base PR Change
vp (Linux x64) Binary 10.74 MiB 10.74 MiB 0 B (0.00%)
vp (Linux x64) gzip -9 4.64 MiB 4.64 MiB -149 B (-0.00%)
NAPI (Linux x64) Binary 32.20 MiB 32.21 MiB +8.00 KiB (+0.02%)
NAPI (Linux x64) gzip -9 12.69 MiB 12.69 MiB +1.53 KiB (+0.01%)
vp (macOS ARM64) Binary 8.03 MiB 8.03 MiB +16 B (+0.00%)
vp (macOS ARM64) gzip -9 4.05 MiB 4.05 MiB +356 B (+0.01%)
NAPI (macOS ARM64) Binary 39.79 MiB 39.80 MiB +16.16 KiB (+0.04%)
NAPI (macOS ARM64) gzip -9 16.99 MiB 16.99 MiB +815 B (+0.00%)
vp (Windows x64) Binary 8.63 MiB 8.64 MiB +7.00 KiB (+0.08%)
vp (Windows x64) gzip -9 3.77 MiB 3.77 MiB +2.64 KiB (+0.07%)
NAPI (Windows x64) Binary 27.04 MiB 27.05 MiB +9.00 KiB (+0.03%)
NAPI (Windows x64) gzip -9 10.76 MiB 10.76 MiB +2.27 KiB (+0.02%)
Trampoline (Windows x64) Binary 214.00 KiB 14.00 KiB -200.00 KiB (-93.46%)
Trampoline (Windows x64) gzip -9 103.20 KiB 7.09 KiB -96.11 KiB (-93.13%)
Installer (Windows x64) Binary 4.50 MiB 4.50 MiB +5.50 KiB (+0.12%)
Installer (Windows x64) gzip -9 2.11 MiB 2.11 MiB +1.50 KiB (+0.07%)

@fengmk2 fengmk2 self-assigned this Aug 16, 2026
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Registry bridge build (2d4a47d)

This commit build is published to the registry bridge, which serves these as ordinary npm versions (every other package proxies to npmjs):

Package Version
vite-plus 0.0.0-commit.2d4a47d7bba13bdbc0206399e87e506cd39eab36
@voidzero-dev/vite-plus-core 0.0.0-commit.2d4a47d7bba13bdbc0206399e87e506cd39eab36

Install the Vite+ CLI built from this commit, then migrate a project:

# macOS / Linux
curl -fsSL https://github.com/@raw/voidzero-dev/vite-plus/2d4a47d7bba13bdbc0206399e87e506cd39eab36/packages/cli/install.sh | VP_PR_VERSION=2466 bash
# Windows (PowerShell)
$env:VP_PR_VERSION="2466"; irm https://raw.githubusercontent.com/voidzero-dev/vite-plus/2d4a47d7bba13bdbc0206399e87e506cd39eab36/packages/cli/install.ps1 | iex

Or download the standalone Windows installer built from this commit:

Architecture Installer
x64 vp-setup-x86_64-pc-windows-msvc.exe
Arm64 vp-setup-aarch64-pc-windows-msvc.exe

GitHub requires you to sign in and downloads each installer as a ZIP artifact. Extract vp-setup.exe, then run it against this preview build:

.\vp-setup.exe --version "0.0.0-commit.2d4a47d7bba13bdbc0206399e87e506cd39eab36" --registry "https://registry-bridge.viteplus.dev/"

After installing, upgrade the current project's vite-plus to this test build with:

vp migrate

Or point your package manager at the bridge registry https://registry-bridge.viteplus.dev/:

Package manager Registry config
npm / pnpm / Bun .npmrc: registry=https://registry-bridge.viteplus.dev/
Yarn (v2+) .yarnrc.yml: npmRegistryServer: "https://registry-bridge.viteplus.dev/"

Then pin the build (vite aliases to vite-plus-core; pnpm can use a catalog, npm an overrides entry):

{
  "devDependencies": {
    "vite-plus": "0.0.0-commit.2d4a47d7bba13bdbc0206399e87e506cd39eab36",
    "vite": "npm:@voidzero-dev/vite-plus-core@0.0.0-commit.2d4a47d7bba13bdbc0206399e87e506cd39eab36"
  }
}

@github-actions

Copy link
Copy Markdown
Contributor

🐳 Docker preview image

Built from this PR's registry bridge build:

Image Compressed size
ghcr.io/voidzero-dev/vite-plus:pr-2466 236MB
# remove any stale local copy from a previous run, then pull fresh
docker rmi ghcr.io/voidzero-dev/vite-plus:pr-2466 2>/dev/null; docker pull ghcr.io/voidzero-dev/vite-plus:pr-2466

Quick check:

docker run --rm ghcr.io/voidzero-dev/vite-plus:pr-2466 vp --version

See docs/guide/docker.md for usage.

@fengmk2
fengmk2 force-pushed the perf/trampoline-raw-win32 branch from 8a5b436 to ab93774 Compare August 21, 2026 12:26
@fengmk2 fengmk2 removed the preview-build Publish this PR's commits to the registry bridge as preview builds label Aug 21, 2026
@fengmk2 fengmk2 changed the title perf(trampoline): raw Win32 rewrite shrinks vp-shim to 8KB perf(trampoline): raw Win32 rewrite shrinks vp-shim to 14KB Aug 21, 2026
@fengmk2 fengmk2 added the preview-build Publish this PR's commits to the registry bridge as preview builds label Aug 21, 2026
@fengmk2
fengmk2 force-pushed the perf/trampoline-raw-win32 branch 3 times, most recently from 6079a4e to 031317c Compare August 22, 2026 04:24
@fengmk2 fengmk2 added preview-build Publish this PR's commits to the registry bridge as preview builds test: e2e Auto run e2e tests test: install-e2e run vite install e2e test test: create-e2e Run `vp create` e2e tests test: sfw and removed preview-build Publish this PR's commits to the registry bridge as preview builds labels Aug 22, 2026
@fengmk2
fengmk2 force-pushed the perf/trampoline-raw-win32 branch from dd2fa66 to 4bc3d18 Compare August 23, 2026 05:28
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 removes panic formatting, unwinding, and backtrace machinery. The implementation is otherwise unchanged.

With the sidecar-aware source from current main, vp-shim.exe changes from 221,696 B to 82,432 B on x86_64-pc-windows-msvc and from 200,704 B to 79,360 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, and the root Cargo.lock drops the stale vp_trampoline entry required by `--locked` commands.
…to 14KB

On top of the build-std profile, replace the Windows implementation with `#![no_main]`, `mainCRTStartup`, and raw KERNEL32 calls in the uv-trampoline structure. The raw path reads the adjacent versioned or legacy `.shim` sidecar from current main, resolves `vp.exe`, and applies the single-root or split directory environment.

The child command line uses the raw `GetCommandLineW` tail after the program argument, so the caller quoting is preserved. Redirected standard handles are made inheritable before `CreateProcessW`, and the trampoline forwards the child exit code.

Launch-critical failures report the failed operation, relevant path, and Windows error code. A missing `vp.exe` also prints a recovery hint. The sidecar-aware binary is 14,336 B on both x86_64-pc-windows-msvc and aarch64-pc-windows-msvc and imports only KERNEL32.

The non-Windows build keeps a portable `std::process::Command` implementation for tests. Pure helpers cover command-line parsing, sidecar parsing, file stems, and decimal formatting on every platform.
The Windows archive step enumerates `crates/*/`, but `vp_trampoline` is no longer a workspace member. Skip it as the `justfile` test recipe does. Portable parser and layout tests run from the standalone crate on Unix, while Windows shim behavior remains covered by the Windows CLI snapshot suite.

Also format the RFC tables and refresh the measured size ladder for the sidecar-aware baseline and raw implementation.
@fengmk2
fengmk2 force-pushed the perf/trampoline-raw-win32 branch from 4bc3d18 to 2d4a47d Compare August 25, 2026 01:11
@fengmk2 fengmk2 added preview-build Publish this PR's commits to the registry bridge as preview builds and removed preview-build Publish this PR's commits to the registry bridge as preview builds labels Aug 25, 2026
@fengmk2
fengmk2 marked this pull request as ready for review August 25, 2026 01:13
@fengmk2
fengmk2 merged commit 43a7240 into main Aug 25, 2026
145 of 167 checks passed
@fengmk2
fengmk2 deleted the perf/trampoline-raw-win32 branch August 25, 2026 02:46
fengmk2 added a commit that referenced this pull request Sep 8, 2026
`vp env` now manages Node.js and package-manager versions together. This
release also fixes TanStack Start routing and stale Vitest aliases.

### Breaking Changes

#### Package-manager setup

Vite+ replaces Corepack with managed `npm`, `pnpm`, `yarn`, and `bun`
commands. It removes the `corepack` shim and legacy global
package-manager installations
([#2391](#2391)), by
@liangmiQwQ.

Replace Corepack setup commands in shell profiles, CI jobs, and
Dockerfiles:

| Previous setup | Replacement |
| --- | --- |
| `corepack enable` | `vp env setup` |
| `vp install -g pnpm@<version>` | `vp env default pnpm@<version>` |
| `vp install -g yarn@<version>` | `vp env default yarn@<version>` |
| `vp install -g bun@<version>` | `vp env default bun@<version>` |
| `vp install -g corepack` | Use the managed package-manager commands
directly |

Use `vp env pin <manager>@<version>` to set a project version.

#### `vp env` command scope and JSON output

Unscoped `vp env` commands now operate on Node.js and package managers.
Package managers support independent defaults, project pins, session
overrides, and installation commands
([#2398](#2398)), by
@liangmiQwQ.

Add `node` to limit an operation to Node.js, for example, `vp env off
node` or `vp env unpin node`. Bare versions, such as `vp env default
22.19.0`, still select Node.js.

Update scripts that read JSON output:

| Command | New output structure |
| --- | --- |
| `vp env current --json` | `node` and `package_manager` objects |
| `vp env list --json`, `vp env list-remote --json` | `node` and
`package_managers` groups |

See the [environment guide](https://viteplus.dev/guide/env).

#### `vp pack` migration to `tsdown` `0.23`

`vp pack` now uses `tsdown` `0.23`, which removes deprecated options and
changes defaults
([#2614](#2614)), by
@fengmk2.

1. Run `vp migrate` to update supported static configurations and
package scripts, including projects that already use Vite+.
2. Check migration warnings in `vite.config.*`, `tsdown.config.*`, and
`package.json`.
3. Update dynamic configurations manually. Arrays built with `.map()`
require manual changes, even when migration reports no warning.
4. Run `vp pack` to check the result.

| Previous option | Replacement |
| --- | --- |
| `bundle: false` | `unbundle: true` |
| `outExtension` | `outExtensions` |
| `publicDir` / `--public-dir` | `copy` / `--copy` |
| `removeNodeProtocol: true` | `nodeProtocol: 'strip'` |
| `injectStyle` | `css.inject` |
| `inlineOnly` / `deps.onlyAllowBundle` | `deps.onlyBundle` |
| `noExternal` | `deps.alwaysBundle` |
| `skipNodeModulesBundle: true` / `deps.skipNodeModulesBundle: true` |
`deps.neverBundle: true` |
| `dts.tsgo: true` / `dts.oxc: true` | `dts.generator: 'tsgo'` /
`dts.generator: 'oxc'` |

Migration preserves the previous defaults for dependency resolution and
ATTW.

`tsdown` no longer supports Node.js `25`. Use Node.js `^22.18.0`,
`^24.11.0`, or `>=26.0.0`. The programmatic `build()` API now returns `{
bundles, watch }`.

See the [complete migration
guide](https://github.com/rolldown/tsdown/releases/tag/v0.23.0) for
declaration and TypeScript module-resolution changes.

#### CLI argument validation

`vp staged`, `vp config`, `vp hooks`, `vp migrate`, and `vp create` now
reject unsupported options and extra positional arguments
([#2523](#2523)), by
@fengmk2.

Remove unsupported arguments from scripts. For example, replace `vp
config --hooks-only` with `vp config --no-agent`.

### Highlights

- Fix TanStack Start HTTP `404` responses caused by separate Vite
runtime copies
([#2617](#2617)), by
@fengmk2.
- Reduce the Windows `vp-shim.exe` size from `214 KiB` to `14 KiB`
([#2466](#2466)), by
@fengmk2.
- Add `vp check --quiet` to hide lint warning diagnostics while
retaining errors and summary counts
([#2593](#2593)), by
@RSS1102.

### Features

- Add `vp sync-versions --json` so automation can request dependency
alignment plans from manifest snapshots without changing project files
([#2600](#2600)), by
@afonsojramos.
- Make `vp create --git` suggest an initial commit command after Git
initialization
([#2581](#2581)), by
@fengmk2.
- Make `vp migrate` replace frozen `voidzero-dev/setup-vp@v1` workflow
references with the supported version pin
([#2540](#2540)), by
@fengmk2.
- Upgrade `rolldown` from `1.2.5` to `1.2.7`, `tsdown` from `0.22.14` to
`0.23.0`, and Oxc from `0.146.0` to `0.148.0`. Upgrade `oxlint` from
`1.79.0` to `1.81.0` and `oxfmt` from `0.64.0` to `0.66.0`. These
versions can flag code that passed before. Run `vp fmt` after upgrading
if CI runs `vp check`
([#2580](#2580),
[#2613](#2613)), by
@voidzero-guard[bot].

### Fixes & Enhancements

- Resolve package-manager versions without rewriting `package.json`. Use
`vp env pin` or `vp env unpin` to change project declarations explicitly
([#2399](#2399)), by
@liangmiQwQ.
- Let `vp migrate` repair stale `vitest` aliases that previously
prevented the CLI from starting
([#2605](#2605)), by
@fengmk2.
- Keep Vite DevTools within the version ranges supported by the bundled
Vite ([#2559](#2559)), by
@fengmk2.
- Keep automatic Vitest upgrades on the supported `4.x` major
([#2612](#2612)), by
@fengmk2.
- Remove a deprecated `tsdown` option from the prompts package build
([#2597](#2597)), by
@jong-kyung.

### Refactor

- Use the updated `which` dependency to resolve relative `PATH` entries
([#2583](#2583)), by
@RSS1102.
- Remove the unused `async-trait` annotation from `JsRuntimeProvider`
([#2538](#2538)), by
@jong-kyung.

### Docs

- Add Azure Pipelines setup instructions
([#2553](#2553)), by
@naokihaba.
- Correct Zed Oxc formatter settings and include JSX and TSX
([#2592](#2592)), by
@joschuba.
- Add Wrangler deployment configuration for the documentation site
([#2596](#2596)), by
@mdong1909.
- Explain conflicts between pnpm and Vite+ runtime management, including
the `runtimeOnFail` setting
([#2620](#2620)), by
@liangmiQwQ.

### Chore

- Run CLI snapshots without published release packages
([#2625](#2625)), by
@fengmk2.
- Update the release-manager skill with package-install checks,
changelog guidance, and announcement handling
([#2548](#2548)), by
@fengmk2.
- Wait for npm dependencies to become available before publishing
dependent release packages
([#2601](#2601)), by
@fengmk2.
- Remove old Docker preview images
([#2539](#2539)), by
@fengmk2.
- Stabilize external-tool snapshots and isolate npm network cases
([#2577](#2577),
[#2604](#2604)), by
@fengmk2.
- Avoid unreliable Fish PPA setup in CI
([#2560](#2560)), by
@fengmk2.
- Update the `vinext` fixture to an upstream fix
([#2571](#2571)), by
@jong-kyung.
- Stabilize the pnpm snapshot and Nuxt build in CI
([#2591](#2591)), by
@voidzero-guard[bot].
- Pin pnpm in project-creation build-approval fixtures
([#2616](#2616)), by
@liangmiQwQ.
- Remove unused documentation components, assets, and the typewriter
dependency
([#2550](#2550),
[#2562](#2562)), by
@jong-kyung.
- Remove duplicate `tempfile` dependencies, an unused runtime helper,
and unused error variants. Update the `unit_bindings` lint name
([#2555](#2555),
[#2558](#2558),
[#2566](#2566),
[#2567](#2567)), by
@jong-kyung.
- Update GitHub Actions dependencies, including `actions/setup-node`
`v7` ([#2544](#2544),
[#2545](#2545),
[#2582](#2582),
[#2618](#2618)), by
@renovate[bot].
- Update `crate-ci/typos` through `v1.50.1`
([#2584](#2584),
[#2589](#2589),
[#2609](#2609)), by
@renovate[bot].
- Update repository pnpm to `11.24.0`
([#2590](#2590)), by
@renovate[bot].
- Update `voidzero-dev/setup-vp` to `v1.19.0`
([#2619](#2619)), by
@renovate[bot].

### Bundled Versions

| Tool | Version | Source |
| --- | --- | --- |
| `vite` | `8.2.2` |
[`de1111a`](vitejs/vite@de1111a)
|
| `rolldown` | `1.2.7` |
[`26b4c6e`](rolldown/rolldown@26b4c6e)
|
| `tsdown` | `0.23.0` | [npm](https://npmx.dev/package/tsdown/v/0.23.0)
|
| `vitest` | `4.1.11` | [npm](https://npmx.dev/package/vitest/v/4.1.11)
|
| `oxlint` | `1.81.0` | [npm](https://npmx.dev/package/oxlint/v/1.81.0)
|
| `oxlint-tsgolint` | `7.0.2001` |
[npm](https://npmx.dev/package/oxlint-tsgolint/v/7.0.2001) |
| `oxfmt` | `0.66.0` | [npm](https://npmx.dev/package/oxfmt/v/0.66.0) |

### Upgrade

```bash
vp upgrade
```

### New Contributors

@afonsojramos, @joschuba

**Full Changelog**:
v0.3.0...v0.3.1

---

Merging this PR will trigger the release workflow.

---------

Co-authored-by: voidzero-guard[bot] <278573678+voidzero-guard[bot]@users.noreply.github.com>
Co-authored-by: MK (fengmk2) <fengmk2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview-build Publish this PR's commits to the registry bridge as preview builds 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.

2 participants