Skip to content
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

Merged
merged 28 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e2ad8fb
[Feature] Preliminary support native-image
yswdqz Sep 28, 2023
7982230
[optimize] optimize config file size.
yswdqz Sep 29, 2023
9211ae3
[change] update changes
yswdqz Sep 29, 2023
0ab6b79
test e2e
yswdqz Oct 14, 2023
fb4cd26
[config] add e2e config
yswdqz Oct 19, 2023
46443b5
[config] add e2e config file
yswdqz Oct 19, 2023
b5fad86
[e2e/doc] reduce e2e casees, add docs for native-image configs
yswdqz Oct 19, 2023
617d4cb
[CI] fix native-image args file
yswdqz Oct 19, 2023
094e4ab
[e2e] fix e2e
yswdqz Oct 19, 2023
44e47ce
Merge branch 'master' into native-image-support
yswdqz Oct 19, 2023
1f8df26
[license] add license
yswdqz Oct 20, 2023
3338207
Merge branch 'master' into native-image-support
wu-sheng Oct 20, 2023
da3d1c3
[license] add license
yswdqz Oct 20, 2023
ec6dc79
Merge branch 'native-image-support' of https://github.com/yswdqz/skyw…
yswdqz Oct 20, 2023
bfaf1dc
[Native config] run ut/it by native-tracing-agent to generate configs
yswdqz Oct 28, 2023
94bb2a5
Merge branch 'master' into native-image-support
wu-sheng Oct 29, 2023
d27fc18
[e2e] test python agent e2e
yswdqz Oct 29, 2023
1ad623f
Merge branch 'native-image-support' of https://github.com/yswdqz/skyw…
yswdqz Oct 29, 2023
20447ef
Update NativeConfigFilter.java
yswdqz Oct 29, 2023
b99f565
[Fix] fix error when generate oal classes
yswdqz Oct 29, 2023
6517a67
[Ready] update e2e, optimize IT
yswdqz Oct 29, 2023
615b3a6
[fix] fix docs
yswdqz Oct 29, 2023
799f9bd
[Fix] fix e2e/license
yswdqz Oct 30, 2023
a7036b5
[doc] change doc link to relative path
yswdqz Oct 30, 2023
2501791
[license/doc] add license, fix typo
yswdqz Oct 30, 2023
4df1860
[typo] fix typo
yswdqz Oct 30, 2023
2ab226f
[doc] add graal jdk install docs
yswdqz Oct 30, 2023
6e11010
[typo] fix typo in ci config files
yswdqz Oct 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 70 additions & 1 deletion .github/workflows/native-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
name: GraalVM Community Edition build
on:
pull_request:
push:

concurrency:
group: skywalking-${{ github.event.pull_request.number || github.ref }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
group: skywalking-${{ github.event.pull_request.number || github.ref }}
group: skywalking-graalvm-${{ 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
Expand All @@ -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]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
runs-on: ${{ 'ubuntu-latest' }}
runs-on: ubuntu-latest

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 }}"
1 change: 1 addition & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Add a component ID for Netty-http (ID=151).
* Add a component ID for Fiber (ID=5021).
* BanyanDBStorageClient: Add `define(Property property, PropertyStore.Strategy strategy)` API.
* Support GraalVM native-image (Experimental).

#### UI

Expand Down
12 changes: 10 additions & 2 deletions docs/en/setup/backend/backend-graalvm.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Copy link
Member

Choose a reason for hiding this comment

The 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).

49 changes: 49 additions & 0 deletions graal/Makefile
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
18 changes: 16 additions & 2 deletions graal/apache-skywalking-native-apm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,28 @@
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>dist</id>
<id>dist-native-pre</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>apache-skywalking-apm-native-pre-bin</finalName>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/binary.xml</descriptor>
<descriptor>${project.basedir}/src/main/assembly/binary-native-pre.xml</descriptor>
</descriptors>
</configuration>
</execution>
<execution>
<id>dist-native</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>apache-skywalking-apm-native-bin</finalName>
<descriptors>
<descriptor>${project.basedir}/src/main/assembly/binary-native.xml</descriptor>
</descriptors>
</configuration>
</execution>
Expand All @@ -95,6 +108,7 @@
<configuration>
<target>
<copy file="${project.build.directory}/apache-skywalking-apm-native-pre-bin.tar.gz" tofile="${project.basedir}/../dist/apache-skywalking-apm-native-pre-bin.tar.gz" overwrite="true" />
<copy file="${project.build.directory}/apache-skywalking-apm-native-bin.tar.gz" tofile="${project.basedir}/../dist/apache-skywalking-apm-native-bin.tar.gz" overwrite="true" />
</target>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/../dist-material/bin</directory>
<outputDirectory>bin</outputDirectory>
<includes>
<include>*.sh</include>
<include>*.bat</include>
</includes>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>${project.basedir}/../../dist-material</directory>
<outputDirectory>config</outputDirectory>
Expand Down Expand Up @@ -125,5 +116,10 @@
<outputDirectory>config</outputDirectory>
<fileMode>0644</fileMode>
</file>
<file>
<source>${project.basedir}/../dist-material/bin/oapService-native-jar.sh</source>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</file>
</files>
</assembly>
121 changes: 121 additions & 0 deletions graal/apache-skywalking-native-apm/src/main/assembly/binary-native.xml
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>
2 changes: 0 additions & 2 deletions graal/dist-material/bin/oapService-native-jar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ PRGDIR=$(dirname "$PRG")
OAP_LOG_DIR="${OAP_LOG_DIR:-${OAP_HOME}/logs}"
JAVA_OPTS="${JAVA_OPTS:- -Xms256M -Xmx4096M}"

. ${OAP_HOME}/bin/exportEnv.sh

if [ ! -d "${OAP_LOG_DIR}" ]; then
mkdir -p "${OAP_LOG_DIR}"
fi
Expand Down
Loading
Loading