Skip to content

Commit

Permalink
include helloworld micro micro benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
trent-s committed Sep 27, 2023
1 parent 47d8c50 commit 38baa6d
Show file tree
Hide file tree
Showing 11 changed files with 393 additions and 0 deletions.
1 change: 1 addition & 0 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ described in [UsingCloudObjectStorage.md](UsingCloudObjectStorage.md).
|graph-bfs |Traverse a generated graph in breadth-first order | N |
|graph-mst |Compute minimum spanning tree of a generated graph | N |
|graph-pagerank |Compute page rank scores of a generated graph | N |
|helloworld |A very simple benchmark that creates a string | N |
|image-recognition |Image classification using a deep learning model from Model Zoo| Y |
|network |Repeatedly measure send and receive time of a datagram socket | Y |
|server-reply |Measure time to read a stream socket | N |
Expand Down
40 changes: 40 additions & 0 deletions benchmarks/helloworld/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.mvn/

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env
60 changes: 60 additions & 0 deletions benchmarks/helloworld/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# helloworld Project

This is a project to port and test [serverless-benchmarks](https://github.com/spcl/serverless-benchmarks) using Quarkus
[Funqy HTTP Binding](https://quarkus.io/guides/funqy-http), which creates a stand-alone application using serverless functions.

To learn more about Quarkus, please refer to https://quarkus.io/ .

## Packaging and running the application

The application can be packaged using:
```shell script
mvn -Dskiptests clean package
```
This produces the `quarkus-run.jar` file in the `target/quarkus-app/` directory.
Be aware that this is not an _über-jar_ as the dependencies are copied into the `target/quarkus-app/lib/` directory.

The application is runnable using:
```shell script
java -jar target/quarkus-app/quarkus-run.jar
```

The server listens to `localhost:8080`, and functions are accessible at `/<functionName>` path.
Functions with parameters only accept POST requests. Functions without parameters accept both GET and POST requests.

Sample curl command for testing the `/helloworld` function:
```
curl -s -w "\n" -H 'Content-Type:application/json' -d '"test"' -X POST http://localhost:8080/helloworld | jq
```
The result looks like:
```
{
"result": 1
}
```
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.

### Building an über-jar
To build an _über-jar_, execute the following command:
```shell script
mvn package -Dquarkus.package.type=uber-jar
```

The application, packaged as an _über-jar_, is runnable using `java -jar target/*-runner.jar`.

## Creating a native executable

To build a native executable:
```shell script
mvn package -Pnative
```

If GraalVM is not installed, the native executable can be built in a container using:
```shell script
mvn package -Pnative -Dquarkus.native.container-build=true
```

To run the native image: `./target/helloworld-1.0.0-SNAPSHOT-runner`

To learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.html.

157 changes: 157 additions & 0 deletions benchmarks/helloworld/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?xml version="1.0"?>
<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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ibm.trl</groupId>
<artifactId>benchmarks</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<groupId>com.ibm.trl</groupId>
<artifactId>helloworld</artifactId>
<version>1.0.0-SNAPSHOT</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-funqy-knative-events</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-container-image-docker</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${compiler-plugin.version}</version>
<configuration>
<parameters>${maven.compiler.parameters}</parameters>
<debug>true</debug>
<debuglevel>lines,vars,source</debuglevel>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>copy-file</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<sourceFile>${java.home}/lib/security/cacerts</sourceFile>
<destinationFile>target/cacerts</destinationFile>
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
</profile>
<profile>
<id>qbicc</id>
<dependencies>
<dependency>
<groupId>org.qbicc.quarkus</groupId>
<artifactId>quarkus-qbicc</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
34 changes: 34 additions & 0 deletions benchmarks/helloworld/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8

ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf --disablerepo='*' --enablerepo='ubi-8-*' install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' update \
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& 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 \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --chown=1001 target/quarkus-app/lib/ /deployments/lib/
COPY --chown=1001 target/quarkus-app/*.jar /deployments/
COPY --chown=1001 target/quarkus-app/app/ /deployments/app/
COPY --chown=1001 target/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8080
USER 1001

ENTRYPOINT [ "sh", "-c", "grep 'model name' /proc/cpuinfo | head -1; /deployments/run-java.sh" ]
31 changes: 31 additions & 0 deletions benchmarks/helloworld/src/main/docker/Dockerfile.legacy-jar
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8

ARG JAVA_PACKAGE=java-17-openjdk-headless
ARG RUN_JAVA_VERSION=1.3.8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
# Install java and the run-java script
# Also set up permissions for user `1001`
RUN microdnf --disablerepo='*' --enablerepo='ubi-8-*' install curl ca-certificates ${JAVA_PACKAGE} \
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' update \
&& microdnf --disablerepo='*' --enablerepo='ubi-8-*' clean all \
&& mkdir /deployments \
&& chown 1001 /deployments \
&& chmod "g+rwX" /deployments \
&& chown 1001:root /deployments \
&& 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 \
&& chown 1001 /deployments/run-java.sh \
&& chmod 540 /deployments/run-java.sh \
&& echo "securerandom.source=file:/dev/urandom" >> /etc/alternatives/jre/conf/security/java.security

# Configure the JAVA_OPTIONS, you can add -XshowSettings:vm to also display the heap size.
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar

EXPOSE 8080
USER 1001

ENTRYPOINT [ "/deployments/run-java.sh" ]
15 changes: 15 additions & 0 deletions benchmarks/helloworld/src/main/docker/Dockerfile.native
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in native (no JVM) mode
###
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.8
WORKDIR /work/
RUN chown 1001 /work \
&& chmod "g+rwX" /work \
&& chown 1001:root /work
COPY --chown=1001:root target/*-runner /work/application

EXPOSE 8080
USER 1001

ENV JAVA_OPTIONS -Dquarkus.http.host=0.0.0.0
CMD ["sh", "-c", "grep 'model name' /proc/cpuinfo | head -1; ./application ${JAVA_OPTIONS}"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM quay.io/quarkus/quarkus-distroless-image:1.0
COPY target/*-runner /application

EXPOSE 8080
USER nonroot

ENV JAVA_OPTIONS -Dquarkus.http.host=0.0.0.0
CMD ["sh", "-c", "./application ${JAVA_OPTIONS}"]
Loading

0 comments on commit 38baa6d

Please sign in to comment.