Skip to content

Commit

Permalink
Leyden POC
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kec <[email protected]>
  • Loading branch information
danielkec committed Sep 25, 2024
1 parent 6e9b457 commit e36422d
Show file tree
Hide file tree
Showing 13 changed files with 369 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/functional/leyden-quickstart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Compiled class file
*.class

# Maven
target/
.m2/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# IntelliJ Idea
.idea/*
!.idea/runConfigurations
*.iws
*.ipr
*.iml
*.releaseBackup
atlassian-ide-plugin.xml

# Netbeans
nbactions.xml
nb-configuration.xml

# Eclipse
.settings
.settings/
.project
.classpath
.factorypath

50 changes: 50 additions & 0 deletions tests/functional/leyden-quickstart/Dockerfile.leyden
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed 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.
#
FROM container-registry.oracle.com/os/oraclelinux:9-slim as olinux-leyden

WORKDIR /usr/share

ARG CHECKPOINT_DIR

ENV JDK_NAME=openjdk-24-leyden+2-8_linux-x64
ENV JAVA_HOME=/usr/share/$JDK_NAME
ENV CR_DIR=${CONT_IMG_VER:-/leyden-checkpoint/cr}

# Install wrk
RUN microdnf -h
RUN microdnf -y update && microdnf -y install perl wget tar gzip curl git openssl-devel
RUN git clone https://github.com/wg/wrk.git && cd wrk && make && cp wrk /usr/local/bin/

# Install Leyden
RUN wget -O leyden-jdk.tar.gz "https://download.java.net/java/early_access/leyden/2/${JDK_NAME}_bin.tar.gz"
RUN tar -xvf ./leyden-jdk.tar.gz -C /usr/share && mv /usr/share/jdk-24 $JAVA_HOME
RUN ln -s $JAVA_HOME/bin/jcmd /bin/ && ln -s $JAVA_HOME/bin/jps /bin/ && ln -s $JAVA_HOME/bin/java /bin/

FROM olinux-leyden
WORKDIR /helidon

ADD target/leyden-quickstart.jar .
ADD target/libs ./libs
ADD runtimeLeyden.sh .
ADD warmUp.sh .
ADD measure.sh .
RUN chmod +x ./*.sh

RUN ./runtimeLeyden.sh

CMD ["sh","/helidon/runtimeLeyden.sh"]

EXPOSE 7001
36 changes: 36 additions & 0 deletions tests/functional/leyden-quickstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
```bash
mvn clean package
docker build -t leyden-helloworld . -f Dockerfile.leyden
# First time ran, checkpoint is created, stop with Ctrl-C
docker run --privileged --network host --name leyden-helloworld leyden-helloworld
# Second time starting from checkpoint, stop with Ctrl-C
docker start -i leyden-helloworld
```


```
---- Vanilla
1667 milliseconds (since JVM startup)
Measuring ...Running 10s test @ http://localhost:7001
16 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 622.78us 1.37ms 27.81ms 92.19%
Req/Sec 4.09k 2.06k 8.96k 61.38%
651144 requests in 10.02s, 85.07MB read
Requests/sec: 64978.74
Transfer/sec: 8.49MB
---- Leyden
578 milliseconds (since JVM startup)
Measuring ...Running 10s test @ http://localhost:7001
16 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 446.13us 0.86ms 22.79ms 92.21%
Req/Sec 4.57k 1.30k 8.82k 70.10%
729398 requests in 10.10s, 95.30MB read
Requests/sec: 72211.76
Transfer/sec: 9.43MB
```
31 changes: 31 additions & 0 deletions tests/functional/leyden-quickstart/buildtimeLeyden.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash -e

#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed 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.
#


echo "==== Creating Leyden checkpoint ===="
echo "=== Pre-starting Helidon MP app ==="
set +e
mkdir -p "/leyden-checkpoint/cr"
./warmUp.sh &
$JAVA_HOME/bin/java -XX:CacheDataStore=$CR_DIR/checkpoint.cds -Xlog:cds=debug:file=$CR_DIR/cds.log -jar ./*.jar
set -e

echo "=== Leyden checkpoint created ==="



21 changes: 21 additions & 0 deletions tests/functional/leyden-quickstart/measure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -e

#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed 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.
#

curl --retry 10 --retry-all-errors --retry-delay 1 http://localhost:7001
printf "\nMeasuring ..."
wrk -c 16 -t 16 -d 10s http://localhost:7001
81 changes: 81 additions & 0 deletions tests/functional/leyden-quickstart/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.helidon.applications</groupId>
<artifactId>helidon-mp</artifactId>
<version>4.1.1</version>
<relativePath/>
</parent>
<groupId>io.helidon.quickstart</groupId>
<artifactId>leyden-quickstart</artifactId>
<version>1.0-SNAPSHOT</version>


<dependencies>
<dependency>
<groupId>io.helidon.microprofile.bundles</groupId>
<artifactId>helidon-microprofile-core</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.openapi</groupId>
<artifactId>helidon-microprofile-openapi</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.health</groupId>
<artifactId>helidon-microprofile-health</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-binding</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.helidon.logging</groupId>
<artifactId>helidon-logging-jul</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.eclipse.microprofile.metrics</groupId>
<artifactId>microprofile-metrics-api</artifactId>
</dependency>
<dependency>
<groupId>io.helidon.microprofile.metrics</groupId>
<artifactId>helidon-microprofile-metrics</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-libs</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.smallrye</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<executions>
<execution>
<id>make-index</id>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
38 changes: 38 additions & 0 deletions tests/functional/leyden-quickstart/runtimeLeyden.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash -e

#
# Copyright (c) 2022-2024 Oracle and/or its affiliates.
#
# Licensed 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.
#

if [ ! -d "$CR_DIR" ];
then
echo "==== Creating Leyden checkpoint ===="
echo "=== Pre-starting Helidon MP app ==="
set +e
mkdir -p "$CR_DIR"
./warmUp.sh &
$JAVA_HOME/bin/java -XX:CacheDataStore=$CR_DIR/checkpoint.cds -Xlog:cds=debug:file=$CR_DIR/cds.log -jar ./*.jar
set -e

echo "=== Leyden checkpoint created ==="
else
echo "==== Starting directly from Leyden checkpoint ===="
#exec ls -l /helidon
./measure.sh &
exec $JAVA_HOME/bin/java -XX:CacheDataStore=$CR_DIR/checkpoint.cds -jar ./*.jar
#exec $JAVA_HOME/bin/java -jar ./*.jar
fi


Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.helidon.quickstart;

import jakarta.enterprise.context.RequestScoped;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/")
@RequestScoped
public class HelloResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String message() {
return "Hello World";
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee
https://jakarta.ee/xml/ns/jakartaee/beans_4_0.xsd"
version="4.0"
bean-discovery-mode="annotated">
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
server.port=7001
server.host=0.0.0.0


Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

# Example Logging Configuration File
# For more information see $JAVA_HOME/jre/lib/logging.properties

# Send messages to the console
handlers=io.helidon.logging.jul.HelidonConsoleHandler

# HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n

# Global logging level. Can be overridden by specific loggers
.level=INFO

# Quiet Weld
org.jboss.level=WARNING

# Component specific log levels
#io.helidon.config.level=INFO
#io.helidon.security.level=INFO
#io.helidon.common.level=INFO
24 changes: 24 additions & 0 deletions tests/functional/leyden-quickstart/warmUp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -e

#
# Copyright (c) 2024 Oracle and/or its affiliates.
#
# Licensed 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.
#


curl --retry 10 --retry-all-errors --retry-delay 1 http://localhost:7001
printf "\n==== Warming up ...\n"
wrk -c 16 -t 16 -d 10s http://localhost:7001
printf "\n==== Warmup complete\n"
kill $(jps | grep jar | awk '{print $1}')
1 change: 1 addition & 0 deletions tests/functional/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@
<module>jax-rs-multiple-apps</module>
<module>param-converter-provider</module>
<module>config-profiles</module>
<module>leyden-quickstart</module>
</modules>
</project>

0 comments on commit e36422d

Please sign in to comment.