Optimize Temurin tool-cache fast path with lazy loading - #1179
Merged
brunoborges merged 4 commits intoJul 29, 2026
Conversation
- Lazy-load distribution installers so only the selected distro module is initialized - Defer cache feature/cache module loading until cache input is provided - Start cache restore early and await it safely alongside Java setup flow - Update orchestration and lazy-loading tests; regenerate dist artifacts Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: cc2c0256-c55e-4a35-a584-5bed7e8b11ad
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes the common Temurin tool-cache-hit path by reducing eager module initialization and introducing concurrency between dependency cache restoration and local Java setup, while preserving deterministic failure behavior. It also regenerates the bundled dist/ output to support dynamic imports/code-splitting and updates tests to validate lazy loading and true overlap.
Changes:
- Make distribution selection lazy by converting the distribution factory to async and dynamically importing only the selected installer.
- Start dependency cache restoration earlier (only when
cacheis configured) and await it before exit while keeping Java/setup errors deterministic. - Add/update unit tests for async distribution resolution, conditional module loading, and concurrent orchestration; regenerate
dist/and update the release staging script.
Show a summary per file
| File | Description |
|---|---|
| src/util.ts | Removes cache feature detection from the shared util module to avoid eager cache dependency loading. |
| src/setup-java.ts | Orchestrates async distribution resolution and overlaps cache restore with setup; awaits in-flight cache work before exit. |
| src/distributions/distribution-factory.ts | Converts factory to async with per-distribution dynamic imports (lazy loading). |
| src/cache-feature.ts | New module encapsulating cache availability checks (lazy-load target). |
| package.json | Updates release script to stage chunked dist/setup/*.js artifacts. |
| dist/setup/index.js | Rebuilt setup entry bundle to support dynamic imports/code splitting. |
| dist/setup/978.index.js | Generated setup bundle chunk (Zulu installer). |
| dist/setup/968.index.js | Generated setup bundle chunk (GraalVM installers). |
| dist/setup/939.index.js | Generated setup bundle chunk (Semeru installer). |
| dist/setup/874.index.js | Generated setup bundle chunk (Adopt + Temurin installers). |
| dist/setup/735.index.js | Generated setup bundle chunk (OpenJDK installer). |
| dist/setup/675.index.js | Generated setup bundle chunk (Dragonwell installer). |
| dist/setup/63.index.js | Generated setup bundle chunk (Liberica installer). |
| dist/setup/557.index.js | Generated setup bundle chunk (SapMachine installer). |
| dist/setup/524.index.js | Generated setup bundle chunk (Liberica NIK installer). |
| dist/setup/463.index.js | Generated setup bundle chunk (Temurin installer). |
| dist/setup/394.index.js | Generated setup bundle chunk (cache feature detection). |
| dist/setup/377.index.js | Generated setup bundle chunk (cache restore/save implementation). |
| dist/setup/282.index.js | Generated setup bundle chunk (JetBrains installer). |
| dist/setup/220.index.js | Generated setup bundle chunk (Microsoft installer). |
| dist/setup/182.index.js | Generated setup bundle chunk (Oracle installer). |
| dist/setup/151.index.js | Generated setup bundle chunk (Kona installer). |
| dist/setup/126.index.js | Generated setup bundle chunk (Corretto installer). |
| dist/setup/19.index.js | Generated setup bundle chunk (Local/jdkfile installer). |
| dist/cleanup/index.js | Rebuilt cleanup bundle to match new build output. |
| tests/util.test.ts | Removes cache feature tests/mocks from util tests (logic moved). |
| tests/setup-java.test.ts | Updates orchestration tests for async factory + concurrent cache restore and deterministic failure handling. |
| tests/setup-java.module-loading.test.ts | New test ensuring cache modules are not imported when cache input is absent. |
| tests/distributors/openjdk-installer.test.ts | Updates factory registration test to await async factory. |
| tests/distributors/graalvm-installer.test.ts | Updates factory mapping test(s) to await async factory. |
| tests/distributors/distribution-factory.test.ts | Updates all factory tests to async/await and rejects assertions. |
| tests/distributors/distribution-factory.lazy-loading.test.ts | New test to ensure non-selected installers aren’t imported on Temurin path. |
| tests/cache-feature.test.ts | New dedicated tests for cache feature detection behavior. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 13/35 changed files
- Comments generated: 2
- Review effort level: Low
- Lazy-load cache save in cleanup path so no-cache runs avoid cache module init in post action - Stage dist/setup/package.json in release script for chunked setup bundle completeness Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: cc2c0256-c55e-4a35-a584-5bed7e8b11ad
Patch is-unsafe's XML comment-close detector during builds so generated bundles recognize both HTML comment end forms and satisfy CodeQL until the dependency publishes a fix. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 277302b1-aa95-4012-817b-9752cdaee14e
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: cc2c0256-c55e-4a35-a584-5bed7e8b11ad
brunoborges
deleted the
brunoborges-optimize-temurin-tool-cache-fast-path
branch
July 29, 2026 21:53
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.
Description:
This change optimizes the high-volume Temurin tool-cache-hit path by reducing eager startup work and overlapping dependency cache restore with local setup work. It does this by lazy-loading only the selected distribution installer, loading cache dependencies only when
cacheis configured, and starting restore early while still awaiting completion before action exit.To preserve behavior and failure semantics, the setup flow now keeps Java/setup failures deterministic while still awaiting any in-flight cache restore to avoid unhandled promise rejections. Tests were updated to cover async distribution resolution, conditional module loading, and true concurrency in orchestration.
The setup bundle was regenerated after introducing dynamic imports. Because the setup output is now chunked, the release staging script was updated to include
dist/setup/*.js.Related issue:
Fixes: #1177
Check list:
npm run checklocally (format, lint, build, test) and all checks pass.