Skip to content

Commit 48c64d8

Browse files
Merge with master.
2 parents 0fc07e2 + 2cf43e5 commit 48c64d8

File tree

65 files changed

+1251
-740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1251
-740
lines changed

.github/workflows/micronaut.yml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#
2+
# Copyright (c) 2024, 2024, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# The Universal Permissive License (UPL), Version 1.0
6+
#
7+
# Subject to the condition set forth below, permission is hereby granted to any
8+
# person obtaining a copy of this software, associated documentation and/or
9+
# data (collectively the "Software"), free of charge and under any and all
10+
# copyright rights in the Software, and any and all patent rights owned or
11+
# freely licensable by each licensor hereunder covering either (i) the
12+
# unmodified Software as contributed to or provided by such licensor, or (ii)
13+
# the Larger Works (as defined below), to deal in both
14+
#
15+
# (a) the Software, and
16+
#
17+
# (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
18+
# one is included with the Software each a "Larger Work" to which the Software
19+
# is contributed by such licensors),
20+
#
21+
# without restriction, including without limitation the rights to copy, create
22+
# derivative works of, display, perform, and distribute the Software and make,
23+
# use, sell, offer for sale, import, export, have made, and have sold the
24+
# Software and the Larger Work(s), and to sublicense the foregoing rights on
25+
# either these or other terms.
26+
#
27+
# This license is subject to the following condition:
28+
#
29+
# The above copyright notice and either this complete permission notice or at a
30+
# minimum a reference to the UPL must be included in all copies or substantial
31+
# portions of the Software.
32+
#
33+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
34+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
35+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
36+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
37+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39+
# SOFTWARE.
40+
#
41+
name: Nightly Micronaut Tests
42+
43+
on:
44+
push:
45+
paths:
46+
- '.github/workflows/micronaut.yml'
47+
pull_request:
48+
paths:
49+
- '.github/workflows/micronaut.yml'
50+
schedule:
51+
- cron: '0 2 * * *'
52+
workflow_dispatch:
53+
54+
env:
55+
GRAALVM_HOME: ${{ github.workspace }}/graalvm
56+
JAVA_HOME: ${{ github.workspace }}/labsjdk
57+
LANG: en_US.UTF-8
58+
MICRONAUT_CORE_PATH: ${{ github.workspace }}/micronaut-core
59+
MICRONAUT_JDK_VERSION: 21
60+
MX_GIT_CACHE: refcache
61+
MX_PATH: ${{ github.workspace }}/mx
62+
MX_PYTHON: python3.8
63+
# Enforce experimental option checking in CI (GR-47922)
64+
NATIVE_IMAGE_EXPERIMENTAL_OPTIONS_ARE_FATAL: "true"
65+
66+
permissions:
67+
contents: read # to fetch code (actions/checkout)
68+
69+
jobs:
70+
build-graalvm-and-micronaut:
71+
name: Native Tests
72+
runs-on: ubuntu-20.04
73+
steps:
74+
- name: Checkout oracle/graal
75+
uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 1
78+
- name: Determine mx version
79+
run: echo "MX_VERSION=$(jq -r '.mx_version' common.json)" >> ${GITHUB_ENV}
80+
- name: Checkout graalvm/mx
81+
uses: actions/checkout@v4
82+
with:
83+
repository: graalvm/mx
84+
fetch-depth: 1
85+
ref: ${{ env.MX_VERSION }}
86+
path: ${{ env.MX_PATH }}
87+
- name: Set up Python
88+
uses: actions/setup-python@v5
89+
with:
90+
python-version: '3.8'
91+
- name: Update mx cache
92+
uses: actions/cache@v3
93+
with:
94+
path: ~/.mx
95+
key: ${{ runner.os }}-mx-${{ hashFiles('**/suite.py') }}
96+
restore-keys: ${{ runner.os }}-mx-
97+
- name: Fetch LabsJDK
98+
run: |
99+
mkdir jdk-dl
100+
${MX_PATH}/mx --java-home= fetch-jdk --jdk-id labsjdk-ce-latest --to jdk-dl --alias ${JAVA_HOME}
101+
- name: Build GraalVM JDK
102+
run: |
103+
cd substratevm
104+
${MX_PATH}/mx --native=native-image --components="Native Image" build
105+
mv $(${MX_PATH}/mx --native=native-image --components="Native Image" graalvm-home) ${GRAALVM_HOME}
106+
${GRAALVM_HOME}/bin/native-image --version
107+
- name: Reconfigure JAVA_HOME for Micronaut
108+
uses: actions/setup-java@v4
109+
with:
110+
distribution: 'oracle'
111+
java-version: '${{ env.MICRONAUT_JDK_VERSION }}'
112+
- name: Run nativeTest in Micronaut launch project
113+
run: |
114+
curl --fail --silent --location --retry 3 --max-time 10 --output demo.zip --request GET 'https://launch.micronaut.io/create/default/com.example.demo?lang=JAVA&build=GRADLE&test=JUNIT&javaVersion=JDK_${{ env.MICRONAUT_JDK_VERSION }}'
115+
unzip demo.zip
116+
cd demo
117+
./gradlew nativeTest
118+
- name: Checkout micronaut-projects/micronaut-core
119+
uses: actions/checkout@v4
120+
with:
121+
repository: micronaut-projects/micronaut-core
122+
fetch-depth: 1
123+
path: ${{ env.MICRONAUT_CORE_PATH }}
124+
- name: Run nativeTest in micronaut-core
125+
run: |
126+
cd ${{ env.MICRONAUT_CORE_PATH }}
127+
./gradlew nativeTest

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Recommendations:
6666
--------------------------------------------------------------------------------
6767
0.8s (4.6% of total time) in 35 GCs | Peak RSS: 1.93GB | CPU load: 9.61
6868
--------------------------------------------------------------------------------
69-
Produced artifacts:
69+
Build artifacts:
7070
/home/janedoe/helloworld/helloworld (executable)
7171
/home/janedoe/helloworld/helloworld.debug (debug_info)
7272
/home/janedoe/helloworld/sources (debug_info)
@@ -341,11 +341,22 @@ If there is enough headroom and the [GC statistics](#glossary-garbage-collection
341341
The CPU time used by the process divided by the total process time.
342342
Increase the number of CPU cores to reduce the time to build the native binary.
343343
344+
## <a name="glossary-build-artifacts"></a>Build Artifacts
345+
346+
The list of all build artifacts.
347+
This includes the generated native binary, but it can also contain other artifacts such as additional libraries, C header files, or debug info.
348+
Some of these artifacts must remain in the same location with the native binary as they are needed at run time.
349+
For applications using AWT, for example, the build process will also output libraries from the JDK and shims to provide compatible AWT support.
350+
These libraries need to be copied and distributed together with the native binary.
351+
Use the `-H:+GenerateBuildArtifactsFile` option to instruct the builder to produce a machine-readable version of the build artifact list in JSON format.
352+
Such a JSON file validates against the JSON schema defined in [`build-artifacts-schema-v0.9.0.json`](https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/assets/build-artifacts-schema-v0.9.0.json).
353+
This schema also contains descriptions for each possible artifact type and explains whether they are needed at run time or not.
354+
344355
## Machine-Readable Build Output
345356
346357
The build output produced by the `native-image` builder is designed for humans, can evolve with new releases, and should thus not be parsed in any way by tools.
347358
Instead, use the `-H:BuildOutputJSONFile=<file.json>` option to instruct the builder to produce machine-readable build output in JSON format that can be used, for example, for building monitoring tools.
348-
The JSON files validate against the JSON schema defined in [`build-output-schema-v0.9.2.json`](https://github.com/oracle/graal/tree/master/docs/reference-manual/native-image/assets/build-output-schema-v0.9.2.json).
359+
Such a JSON file validates against the JSON schema defined in [`build-output-schema-v0.9.2.json`](https://github.com/oracle/graal/tree/master/docs/reference-manual/native-image/assets/build-output-schema-v0.9.2.json).
349360
Note that a JSON file is produced if and only if a build succeeds.
350361
351362
The following example illustrates how this could be used in a CI/CD build pipeline to check that the number of reachable methods does not exceed a certain threshold:

docs/reference-manual/native-image/MemoryManagement.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ Here is a small subset of the options that can be specified when doing performan
164164

165165
```shell
166166
# Build and execute a native image that uses the G1 GC with a region size of 2MB and a maximum pause time goal of 100ms
167-
native-image --gc=G1 -H:G1RegionSize=2m -R:MaxGCPauseMillis=100 HelloWorld
167+
native-image --gc=G1 -H:G1HeapRegionSize=2m -R:MaxGCPauseMillis=100 HelloWorld
168168
./helloworld
169169

170170
# Execute the native image from above and override the maximum pause time goal

docs/reference-manual/native-image/OptimizationsAndPerformance.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,35 @@ permalink: /reference-manual/native-image/optimizations-and-performance/
77

88
# Optimizations and Performance
99

10-
Native Image provides advanced mechanisms to further optimize the generated binary:
10+
Native Image provides different mechanisms that enable users to optimize a generated binary in terms of performance, file size, build time, debuggability, and other metrics.
11+
12+
### Optimization Levels
13+
14+
Similar to `gcc` and `clang`, users can control the optimization level using the `-O` option.
15+
By default, `-O2` is used which aims for a good tradeoff between performance, file size, and build time.
16+
The following table provides an overview of the different optimization levels and explains when they are useful:
17+
18+
| Level | Optimizations | Use Cases |
19+
|:---:|:---:|---|
20+
| `-Ob` | Reduced | Quick build mode: Speeds up builds during development by avoiding time-consuming optimizations. This can also reduce file size sometimes. |
21+
| `-O0` | None | Typically used together with `-g` to improve the debugging experience. |
22+
| `-O1` | Basic | Trades performance for reduced file size and build time. Oracle GraalVM's `-O1` is somewhat comparable to `-O2` in GraalVM Community Edition. |
23+
| `-O2` | Advanced | **Default:** Aims for good performance at a reasonable file size. |
24+
| `-O3` | All | Aims for the best performance at the cost of longer build times. Used automatically by Oracle GraalVM for [PGO builds](guides/optimize-native-executable-with-pgo.md) (`--pgo` option). `-O3` and `-O2` are identical in GraalVM Community Edition. |
25+
26+
### Optimizing for Specific Machines
27+
28+
Native Image provides a `-march` option that works similarly to the ones in `gcc` and `clang`: it enables users to control the set of instructions that the Graal compiler can use when compiling code to native.
29+
By default, Native Image uses [`x86-64-v3` on x64](https://en.wikipedia.org/wiki/X86-64#Microarchitecture_levels){:target="_blank"} and [`armv8-a` on AArch64](https://en.wikipedia.org/wiki/ARM_architecture_family#Cores){:target="_blank"}.
30+
Use `-march=list` to list all available machine types.
31+
If the generated binary is built on the same or similar machine type that it is also deployed on, use `-march=native`.
32+
This option instructs the compiler to use all instructions that it finds available on the machine the binary is generated on.
33+
If the generated binary, on the other hand, is distributed to users with many different, and potentially very old machines, use `-march=compatibility`.
34+
This reduces the set of instructions used by the compiler to a minimum and thus improves the compatibility of the generated binary.
35+
36+
### Additional Features
37+
38+
Native Image provides additional features to further optimize a generated binary:
1139

1240
- Profile-Guided Optimizations (PGO) can provide additional performance gain and higher throughput for most native images. See [Optimize a Native Executable with PGO](guides/optimize-native-executable-with-pgo.md).
1341
- Choosing an appropriate Garbage Collector and tailoring the garbage collection policy can reduce GC times. See [Memory Management](MemoryManagement.md).

docs/reference-manual/native-image/assets/build-artifacts-schema-v0.9.0.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"title": "Relative path to file or directory",
1212
"type": "string"
1313
},
14-
"title": "Build information generated by Native Image (not needed at run-time)",
14+
"title": "Build information generated by Native Image (not needed at run time)",
1515
"type": "array"
1616
},
1717
"c_headers": {
@@ -21,7 +21,7 @@
2121
"title": "Relative path to file or directory",
2222
"type": "string"
2323
},
24-
"title": "C header files generated by Native Image (not needed at run-time)",
24+
"title": "C header files generated by Native Image (not needed at run time)",
2525
"type": "array"
2626
},
2727
"debug_info": {
@@ -31,7 +31,7 @@
3131
"title": "Relative path to file or directory",
3232
"type": "string"
3333
},
34-
"title": "Debug information generated by Native Image (not needed at run-time)",
34+
"title": "Debug information generated by Native Image (not needed at run time)",
3535
"type": "array"
3636
},
3737
"executables": {
@@ -41,7 +41,7 @@
4141
"title": "Relative path to file or directory",
4242
"type": "string"
4343
},
44-
"title": "Executables generated by Native Image (needed at run-time)",
44+
"title": "Executables generated by Native Image (needed at run time)",
4545
"type": "array"
4646
},
4747
"import_libraries": {
@@ -51,7 +51,7 @@
5151
"title": "Relative path to file or directory",
5252
"type": "string"
5353
},
54-
"title": "Import libraries generated by Native Image (not needed at run-time)",
54+
"title": "Import libraries generated by Native Image (not needed at run time)",
5555
"type": "array"
5656
},
5757
"jdk_libraries": {
@@ -61,7 +61,7 @@
6161
"title": "Relative path to file or directory",
6262
"type": "string"
6363
},
64-
"title": "JDK libraries copied by Native Image (needed at run-time)",
64+
"title": "JDK libraries copied by Native Image (needed at run time)",
6565
"type": "array"
6666
},
6767
"language_home": {
@@ -71,7 +71,7 @@
7171
"title": "Relative path to file or directory",
7272
"type": "string"
7373
},
74-
"title": "Language home artifacts for Truffle languages (needed at run-time)",
74+
"title": "Language home artifacts for Truffle languages (needed at run time)",
7575
"type": "array"
7676
},
7777
"shared_libraries": {
@@ -81,7 +81,7 @@
8181
"title": "Relative path to file or directory",
8282
"type": "string"
8383
},
84-
"title": "Shared libraries generated by Native Image (not needed at run-time)",
84+
"title": "Shared libraries generated by Native Image (needed at run time)",
8585
"type": "array"
8686
}
8787
},

java-benchmarks/mx.java-benchmarks/mx_java_benchmarks.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,21 +468,33 @@ def extra_image_build_argument(self, benchmark, args):
468468

469469
mx_benchmark.add_bm_suite(BaseQuarkusRegistryBenchmark())
470470

471+
_mushopConfig = {
472+
'order': ['--initialize-at-build-time=io.netty.handler.codec.http.cookie.ServerCookieEncoder,java.sql.DriverInfo,kotlin.coroutines.intrinsics.CoroutineSingletons'],
473+
'user': ['--initialize-at-build-time=io.netty.handler.codec.http.cookie.ServerCookieEncoder,java.sql.DriverInfo'],
474+
'payment': ['--initialize-at-build-time=io.netty.handler.codec.http.cookie.ServerCookieEncoder']
475+
}
476+
471477
class BaseMicronautMuShopBenchmark(BaseMicronautBenchmarkSuite, mx_sdk_benchmark.BaseMicroserviceBenchmarkSuite):
472478
"""
473-
This benchmark suite is NOT yet fully functional - there is not load for measuring its runtime performance.
474-
It is only useful to collect image build time metrics.
479+
This benchmark suite is used to measure the precision and performance of the static analysis in Native Image,
480+
so there is no runtime load, that's why the default stage is just image.
475481
"""
476482

477483
def version(self):
478-
return "0.0.1"
484+
return "0.0.2"
479485

480486
def name(self):
481487
return "mushop"
482488

483489
def benchmarkList(self, bmSuiteArgs):
484490
return ["user", "order", "payment"]
485491

492+
def default_stages(self):
493+
return ['image']
494+
495+
def run(self, benchmarks, bmSuiteArgs):
496+
return self.intercept_run(super(), benchmarks, bmSuiteArgs)
497+
486498
def createCommandLineArgs(self, benchmarks, bmSuiteArgs):
487499
if benchmarks is None:
488500
mx.abort("Suite can only run a single benchmark per VM instance.")
@@ -496,11 +508,11 @@ def applicationDist(self):
496508
return mx.library("MICRONAUT_MUSHOP_" + self.version(), True).get_path(True)
497509

498510
def extra_image_build_argument(self, benchmark, args):
499-
return [
511+
return ([
500512
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.jdk=ALL-UNNAMED',
501513
'--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED',
502-
'--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED'
503-
] + super(BaseMicronautBenchmarkSuite,self).extra_image_build_argument(benchmark, args)
514+
'--add-exports=org.graalvm.nativeimage/org.graalvm.nativeimage.impl=ALL-UNNAMED']
515+
+ _mushopConfig[benchmark] + super(BaseMicronautBenchmarkSuite,self).extra_image_build_argument(benchmark, args))
504516

505517
mx_benchmark.add_bm_suite(BaseMicronautMuShopBenchmark())
506518

java-benchmarks/mx.java-benchmarks/suite.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@
3838
"packedResource": True,
3939
},
4040

41-
"MICRONAUT_MUSHOP_0.0.1" : {
42-
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/mu-shop-0.0.1.zip"],
43-
"digest": "sha512:41f91679c2077a9c252cfc29b8cbf7884f2e9f3c411cfe6c88d807d346178b76299bc5c3f446290b84139ca3a9f6f18c91511fc8ee90b47549b4a8c19cdb337d" ,
41+
"MICRONAUT_MUSHOP_0.0.2" : {
42+
"urls": ["https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/mu-shop-0.0.2.zip"],
43+
"digest": "sha512:e0a503423c1cf94611e9dc14c4d8f06ae25081745b3ebe47b91225c188713537a55c9281a865d1ada364fddaac7d17b90b7da728ccf3975e4d2f584d21bee550" ,
4444
"packedResource": True
4545
},
4646

0 commit comments

Comments
 (0)