Here is my current workflow. I want to try in matrix different methods of optimization to compare what will be faster. Here methods i want to try, you need make a plan how to make this large workflow:
Build Performance
Building the JDK requires a lot of horsepower. Some of the build tools can be adjusted to utilize more or less of resources such as parallel threads and memory. The configure script analyzes your system and selects reasonable values for such options based on your hardware. If you encounter resource problems, such as out of memory conditions, you can modify the detected values with:
--with-num-cores -- number of cores in the build system, e.g. --with-num-cores=8.
--with-memory-size -- memory (in MB) available in the build system, e.g. --with-memory-size=1024
You can also specify directly the number of build jobs to use with --with-jobs=N to configure, or JOBS=N to make. Do not use the -j flag to make. In most cases it will be ignored by the makefiles, but it can cause problems for some make targets.
It might also be necessary to specify the JVM arguments passed to the Boot JDK, using e.g. --with-boot-jdk-jvmargs="-Xmx8G". Doing so will override the default JVM arguments passed to the Boot JDK.
At the end of a successful execution of configure, you will get a performance summary, indicating how well the build will perform. Here you will also get performance hints. If you want to build fast, pay attention to those!
If you want to tweak build performance, run with make LOG=info to get a build time summary at the end of the build process.
Disk Speed
If you are using network shares, e.g. via NFS, for your source code, make sure the build directory is situated on local disk (e.g. by ln -s /localdisk/jdk-build $JDK-SHARE/build). The performance penalty is extremely high for building on a network share; close to unusable.
Also, make sure that your build tools (including Boot JDK and toolchain) is located on a local disk and not a network share.
As has been stressed elsewhere, do use SSD for source code and build directory, as well as (if possible) the build tools.
Virus Checking
The use of virus checking software, especially on Windows, can significantly slow down building of the JDK. If possible, turn off such software, or exclude the directory containing the JDK source code from on-the-fly checking.
Precompiled Headers
By default, the Hotspot build uses pre-compiled headers (PCH) on the toolchains were it is properly supported (clang, gcc, and Visual Studio). Normally, this speeds up the build process, but in some circumstances, it can actually slow things down.
You can experiment by disabling pre-compiled headers using --disable-precompiled-headers.
Using the javac Server
To speed up compilation of Java code, especially during incremental compilations, the javac server is automatically enabled in the configuration step by default. To explicitly enable or disable the javac server, use either --enable-javac-server or --disable-javac-server.
Building the Right Target
Selecting the proper target to build can have dramatic impact on build time. For normal usage, jdk or the default target is just fine. You only need to build images for shipping, or if your tests require it.
See also Using Fine-Grained Make Targets on how to build an even smaller subset of the product.
name: Build Corretto 21 lilliput-2 Msys2 edition
on:
schedule:
- cron: '0 5 * * 1'
workflow_dispatch:
env:
UPSTREAM_REPO: corretto/corretto-21
UPSTREAM_BRANCH: lilliput-2
GITHUB_VARIABLE_NAME: LAST_BUILT_CORRETTO_LILLIPUT_SHA
CORRETTO_SOURCE_DIR: corretto_source_checkout
MSYS2_PACKAGES: >-
base-devel
unzip
zip
autoconf
automake
mingw-w64-x86_64-toolchain
jobs:
build_if_new_commits:
runs-on: windows-2022
permissions:
contents: read
actions: read
steps:
- name: Read Last Built Upstream SHA
id: read_last_sha
run: |
$sha_from_var = "${{ vars[env.GITHUB_VARIABLE_NAME] || '' }}"
echo "last_sha=$sha_from_var" >> $GITHUB_OUTPUT
shell: pwsh
- name: Checkout upstream repository
id: checkout_upstream
uses: actions/checkout@v4
with:
repository: ${{ env.UPSTREAM_REPO }}
ref: ${{ env.UPSTREAM_BRANCH }}
fetch-depth: 1
path: ${{ env.CORRETTO_SOURCE_DIR }}
- name: Get Current Upstream SHA
id: get_upstream_sha
working-directory: ${{ env.CORRETTO_SOURCE_DIR }}
run: |
$current_sha = (git rev-parse HEAD).Trim()
echo "sha=$current_sha" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Determine if Build is Needed
id: check_build_condition
run: |
$needs_build_ps_var = "false"
if ("${{ github.event_name }}" -eq "workflow_dispatch" || "${{ steps.read_last_sha.outputs.last_sha }}" -ne "${{ steps.get_upstream_sha.outputs.sha }}") {
$needs_build_ps_var = "true"
}
echo "needs_build=$needs_build_ps_var" >> $env:GITHUB_OUTPUT
shell: pwsh
- name: Update GitHub Repository Variable with PAT
if: steps.check_build_condition.outputs.needs_build == 'true'
env:
NEW_SHA_TO_SAVE: ${{ steps.get_upstream_sha.outputs.sha }}
GH_TOKEN: ${{ secrets.MY_PAT }}
run: |
gh variable set "${{ env.GITHUB_VARIABLE_NAME }}" --body "${NEW_SHA_TO_SAVE}" --repo "${{ github.repository }}"
shell: bash
- name: Set up Corretto 21 as Bootstrap JDK
if: steps.check_build_condition.outputs.needs_build == 'true'
uses: actions/setup-java@v4
with:
distribution: 'corretto'
java-version: '21'
- name: Set up MSYS2
if: steps.check_build_condition.outputs.needs_build == 'true'
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: true
install: ${{ env.MSYS2_PACKAGES }}
- name: Configure Corretto Build
if: steps.check_build_condition.outputs.needs_build == 'true'
working-directory: ${{ env.CORRETTO_SOURCE_DIR }}
shell: msys2 {0}
run: |
BOOT_JDK_MSYS=$(cygpath -u "$JAVA_HOME")
./configure --with-boot-jdk="$BOOT_JDK_MSYS" \
--disable-warnings-as-errors \
--with-debug-level=release
- name: Build Corretto (make images)
if: steps.check_build_condition.outputs.needs_build == 'true'
working-directory: ${{ env.CORRETTO_SOURCE_DIR }}
shell: msys2 {0}
run: |
make JOBS=$(nproc) images
- name: Clean Debug Symbols from JDK Image
if: steps.check_build_condition.outputs.needs_build == 'true'
working-directory: ${{ env.CORRETTO_SOURCE_DIR }}
shell: pwsh
run: |
$jdkImagePath = Get-ChildItem -Path "build\*\images\jdk" -Directory | Select-Object -First 1 -ExpandProperty FullName
if ($jdkImagePath) { Get-ChildItem -Path $jdkImagePath -Recurse -Include "*.pdb", "*.map" | Remove-Item -Force -EA SilentlyContinue }
- name: Prepare Artifact Structure
if: steps.check_build_condition.outputs.needs_build == 'true'
id: prepare_artifact
working-directory: ${{ env.CORRETTO_SOURCE_DIR }}
shell: pwsh
run: |
$jdkSourcePath = Get-ChildItem -Path "build\*\images\jdk" -Directory | Select-Object -First 1 -ExpandProperty FullName
$releaseFile = Join-Path $jdkSourcePath "release"
$releaseContent = Get-Content $releaseFile -Raw | ConvertFrom-StringData -Delimiter '='
$javaVersion = $releaseContent.JAVA_VERSION.Trim('"')
echo "JAVA_VERSION_EXTRACTED=$javaVersion" >> $GITHUB_OUTPUT
$stagingDir = Join-Path $env:GITHUB_WORKSPACE "staging_artifact"
$targetDirName = "corretto-21-lilliput-${javaVersion}"
$fullTargetPathInStaging = Join-Path $stagingDir $targetDirName
if (Test-Path $stagingDir) { Remove-Item -Recurse -Force $stagingDir }
New-Item -ItemType Directory -Path $fullTargetPathInStaging | Out-Null
Move-Item -Path (Join-Path $jdkSourcePath "*") -Destination $fullTargetPathInStaging -Force
- name: Upload Windows JDK Build Artifact
if: steps.check_build_condition.outputs.needs_build == 'true'
uses: actions/upload-artifact@v4
with:
name: corretto-21-lilliput-${{ steps.prepare_artifact.outputs.JAVA_VERSION_EXTRACTED }}-windows-x64-jdk
path: staging_artifact/