-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] GraalVM Native Image support (Experimental). #11365
Changes from 19 commits
e2ad8fb
7982230
9211ae3
0ab6b79
fb4cd26
46443b5
b5fad86
617d4cb
094e4ab
44e47ce
1f8df26
3338207
da3d1c3
ec6dc79
bfaf1dc
94bb2a5
d27fc18
1ad623f
20447ef
b99f565
6517a67
615b3a6
799f9bd
a7036b5
2501791
4df1860
2ab226f
6e11010
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,16 @@ | |||||
name: GraalVM Community Edition build | ||||||
on: | ||||||
pull_request: | ||||||
push: | ||||||
|
||||||
concurrency: | ||||||
group: skywalking-${{ github.event.pull_request.number || github.ref }} | ||||||
cancel-in-progress: true | ||||||
|
||||||
env: | ||||||
SW_AGENT_JDK_VERSION: 8 | ||||||
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 | ||||||
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 5 # Cache restore timeout | ||||||
jobs: | ||||||
build: | ||||||
runs-on: ubuntu-latest | ||||||
|
@@ -31,10 +41,69 @@ jobs: | |||||
components: 'native-image' | ||||||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||||||
- name: Native Compile | ||||||
env: | ||||||
SW_OAL_ENGINE_DEBUG: true | ||||||
run: | | ||||||
./mvnw -Pbackend,native clean package -Dmaven.test.skip | ||||||
- uses: actions/upload-artifact@v3 | ||||||
name: Upload distribution tar | ||||||
with: | ||||||
name: native-pre-dist | ||||||
path: distribution/graal/dist | ||||||
path: graal/dist | ||||||
- name: Build and save docker images | ||||||
run: | | ||||||
make -f graal/Makefile docker.oap || make -f graal/Makefile docker.oap | ||||||
docker save -o docker-images-skywalking-oap.tar skywalking/oap:latest | ||||||
- name: Upload docker images | ||||||
uses: actions/upload-artifact@v3 | ||||||
with: | ||||||
name: docker-images-native | ||||||
path: docker-images-skywalking-*.tar | ||||||
e2e-test: | ||||||
if: | | ||||||
always() && ! cancelled() | ||||||
name: E2E test | ||||||
needs: [build] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
runs-on: ${{ 'ubuntu-latest' }} | ||||||
timeout-minutes: 60 | ||||||
strategy: | ||||||
fail-fast: false | ||||||
matrix: | ||||||
test: | ||||||
- name: Graal Docker Image | ||||||
config: test/e2e-v2/cases/python/e2e.yaml | ||||||
steps: | ||||||
- uses: actions/checkout@v3 | ||||||
with: | ||||||
submodules: true | ||||||
- uses: actions/download-artifact@v3 | ||||||
name: Download docker images | ||||||
with: | ||||||
name: docker-images-native | ||||||
path: docker-images | ||||||
- name: Load docker images | ||||||
run: | | ||||||
find docker-images -name "*.tar" -exec docker load -i {} \; | ||||||
find docker-images -name "*.tar" -exec rm {} \; | ||||||
- name: Cache maven repository | ||||||
uses: actions/cache@v3 | ||||||
with: | ||||||
path: ~/.m2/repository | ||||||
key: ${{ runner.os }}-maven-${{ hashFiles('test/e2e-v2/java-test-service/**/pom.xml') }} | ||||||
restore-keys: ${{ runner.os }}-maven- | ||||||
- name: Prepare test services | ||||||
shell: bash | ||||||
run: ./mvnw -B -q -f test/e2e-v2/java-test-service/pom.xml clean package | ||||||
- name: Set env var | ||||||
run: | | ||||||
echo "${{ matrix.test.env }}" >> $GITHUB_ENV | ||||||
- name: ${{ matrix.test.name }} | ||||||
uses: apache/skywalking-infra-e2e@0a5b398fc9668ccb848b16e6da4f09180955dc3e | ||||||
with: | ||||||
e2e-file: $GITHUB_WORKSPACE/${{ matrix.test.config }} | ||||||
- uses: actions/upload-artifact@v2 | ||||||
if: ${{ failure() }} | ||||||
name: Upload Logs | ||||||
with: | ||||||
name: logs | ||||||
path: "${{ env.SW_INFRA_E2E_LOG_DIR }}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ The native-image compilation is not enabled by default. To enable it, we need to | |
|
||
``` | ||
|
||
Then, 2 packages are in `distribution/graal/dist`, | ||
Then, 2 packages are in `graal/dist`, | ||
As this is an experimental feature, a package named `apache-skywalking-apm-native-pre-bin.tar.gz` is a tarball for GraalVMization friendly, including original classes to be compiled by GraalVM. | ||
The package named `apache-skywalking-apm-native-bin.tar.gz` includes the final compiled native binary, relative configuration files, and booting shells. Read `Package Structure` doc for more details. | ||
|
||
|
@@ -46,4 +46,12 @@ we can successfully start SkyWalking-oap. | |
With native-image, some features are not yet supported. | ||
|
||
1. [LAL](https://skywalking.apache.org/docs/main/next/en/concepts-and-designs/lal/), [MAL](https://skywalking.apache.org/docs/main/next/en/concepts-and-designs/mal/), and some other features related to them are not supported at the moment. | ||
2. The [OAL](https://skywalking.apache.org/docs/main/next/en/concepts-and-designs/oal/) files are used in the compiling stage, which means that users would not see these files inside the native image package, and can't change it. Consider recompiling and packaging from the source codes including your OAL file changes. | ||
2. The [OAL](https://skywalking.apache.org/docs/main/next/en/concepts-and-designs/oal/) files are used in the compiling stage, which means that users would not see these files inside the native image package, and can't change it. Consider recompiling and packaging from the source codes including your OAL file changes. | ||
|
||
## Current Limitations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The path you are using here should use the relative path. The website compiling could translate it to the correct path binding in the version(commit ID). |
||
Native-image supports reflection and other dynamic features through some JSON-formatted configuration files. SkyWalking currently provides a set of configuration files for basic support. You can find them [here](https://github.com/apache/skywalking/tree/master/graal/graal-server-starter/src/main/resources/META-INF/native-image). | ||
|
||
For now, these configuration files do not support all runtime environments (but will be fully supported in the future). Therefore, in other environments, users may need to generate the configuration files required by native-image on their own. | ||
|
||
SkyWalking uses [native build tools](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html) to generate native-image. Additionally, GraalVM provides an agent to assist in generating configuration files. Therefore, users can generate the required configuration files by referring to [native build tools agent guide](https://graalvm.github.io/native-build-tools/latest/maven-plugin.html#agent-support). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
SHELL := /bin/bash -o pipefail | ||
|
||
SW_GRAAL_ROOT := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | ||
CONTEXT = ${SW_GRAAL_ROOT}/dist | ||
DIST ?= apache-skywalking-apm-native-bin.tar.gz | ||
CLI_VERSION ?= 0.12.0 # CLI version inside OAP image should always use an Apache released artifact. | ||
|
||
HUB ?= skywalking | ||
|
||
TAG ?= latest | ||
|
||
DOCKER_BUILD_TOP:=${CONTEXT}/docker_build | ||
|
||
NAME := oap | ||
|
||
LOAD_OR_PUSH = --load | ||
|
||
BUILD_ARGS := $(BUILD_ARGS) --build-arg DIST=$(DIST) --build-arg SKYWALKING_CLI_VERSION=$(CLI_VERSION) | ||
|
||
docker.% push.docker.%: $(CONTEXT)/$(DIST) $(SW_GRAAL_ROOT)/docker/%/* | ||
$(DOCKER_RULE) | ||
|
||
define DOCKER_RULE | ||
mkdir -p $(DOCKER_BUILD_TOP)/$(NAME) | ||
cp -r $^ $(DOCKER_BUILD_TOP)/$(NAME) | ||
docker buildx create --use --driver docker-container --name skywalking_main > /dev/null 2>&1 || true | ||
docker buildx build $(PLATFORMS) $(LOAD_OR_PUSH) \ | ||
--no-cache $(BUILD_ARGS) \ | ||
-t $(HUB)/$(NAME):$(TAG) \ | ||
-t $(HUB)/$(NAME):latest \ | ||
$(DOCKER_BUILD_TOP)/$(NAME) | ||
docker buildx rm skywalking_main || true | ||
endef |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<!-- | ||
~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
~ contributor license agreements. See the NOTICE file distributed with | ||
~ this work for additional information regarding copyright ownership. | ||
~ The ASF licenses this file to You under the Apache License, Version 2.0 | ||
~ (the "License"); you may not use this file except in compliance with | ||
~ the License. You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
~ | ||
--> | ||
|
||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> | ||
<id>dist</id> | ||
<formats> | ||
<format>tar.gz</format> | ||
</formats> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.basedir}/../../dist-material</directory> | ||
<outputDirectory>config</outputDirectory> | ||
<includes> | ||
<include>log4j2.xml</include> | ||
<include>alarm-settings.yml</include> | ||
</includes> | ||
</fileSet> | ||
<fileSet> | ||
<directory>${project.basedir}/../../dist-material</directory> | ||
<outputDirectory/> | ||
<includes> | ||
<include>config-examples/*</include> | ||
</includes> | ||
</fileSet> | ||
<fileSet> | ||
<directory>${project.basedir}/../../oap-server/server-starter/src/main/resources</directory> | ||
<includes> | ||
<include>component-libraries.yml</include> | ||
<include>gateways.yml</include> | ||
<include>service-apdex-threshold.yml</include> | ||
<include>endpoint-name-grouping.yml</include> | ||
<include>metadata-service-mapping.yaml</include> | ||
<include>trace-sampling-policy-settings.yml</include> | ||
<include>oal/*.oal</include> | ||
<include>fetcher-prom-rules/*.yaml</include> | ||
<include>envoy-metrics-rules/**</include> | ||
<include>meter-analyzer-config/*.yaml</include> | ||
<include>zabbix-rules/*.yaml</include> | ||
<include>openapi-definitions/*/*.yaml</include> | ||
<include>otel-rules/**</include> | ||
<include>ui-initialized-templates/*/*.json</include> | ||
<include>ui-initialized-templates/menu.yaml</include> | ||
<include>lal/*</include> | ||
<include>log-mal-rules/**</include> | ||
<include>telegraf-rules/*</include> | ||
</includes> | ||
<outputDirectory>config</outputDirectory> | ||
</fileSet> | ||
|
||
<!-- data generator --> | ||
<fileSet> | ||
<directory>${project.basedir}/../../oap-server/server-tools/data-generator/target/</directory> | ||
<includes> | ||
<include>data-generator-${project.version}.jar</include> | ||
</includes> | ||
<outputDirectory>oap-libs</outputDirectory> | ||
</fileSet> | ||
<fileSet> | ||
<directory>${project.basedir}/../../oap-server/server-tools/data-generator/src/main/assembly/bin</directory> | ||
<outputDirectory>tools/data-generator/bin</outputDirectory> | ||
<includes> | ||
<include>*.sh</include> | ||
</includes> | ||
<fileMode>0755</fileMode> | ||
</fileSet> | ||
<fileSet> | ||
<directory>${project.basedir}/../../oap-server/server-tools/data-generator/src/main/resources</directory> | ||
<outputDirectory>tools/data-generator/config</outputDirectory> | ||
<includes> | ||
<include>application.yml</include> | ||
</includes> | ||
</fileSet> | ||
<!-- data generator --> | ||
|
||
<!-- Profile exporter tools --> | ||
<fileSet> | ||
<directory>${project.basedir}/../../tools/profile-exporter</directory> | ||
<outputDirectory>tools/profile-exporter</outputDirectory> | ||
</fileSet> | ||
|
||
<fileSet> | ||
<directory>${project.basedir}/../../dist-material/release-docs</directory> | ||
<outputDirectory/> | ||
</fileSet> | ||
</fileSets> | ||
<files> | ||
<file> | ||
<source>${project.basedir}/../graal-server-starter/src/main/resources/application.yml</source> | ||
<outputDirectory>config</outputDirectory> | ||
<fileMode>0644</fileMode> | ||
</file> | ||
<file> | ||
<source>${project.basedir}/../dist-material/bin/oapService-native.sh</source> | ||
<outputDirectory>bin</outputDirectory> | ||
<fileMode>0755</fileMode> | ||
</file> | ||
<file> | ||
<source>${project.basedir}/../graal-server-starter/target/skywalking-oap-native</source> | ||
<outputDirectory>image</outputDirectory> | ||
<fileMode>0755</fileMode> | ||
</file> | ||
</files> | ||
</assembly> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.