Skip to content

Commit 38baa6d

Browse files
committed
include helloworld micro micro benchmark
1 parent 47d8c50 commit 38baa6d

File tree

11 files changed

+393
-0
lines changed

11 files changed

+393
-0
lines changed

benchmarks/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ described in [UsingCloudObjectStorage.md](UsingCloudObjectStorage.md).
1313
|graph-bfs |Traverse a generated graph in breadth-first order | N |
1414
|graph-mst |Compute minimum spanning tree of a generated graph | N |
1515
|graph-pagerank |Compute page rank scores of a generated graph | N |
16+
|helloworld |A very simple benchmark that creates a string | N |
1617
|image-recognition |Image classification using a deep learning model from Model Zoo| Y |
1718
|network |Repeatedly measure send and receive time of a datagram socket | Y |
1819
|server-reply |Measure time to read a stream socket | N |

benchmarks/helloworld/.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#Maven
2+
target/
3+
pom.xml.tag
4+
pom.xml.releaseBackup
5+
pom.xml.versionsBackup
6+
release.properties
7+
.mvn/
8+
9+
# Eclipse
10+
.project
11+
.classpath
12+
.settings/
13+
bin/
14+
15+
# IntelliJ
16+
.idea
17+
*.ipr
18+
*.iml
19+
*.iws
20+
21+
# NetBeans
22+
nb-configuration.xml
23+
24+
# Visual Studio Code
25+
.vscode
26+
.factorypath
27+
28+
# OSX
29+
.DS_Store
30+
31+
# Vim
32+
*.swp
33+
*.swo
34+
35+
# patch
36+
*.orig
37+
*.rej
38+
39+
# Local environment
40+
.env

