| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Two wall-clock optimizations on the JDK install path. `tc.cacheDir` recursively copies the extracted tree into RUNNER_TOOL_CACHE, so a 200-600MB JDK is written to disk twice. The extraction directory and the tool-cache normally share a filesystem, so `cacheJdkDir` renames it instead and writes the `.complete` marker itself, mirroring the destination layout `tc.cacheDir` produces. It falls back to the copy when the tool-cache location is unknown, when the source is not a real directory (a symlinked source would otherwise leave a dangling entry once RUNNER_TEMP is cleaned), or when the rename fails - a cross-device tool-cache, or anti-virus holding a handle on Windows. The rename is atomic, so the source is still intact for the fallback. Extraction now uses `pigz` for tarballs when the runner provides it, and Windows zips go through the bundled `tar.exe` rather than `tc.extractZip`, which shells out to PowerShell's much slower `Expand-Archive`. Both fall back to the stock extraction and clean up the abandoned directory first. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b76d8cb0-f629-46e1-bf9a-ffde06948644
There was a problem hiding this comment.
This PR optimizes the JDK installation path in setup-java to reduce redundant disk I/O on cache misses by (1) moving extracted JDK directories into the GitHub Actions tool-cache instead of recursively copying them, and (2) speeding up archive extraction using faster tools when available (pigz for .tar.gz, tar.exe for Windows .zip).
Changes:
| File | Description |
|---|---|
| src/util.ts | Introduces cacheJdkDir (move-based tool-cache) and faster extraction paths for tar.gz/zip with fallbacks. |
| src/distributions/*/installer.ts | Switches distribution installers from tc.cacheDir to cacheJdkDir to avoid copy-based caching. |
| tests/util-install.test.ts | Adds tests covering move semantics, .complete marker behavior, and extraction fast-path fallbacks/cleanup. |
| dist/setup/, dist/cleanup/ | Updates compiled/bundled output to reflect the new util logic and installer wiring. |
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Description:
Installing a JDK writes it to disk twice. Every distribution extracts the archive into RUNNER_TEMP and then calls tc.cacheDir, which recursively copies the whole tree into RUNNER_TOOL_CACHE. For a 200-600MB JDK that is a few hundred megabytes of pure redundant I/O on every cache miss, and it is the single most expensive step in the install path - considerably more than the vendor metadata requests people usually suspect.
This PR addresses that, plus the extraction step next to it.
1. Move instead of copy (cacheJdkDir)
New helper in src/util.ts, replacing tc.cacheDir at all 15 distribution installers. The extraction directory and the tool-cache normally live on the same filesystem, so the copy can just be a fs.renameSync. The helper mirrors the destination layout tc.cacheDir produces exactly (including semver.clean(version) || version and the arch default) and writes the .complete marker itself, so tc.findAllVersions / findInToolcache keep resolving entries unchanged.
It falls back to the original tc.cacheDir copy when:
2. Faster extraction
extractJdkFile now hands tarball decompression to pigz when the runner provides it, and extracts Windows zips with the bundled %SystemRoot%\System32\tar.exe instead of tc.extractZip, which shells out to PowerShell's Expand-Archive (typically several times slower for a JDK-sized archive). Both paths fall back to the stock extraction, cleaning up the abandoned directory first so a failure does not double peak temp usage.
Worth a careful look:
Related issue:
N/A
Check list:
Tests: 20 new cases in __tests__/util-install.test.ts covering the move, marker creation, replacing an existing entry, version/arch normalization parity with tc.cacheDir, and each fallback path (missing tool-cache root, symlinked source, rename failure with no stale marker left behind, pigz failure and cleanup, whitespace in the pigz path, Windows tar.exe failure and cleanup). Full suite is 1272 passing.