Repository navigation
Commit 6eb3ef7
authored
perf: cache package managers and use native toolchain setup (#209)
Fresh runners still run a shell installer after a Vite+/Node.js cache
hit and download the project package manager. `cache-toolchain: true`
now caches the selected managed package manager and activates validated
toolchains through the cached CLI.
A temporary copy of the validated CLI performs Vite+'s native setup. It
creates the activation links, configuration, and shims.
`VP_SELF_SETUP_NO_MODIFY_PATH=1` skips persistent shell-profile and user
`PATH` changes. The action exports `PATH` for itself and subsequent
steps through `GITHUB_PATH`. Native activation requires an exact
validated cache hit and no active installation. Failed activation falls
back to the normal installer.
The selected managed `pnpm`, `npm`, `yarn`, or `bun` installation uses a
separate archive. Its key includes the toolchain identity, exact manager
version, and a hash of npm configuration. Configuration files and
credentials stay outside the archive. Existing installations remain
intact; invalid archives fall back to normal installation. Independent
directory and manager queries run together. All cache uploads run in
parallel and follow `cache-save`.
`package-manager-cache-hit` reports the manager archive.
`toolchain-cache-hit` retains its Vite+/Node.js meaning.
### Hosted comparison
The [GitHub Actions
run](https://github.com/voidzero-dev/setup-vp/actions/runs/39234874369)
passed all 57 jobs: three warm-ups and six samples per case on each
platform.
The PR base is
[`c025a93`](c025a93).
Manager caching with shell setup uses
[`f28bb92`](f28bb92).
The optimized implementation is
[`06fe7ec`](06fe7ec).
All cases use fresh runners, the same project checkout, and warm
dependency and Vite+/Node.js archives. Both PR implementations also
restore the same manager archive. Versions are fixed at `Vite+ 1.3.0`,
Node.js `24.22.0`, and `pnpm@12.7.0`. The local `vite-plus` package and
`vite` alias also use `1.3.0`.
Median setup plus post-action time includes `vp install`. All cases use
`cache-save: true` and `sfw: false`.
| Runner | PR base | Before optimization | Optimized | Reduction vs
before | Reduction vs base |
| --- | ---: | ---: | ---: | ---: | ---: |
| Linux x64 | 7 s | 9.5 s | 5.5 s | 42.1% | 21.4% |
| macOS ARM64 | 15.5 s | 18.5 s | 13.5 s | 27.0% | 12.9% |
| Windows x64 | 18 s | 16.5 s | 12 s | 27.3% | 33.3% |
```mermaid
xychart-beta
title "PR 209: median setup + post time"
x-axis ["Linux before", "Linux after", "macOS before", "macOS after", "Windows before", "Windows after"]
y-axis "Seconds — lower is better" 0 --> 30
bar [9.5, 5.5, 18.5, 13.5, 16.5, 12]
```
The chart compares the two PR implementations with manager caching
enabled. All 18 optimized samples used native activation without
installer fallback. All 36 PR samples reported
`package-manager-cache-hit: true`.
### Why cache hits could take more time
A manager archive adds a lookup, transfer, extraction, and executable
check. In the [earlier
run](https://github.com/voidzero-dev/setup-vp/actions/runs/39227680298),
Windows manager restoration took a median `1.18 s` after the cache
match. Dependency-cache discovery saved about `0.91 s`, so archive costs
could exceed that saving.
The earlier Windows totals also included bootstrap variation: `4.57 s`
at the PR base versus `6.19 s` with manager caching. The [shell
installer](https://github.com/voidzero-dev/vite-plus/blob/v1.3.0/packages/cli/install.ps1)
downloads a standalone CLI before native setup, even with a restored
payload. Native setup also [starts PowerShell to update user
PATH](https://github.com/voidzero-dev/vite-plus/blob/v1.3.0/crates/vp_global_cli/src/self_setup/shell.rs).
The optimized cache path removes these operations.
The new run measures this activation phase from toolchain validation to
Node.js configuration:
| Runner | Before optimization | Optimized |
| --- | ---: | ---: |
| Linux x64 | 0.605 s | 0.033 s |
| macOS ARM64 | 0.739 s | 0.056 s |
| Windows x64 | 4.632 s | 0.119 s |
The Windows activation saving is about `4.51 s`. Cache transfer and
runner variation also affect total time. The full Linux and macOS
reductions must not be attributed solely to native activation.
<details>
<summary>Samples, cache storage, and reproduction</summary>
All six samples are in seconds, in sample order:
| Runner | PR base | Before optimization | Optimized |
| --- | --- | --- | --- |
| Linux x64 | 5, 5, 7, 7, 9, 9 | 12, 8, 6, 6, 12, 11 | 7, 5, 6, 6, 4, 5
|
| macOS ARM64 | 18, 21, 13, 16, 10, 15 | 9, 10, 18, 23, 19, 22 | 16, 13,
12, 21, 10, 14 |
| Windows x64 | 23, 21, 17, 16, 16, 19 | 27, 17, 14, 15, 20, 16 | 11,
12, 12, 12, 11, 18 |
GitHub reports step durations in whole seconds; a six-sample median can
include half a second. Phase timings use log timestamps. Measurements
exclude runner startup, checkout, metadata checks, the project build,
and artifact uploads.
The [benchmark
workflow](https://github.com/voidzero-dev/setup-vp/blob/b0b235ae74110b9aa3637fb2762bf71658986cc9/.github/workflows/package-manager-benchmark.yml)
pins all three action commits and the project checkout. It uses isolated
cache paths and records each installation. The analysis checks versions,
binary hashes, lockfile hashes, runner images, and cache outputs. The
benchmark harness stays outside this PR's source diff.
The manager archives use `20.6 MiB` on Linux, `17.8 MiB` on macOS, and
`20.1 MiB` on Windows. One entry per platform totals about `59 MiB`.
</details>1 parent c025a93 commit 6eb3ef7
17 files changed
Lines changed: 935 additions & 131 deletions
File tree
- .github/workflows
- dist
- src
- ci
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | | - | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | | - | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
| 70 | + | |
68 | 71 | | |
69 | 72 | | |
70 | 73 | | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| 93 | + | |
87 | 94 | | |
88 | 95 | | |
89 | 96 | | |
| |||
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
96 | | - | |
| 103 | + | |
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
100 | 107 | | |
101 | | - | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
| |||
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| 126 | + | |
119 | 127 | | |
120 | 128 | | |
121 | 129 | | |
| 130 | + | |
122 | 131 | | |
123 | 132 | | |
124 | 133 | | |
125 | 134 | | |
126 | 135 | | |
| 136 | + | |
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
388 | 389 | | |
389 | 390 | | |
390 | 391 | | |
| |||
406 | 407 | | |
407 | 408 | | |
408 | 409 | | |
409 | | - | |
| 410 | + | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
| |||
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
425 | 429 | | |
426 | 430 | | |
427 | 431 | | |
| |||
432 | 436 | | |
433 | 437 | | |
434 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
435 | 457 | | |
436 | 458 | | |
437 | 459 | | |
| |||
447 | 469 | | |
448 | 470 | | |
449 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
450 | 488 | | |
451 | 489 | | |
452 | | - | |
453 | | - | |
| 490 | + | |
| 491 | + | |
454 | 492 | | |
455 | 493 | | |
456 | 494 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
0 commit comments