benchmarks/helloworld/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# helloworld Project
2+
3+
This is a project to port and test [serverless-benchmarks](https://github.com/spcl/serverless-benchmarks) using Quarkus
4+
[Funqy HTTP Binding](https://quarkus.io/guides/funqy-http), which creates a stand-alone application using serverless functions.
5+
6+
To learn more about Quarkus, please refer to https://quarkus.io/ .
7+
8+
## Packaging and running the application
9+
10+
The application can be packaged using:
11+
```shell script
12+
mvn -Dskiptests clean package
13+
```
14+
This produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
15+
Be aware that this is not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.
16+
17+
The application is runnable using:
18+
```shell script
19+
java -jar target/quarkus-app/quarkus-run.jar
20+
```
21+
22+
The server listens to `localhost:8080`, and functions are accessible at `/<functionName>` path.
23+
Functions with parameters only accept POST requests. Functions without parameters accept both GET and POST requests.
24+
25+
Sample curl command for testing the `/helloworld` function:
26+
```
27+
curl -s -w "\n" -H 'Content-Type:application/json' -d '"test"' -X POST http://localhost:8080/helloworld | jq
28+
```
29+
The result looks like:
30+
```
31+
{
32+
"result": 1
33+
}
34+
```
35+
Valid choices of the test data size are `test`, `small`, and `large`, where the graph sizes are set to `1`, `100`, and `1,000`, respectively.
36+
37+
### Building an über-jar
38+
To build an _über-jar_, execute the following command:
39+
```shell script
40+
mvn package -Dquarkus.package.type=uber-jar
41+
```
42+
43+
The application, packaged as an _über-jar_, is runnable using `java -jar target/*-runner.jar`.
44+
45+
## Creating a native executable
46+
47+
To build a native executable:
48+
```shell script
49+
mvn package -Pnative
50+
```
51+
52+
If GraalVM is not installed, the native executable can be built in a container using:
53+
```shell script
54+
mvn package -Pnative -Dquarkus.native.container-build=true
55+
```
56+
57+
To run the native image: `./target/helloworld-1.0.0-SNAPSHOT-runner`
58+
59+
To learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.
60+

benchmarks/helloworld/pom.xml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
<?xml version="1.0"?>
2+
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>com.ibm.trl</groupId>
7+
<artifactId>benchmarks</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<groupId>com.ibm.trl</groupId>
11+
<artifactId>helloworld</artifactId>
12+
<version>1.0.0-SNAPSHOT</version>
13+
<dependencyManagement>
14+
<dependencies>
15+
<dependency>
16+
<groupId>${quarkus.platform.group-id}</groupId>
17+
<artifactId>${quarkus.platform.artifact-id}</artifactId>
18+
<version>${quarkus.platform.version}</version>
19+
<type>pom</type>
20+
<scope>import</scope>
21+
</dependency>
22+
</dependencies>
23+
</dependencyManagement>
24+
<dependencies>
25+
<dependency>
26+
<groupId>io.quarkus</groupId>
27+
<artifactId>quarkus-funqy-knative-events</artifactId>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.quarkus</groupId>
31+
<artifactId>quarkus-arc</artifactId>
32+
</dependency>
33+
<dependency>
34+
<groupId>io.quarkus</groupId>
35+
<artifactId>quarkus-resteasy-jackson</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>io.quarkus</groupId>
39+
<artifactId>quarkus-container-image-docker</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>io.quarkus</groupId>
43+
<artifactId>quarkus-junit5</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.rest-assured</groupId>
48+
<artifactId>rest-assured</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
</dependencies>
52+
<build>
53+
<plugins>
54+
<plugin>
55+
<groupId>${quarkus.platform.group-id}</groupId>
56+
<artifactId>quarkus-maven-plugin</artifactId>
57+
<version>${quarkus.platform.version}</version>
58+
<extensions>true</extensions>
59+
<executions>
60+
<execution>
61+
<goals>
62+
<goal>build</goal>
63+
<goal>generate-code</goal>
64+
<goal>generate-code-tests</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
<plugin>
70+
<artifactId>maven-compiler-plugin</artifactId>
71+
<version>${compiler-plugin.version}</version>
72+
<configuration>
73+
<parameters>${maven.compiler.parameters}</parameters>
74+
<debug>true</debug>
75+
<debuglevel>lines,vars,source</debuglevel>
76+
</configuration>
77+
</plugin>
78+
<plugin>
79+
<artifactId>maven-surefire-plugin</artifactId>
80+
<version>${surefire-plugin.version}</version>
81+
<configuration>
82+
<systemPropertyVariables>
83+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
84+
<maven.home>${maven.home}</maven.home>
85+
</systemPropertyVariables>
86+
</configuration>
87+
</plugin>
88+
<plugin>
89+
<groupId>com.coderplus.maven.plugins</groupId>
90+
<artifactId>copy-rename-maven-plugin</artifactId>
91+
<version>1.0</version>
92+
<executions>
93+
<execution>
94+
<id>copy-file</id>
95+
<phase>generate-sources</phase>
96+
<goals>
97+
<goal>copy</goal>
98+
</goals>
99+
<configuration>
100+
<fileSets>
101+
<fileSet>
102+
<sourceFile>${java.home}/lib/security/cacerts</sourceFile>
103+
<destinationFile>target/cacerts</destinationFile>
104+
</fileSet>
105+
</fileSets>
106+
</configuration>
107+
</execution>
108+
</executions>
109+
</plugin>
110+
</plugins>
111+
</build>
112+
<profiles>
113+
<profile>
114+
<id>native</id>
115+
<activation>
116+
<property>
117+
<name>native</name>
118+
</property>
119+
</activation>
120+
<build>
121+
<plugins>
122+
<plugin>
123+
<artifactId>maven-failsafe-plugin</artifactId>
124+
<version>${surefire-plugin.version}</version>
125+
<executions>
126+
<execution>
127+
<goals>
128+
<goal>integration-test</goal>
129+
<goal>verify</goal>
130+
</goals>
131+
<configuration>
132+
<systemPropertyVariables>
133+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
134+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
135+
<maven.home>${maven.home}</maven.home>
136+
</systemPropertyVariables>
137+
</configuration>
138+
</execution>
139+
</executions>
140+
</plugin>
141+
</plugins>
142+
</build>
143+
<properties>
144+
<quarkus.package.type>native</quarkus.package.type>
145+
</properties>
146+
</profile>
147+
<profile>
148+
<id>qbicc</id>
149+
<dependencies>
150+
<dependency>
151+
<groupId>org.qbicc.quarkus</groupId>
152+
<artifactId>quarkus-qbicc</artifactId>
153+
</dependency>
154+
</dependencies>
155+
</profile>
156+
</profiles>
157+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3+
###
4+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
5+
6+
ARG JAVA_PACKAGE=java-17-openjdk-headless
7+
ARG RUN_JAVA_VERSION=1.3.8
8+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
9+
# Install java and the run-java script
10+
# Also set up permissions for user `1001`
11+
RUN microdnf --disablerepo='*' --enablerepo='ubi-8-*' install curl ca-certificates ${JAVA_PACKAGE} \
12+
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' update \
13+
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' clean all \
14+
&& mkdir /deployments \
15+
&& chown 1001 /deployments \
16+
&& chmod "g+rwX" /deployments \
17+
&& chown 1001:root /deployments \
18+
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
19+
&& chown 1001 /deployments/run-java.sh \
20+
&& chmod 540 /deployments/run-java.sh \
21+
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
22+
23+
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
24+
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
25+
# We make four distinct layers so if there are application changes the library layers can be re-used
26+
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
27+
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
28+
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
29+
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/
30+
31+
EXPOSE 8080
32+
USER 1001
33+
34+
ENTRYPOINT [ "sh", "-c", "grep 'model name' /proc/cpuinfo | head -1; /deployments/run-java.sh" ]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
3+
###
4+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
5+
6+
ARG JAVA_PACKAGE=java-17-openjdk-headless
7+
ARG RUN_JAVA_VERSION=1.3.8
8+
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
9+
# Install java and the run-java script
10+
# Also set up permissions for user `1001`
11+
RUN microdnf --disablerepo='*' --enablerepo='ubi-8-*' install curl ca-certificates ${JAVA_PACKAGE} \
12+
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' update \
13+
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' clean all \
14+
&& mkdir /deployments \
15+
&& chown 1001 /deployments \
16+
&& chmod "g+rwX" /deployments \
17+
&& chown 1001:root /deployments \
18+
&& curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
19+
&& chown 1001 /deployments/run-java.sh \
20+
&& chmod 540 /deployments/run-java.sh \
21+
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security
22+
23+
# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
24+
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
25+
COPY target/lib/* /deployments/lib/
26+
COPY target/*-runner.jar /deployments/app.jar
27+
28+
EXPOSE 8080
29+
USER 1001
30+
31+
ENTRYPOINT [ "/deployments/run-java.sh" ]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
####
2+
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
3+
###
4+
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
5+
WORKDIR /work/
6+
RUN chown 1001 /work \
7+
&& chmod "g+rwX" /work \
8+
&& chown 1001:root /work
9+
COPY --chown=1001:root target/*-runner /work/application
10+
11+
EXPOSE 8080
12+
USER 1001
13+
14+
ENV JAVA_OPTIONS -Dquarkus.http.host=0.0.0.0
15+
CMD ["sh", "-c", "grep 'model name' /proc/cpuinfo | head -1; ./application ${JAVA_OPTIONS}"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM quay.io/quarkus/quarkus-distroless-image:1.0
2+
COPY target/*-runner /application
3+
4+
EXPOSE 8080
5+
USER nonroot
6+
7+
ENV JAVA_OPTIONS -Dquarkus.http.host=0.0.0.0
8+
CMD ["sh", "-c", "./application ${JAVA_OPTIONS}"]

0 commit comments

Comments
 (0)