Skip to content

Commit

Permalink
apacheGH-524: Add sshd-benchmarks maven project
Browse files Browse the repository at this point in the history
The new maven project sshd-benchmarks contains JMH benchmarks. The
project is not part of the binary distribution, and the install:install
and deploy:deploy targets are skipped. The project is included in the
source distribution.

The benchmarks are intended to be run locally.

Currently the project contains benchmarks for SFTP file uploads, which
can be run either against a local container (if the docker engine is
running), or against an external SFTP server.
  • Loading branch information
tomaswolf committed Aug 9, 2024
1 parent 16b3078 commit 7bc19f3
Show file tree
Hide file tree
Showing 19 changed files with 1,182 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Servers/
.settings/
RemoteSystemsTempFiles/
.classpath
.factorypath
.project
# Puthon related files
.pydevproject
Expand Down
2 changes: 2 additions & 0 deletions assembly/src/main/descriptors/windows-src.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@

<include>sshd-openpgp/src/test/resources/**/*</include>
<include>sshd-core/src/test/resources/org/apache/sshd/client/opensshcerts/**/*</include>
<include>sshd-benchmarks/src/main/resources/org/apache/sshd/**/*</include>
</includes>
<excludes>
<exclude>**/eclipse-classes/**</exclude>
Expand Down Expand Up @@ -95,6 +96,7 @@

<exclude>sshd-core/src/docs/*.txt</exclude>
<exclude>sshd-core/src/test/resources/org/apache/sshd/client/opensshcerts/**/*</exclude>
<exclude>sshd-benchmarks/src/main/resources/org/apache/sshd/**/*</exclude>
<exclude>sshd-openpgp/src/test/resources/**/*</exclude>
</excludes>
<lineEnding>dos</lineEnding>
Expand Down
8 changes: 6 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
<format.formatter.action>validate</format.formatter.action>
</properties>
</profile>

<profile>
<id>toolchains</id>
<activation>
Expand Down Expand Up @@ -683,7 +683,7 @@
</dependency>

<!-- Test dependencies -->
<dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
<scope>test</scope>
Expand Down Expand Up @@ -730,6 +730,8 @@
<exclude>docs/**</exclude>
<exclude>sshd-sources/**</exclude>
<exclude>src/test/resources/**</exclude>
<exclude>src/main/resources/org/apache/sshd/benchmarks/**</exclude>
<exclude>src/main/java/org/apache/sshd/benchmarks/**/*.md</exclude>
<exclude>**/stty-output-*.txt</exclude>
<exclude>**/target/**</exclude>
<!-- formatter plugin cache folder -->
Expand Down Expand Up @@ -937,6 +939,7 @@
<skipPmdError>false</skipPmdError>
<analysisCache>true</analysisCache> <!-- enable incremental analysis -->
<excludeRoots>
<excludeRoot>target/generated-sources/annotations</excludeRoot>
<excludeRoot>target/generated-sources/java</excludeRoot>
</excludeRoots>
<excludes>
Expand Down Expand Up @@ -1379,6 +1382,7 @@
</reporting>

<modules>
<module>sshd-benchmarks</module>
<module>sshd-common</module>
<module>sshd-putty</module>
<module>sshd-openpgp</module>
Expand Down
20 changes: 20 additions & 0 deletions sshd-benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# JMH Benchmarks

This project provides a few JMH benchmarks. It is not part of the Apache MINA sshd binary distribution.

For details about the benchmarks, see the individual READMEs.

Note that benchmarking or timing individual SSH or SFTP operations is difficult because there are always
at least two servers and a network connection in between involved. Some tests run an SSH peer in a local
docker container. The network connection is fast and has a very low latency, but the machine executing
the benchmarks also executes the docker container, which may skew timings. If tests are run against an
external SSH peer on some other machine, the network may be slower and/or have a higher latency, which
again may give unusable timings. Moreover, if the network is a general-purpose network, other traffic may
influence timings, and if there are firewalls and/or proxies in between, getting meaningful timings may
be even harder.

Other processes running on the machine executing the benchmarks may also influence timings. In
particular, suspend automatic backups during benchmarking, and try to avoid interference from virus
scanners. Shut down messaging programs (Teams and the like, but also E-Mail programs), maybe even Web
Browsers or programs that may suddenly check for available updates). Don't do other things on the
machine while the benchmark runs; even scrolling in some other window will skew timings.
188 changes: 188 additions & 0 deletions sshd-benchmarks/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<!--
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.
-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd</artifactId>
<version>2.14.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>sshd-benchmarks</artifactId>
<name>Apache Mina SSHD :: Benchmarks</name>
<packaging>jar</packaging>
<inceptionYear>2024</inceptionYear>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.37</jmh.version>
<uberjar.name>benchmarks</uberjar.name>
<sshd-version>${project.version}</sshd-version>
</properties>

<dependencies>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.33</version>
</dependency>

<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-common</artifactId>
<version>${sshd-version}</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>${sshd-version}</version>
</dependency>
<dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-sftp</artifactId>
<version>${sshd-version}</version>
</dependency>

<dependency>
<groupId>net.i2p.crypto</groupId>
<artifactId>eddsa</artifactId>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpg-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
</dependency>
<dependency>
<groupId>com.github.mwiede</groupId>
<artifactId>jsch</artifactId>
</dependency>
<!--
We inherit JUnit with test scope from the parent POM. This causes trouble with testcontainers,
and we get compilation errors. Overriding the dependency with provided scope resolves that.
-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<finalName>${uberjar.name}</finalName>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.openjdk.jmh.Main</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
<!--
Shading signed JARs will fail without this.
http://stackoverflow.com/questions/999489/invalid-signature-file-when-attempting-to-run-a-jar
-->
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<!-- Don't install or deploy this. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>
10 changes: 10 additions & 0 deletions sshd-benchmarks/src/main/java/org/apache/sshd/benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Benchmarks

This is a generalized benchmark runner for Apache MINA sshd JMH benchmarks. It takes a number of command line options to control which benchmarks are run and how.

Without arguments, it runs the full "SFTP upload" benchmark suite against an OpenSSH instance running in a local docker container. The docker engine must be running for this to work. There are command-line arguments to run the benchmarks against any external server; the benchmarks all assume that there is an `upload` directory into which they can write. Command-line argument `--help` lists the available options.

Via the `--run` option, one can control which benchmarks are run.

Benchmarks are run with a warm-up of 4 iterations, and then 10 timed iterations.

Loading

0 comments on commit 7bc19f3

Please sign in to comment.