Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ NashornProfile.txt
**/core.[0-9]*
*.rej
*.orig
test/benchmarks/**/target
61 changes: 61 additions & 0 deletions test/benchmarks/micros-javac/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Javac microbenchmarks

The Javac Microbenchmarks is a collection of microbenchmarks for measuring
the performance of Javac API using the
[JMH](http://openjdk.java.net/projects/code-tools/jmh/) framework.


## Building and running the project

Currently, the project can be built and run with JDK 9 and later. This is
a Maven project and is built by:

$ mvn clean install

After building, the executable jar is target/micros-javac-[version].jar.
Run the benchmarks with:

$ java -jar target/micros-javac-*.jar [optional jmh parameters]

See the entire list of benchmarks using:

$ java -jar target/micros-javacs-*.jar -l [optional regex to select benchmarks]

For example:

$ java -jar target/micros-javac-1.0-SNAPSHOT.jar -l
Benchmarks:
org.openjdk.bench.langtools.javac.GroupJavacBenchmark.coldGroup
org.openjdk.bench.langtools.javac.GroupJavacBenchmark.hotGroup
org.openjdk.bench.langtools.javac.SingleJavacBenchmark.compileCold
org.openjdk.bench.langtools.javac.SingleJavacBenchmark.compileHot

And the same regex syntax works to run some test:

$ java -jar target/micros-javac-1.0-SNAPSHOT.jar SingleJavacBenchmark.compileHot

## Troubleshooting

### Build of micros-javac module got stuck

If you build got stuck on `[get] Getting: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_windows-x64_bin.zip` then you are probably experiencing some networking or web proxy obstacles.

One solution is to download required reference JDK from [https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_windows-x64_bin.zip](https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_windows-x64_bin.zip) manually and then build the project with property pointing to the local copy:

$ mvn clean install -Djavac.benchmark.openjdk.zip.download.url=file:///<your download location>/openjdk-11+28_windows-x64_bin.zip

Note: Please use `openjdk-11+28_windows-x64_bin.zip` to build the project no matter what target platform is.

Another solution might be to add proxy settings:

$ mvn -Dhttps.proxyHost=... -Dhttps.proxyPort=... clean install

### Execution of micros-javac benchmarks takes several hours

micros-javac benchmarks consist of two sets of benchmarks:
* `SingleJavacBenchmark` (which is parametrized) measures each single javac compilation stage in an isolated run. This benchmark is designed for exact automated performance regression testing and it takes several hours to execute completely.
* `GroupJavacBenchmark` is grouping the measurements of all javac compilation stages into one run and its execution should take less than 30 minutes on a regular developers computer.

Solution to speed up javac benchmarking is to select only `GroupJavacBenchmark` for execution using following command line:

$ java -jar target/micros-javac-1.0-SNAPSHOT.jar .*GroupJavacBenchmark.*
139 changes: 139 additions & 0 deletions test/benchmarks/micros-javac/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<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/maven-v4_0_0.xsd">
<!--
Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
or visit www.oracle.com if you need additional information or have any
questions.
-->
<modelVersion>4.0.0</modelVersion>
<groupId>org.openjdk</groupId>
<artifactId>micros-javac</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>OpenJDK Microbenchmark of Java Compile</name>
<properties>
<javac.benchmark.openjdk.zip.download.url>https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_windows-x64_bin.zip</javac.benchmark.openjdk.zip.download.url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jmh.version>1.36</jmh.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<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.AppendingTransformer">
<resource>META-INF/BenchmarkList</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/CompilerHints</resource>
</transformer>
</transformers>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.4</version>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<mkdir dir="${project.build.outputDirectory}"/>
<get src="${javac.benchmark.openjdk.zip.download.url}" dest="${project.build.directory}/jdk-bin.zip" skipexisting="true" verbose="true"/>
<unzip src="${project.build.directory}/jdk-bin.zip" dest="${project.build.outputDirectory}">
<patternset>
<include name="*/lib/src.zip"/>
<include name="*/release"/>
</patternset>
<mapper type="flatten"/>
</unzip>
<loadfile srcFile="${project.build.outputDirectory}/release" property="release.info"/>
<echo>
-------------------------------------------------
Bundling JDK sources with following release info:
-------------------------------------------------
${release.info}
-------------------------------------------------
</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<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>
</dependencies>
</project>
Loading