Skip to content

Commit

Permalink
allow jmh benchmarks to be cached for faster ci runs
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-manes committed Oct 21, 2024
1 parent 47a0101 commit d93625c
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 27 deletions.
101 changes: 86 additions & 15 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ jobs:
java: ${{ matrix.java }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
caffeine:jmh -q
-PincludePattern=ComputeBenchmark
-PbenchmarkParameters=computeType=Caffeine,Guava,ConcurrentHashMap
- name: Upload Compute JMH Results to Gist
uses: popsiclestick/gist-sync-action@88f8633178625914f2a01abf1a765f7272a580fa # v1.2.0
if: >
github.event_name == 'push'
&& github.event.repository.fork == false
&& endsWith(github.ref, github.event.repository.default_branch)
continue-on-error: true
with:
auth: ${{ secrets.GIST_TOKEN }}
Expand All @@ -68,15 +67,14 @@ jobs:
java: ${{ matrix.java }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
caffeine:jmh -q
-PincludePattern=GetPutBenchmark
-PbenchmarkParameters=cacheType=Caffeine,Guava,ConcurrentHashMap
- name: Upload Get/Put JMH Results to Gist
uses: popsiclestick/gist-sync-action@88f8633178625914f2a01abf1a765f7272a580fa # v1.2.0
if: >
github.event_name == 'push'
&& github.event.repository.fork == false
&& endsWith(github.ref, github.event.repository.default_branch)
continue-on-error: true
with:
auth: ${{ secrets.GIST_TOKEN }}
Expand All @@ -90,39 +88,112 @@ jobs:
java: ${{ matrix.java }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
caffeine:jmh -q
-PincludePattern=PutRemoveBenchmark
-PbenchmarkParameters=cacheType=Caffeine,Guava,ConcurrentHashMap
- name: Upload Put/Remove JMH Results to Gist
uses: popsiclestick/gist-sync-action@88f8633178625914f2a01abf1a765f7272a580fa # v1.2.0
if: >
github.event_name == 'push'
&& github.event.repository.fork == false
continue-on-error: true
with:
auth: ${{ secrets.GIST_TOKEN }}
gist_description: Put/Remove JMH Results
gist_title: putremove_results_${{ matrix.java }}.json
github_file: ./caffeine/build/reports/jmh/results.json
gist_url: https://gist.githubusercontent.com/ben-manes/1359c399cb717e81976ee635c513340b
- name: EvictionBenchmark JMH Benchmark
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh -q
-PincludePattern=EvictionBenchmark
-PbenchmarkParameters=cacheType=Caffeine,Guava
- name: Upload EvictionBenchmark JMH Results to Gist
uses: popsiclestick/gist-sync-action@88f8633178625914f2a01abf1a765f7272a580fa # v1.2.0
if: >
github.event_name == 'push'
&& github.event.repository.fork == false
continue-on-error: true
with:
auth: ${{ secrets.GIST_TOKEN }}
gist_description: Eviction JMH Results
gist_title: eviction_results_${{ matrix.java }}.json
github_file: ./caffeine/build/reports/jmh/results.json
gist_url: https://gist.githubusercontent.com/ben-manes/2f5b54540c2e67edc0d1a7f28a1139f5
- name: FrequencySketch JMH Benchmark
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: >
caffeine:jmh --no-daemon -q
caffeine:jmh -q
-PincludePattern=FrequencySketchBenchmark
-PbenchmarkParameters=tableSize=134217728
- name: Upload FrequencySketch JMH Results to Gist
uses: popsiclestick/gist-sync-action@88f8633178625914f2a01abf1a765f7272a580fa # v1.2.0
if: >
github.event_name == 'push'
&& github.event.repository.fork == false
continue-on-error: true
with:
auth: ${{ secrets.GIST_TOKEN }}
gist_description: FrequencySketch JMH Results
gist_title: freq_results_${{ matrix.java }}.json
github_file: ./caffeine/build/reports/jmh/results.json
gist_url: https://gist.githubusercontent.com/ben-manes/f93df1b66aa210bc23a1e672ef9bee16
- name: TimerWheelBenchmark JMH Benchmark
uses: ./.github/actions/run-gradle
with:
java: ${{ matrix.java }}
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
arguments: caffeine:jmh --no-daemon -q -PincludePattern=TimerWheelBenchmark
arguments: caffeine:jmh -q -PincludePattern=TimerWheelBenchmark
- name: Upload TimerWheelBenchmark JMH Results to Gist
uses: popsiclestick/gist-sync-action@88f8633178625914f2a01abf1a765f7272a580fa # v1.2.0
if: >
github.event_name == 'push'
&& github.event.repository.fork == false
continue-on-error: true
with:
auth: ${{ secrets.GIST_TOKEN }}
gist_description: TimerWheel JMH Results
gist_title: timerwheel_results_${{ matrix.java }}.json
github_file: ./caffeine/build/reports/jmh/results.json
gist_url: https://gist.githubusercontent.com/ben-manes/9abafdbc76fe34c0e63cef386b0b9ac0
- name: Publish JMH benchmarks
if: >
matrix.java == env.PUBLISH_JDK
&& github.event_name == 'push'
&& endsWith(github.ref, github.event.repository.default_branch)
run: |
{
echo '#### [Compute](https://jmh.morethan.io/?gists=511298014cc5629cbc5e57f09fd4c430)'
echo -n 'This benchmark that evaluates the overhead due to locking when the entry is'
echo -n 'present. The scenarios graphed are all threads retrieving a single entry'
echo -n '("sameKey") and threads retrieving different keys based on a Zipf distribution'
echo -n '("spread").'
echo -n 'This benchmark that evaluates the overhead due to locking when the entry is '
echo -n 'present. The scenarios graphed are all threads retrieving a single entry '
echo -n '("sameKey") and threads retrieving different keys based on a Zipf '
echo -n 'distribution ("spread").'
echo -e '\n'
echo '#### [Get/Put](https://jmh.morethan.io/?gists=b231cf57cf8e144e2247716e777edcf3)'
echo -n 'A benchmark that evaluates the read/write performance of a cache. The cache is'
echo -n 'pre-populated for a 100% hit rate and a Zipf distribution of keys is used to'
echo -n 'mimic application usage patterns.'
echo -n 'A benchmark that evaluates the read/write performance of a cache. The cache '
echo -n 'is pre-populated for a 100% hit rate and a Zipf distribution of keys is used '
echo -n 'to mimic application usage patterns.'
echo -e '\n'
echo '#### [Put/Remove](https://jmh.morethan.io/?gists=1359c399cb717e81976ee635c513340b)'
echo -n 'A benchmark that evaluates the insert/update/remove performance of a cache. '
echo -n 'A Zipf distribution of keys is used but it is unpredictable if the entry is '
echo -n 'present given the competing operations.'
echo -e '\n'
echo '#### [Eviction](https://jmh.morethan.io/?gists=2f5b54540c2e67edc0d1a7f28a1139f5)'
echo -n 'A benchmark that evaluates the performance of a evictions by always inserting '
echo -n 'a new entry.'
echo -e '\n'
echo '#### [FrequencySketch](https://jmh.morethan.io/?gists=f93df1b66aa210bc23a1e672ef9bee16)'
echo -n 'A benchmark that evaluates the performance of a frequency sketch for use by '
echo -n 'size eviction.'
echo -e '\n'
echo '#### [TimerWheel](https://jmh.morethan.io/?gists=9abafdbc76fe34c0e63cef386b0b9ac0)'
echo -n 'A benchmark that evaluates the performance of the timer wheel for use by '
echo -n 'variable expiration.'
} >> $GITHUB_STEP_SUMMARY
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* This benchmark can be run by optionally specifying the target jvm in the command.
* <p>
* <pre>{@code
* JAVA_VERSION=20 ./gradlew jmh -PincludePattern=FactoryBenchmark --no-daemon
* ./gradlew jmh -PincludePattern=FactoryBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
/**
* <p>
* <pre>{@code
* ./gradlew jmh -PincludePattern=BuilderBenchmark --no-daemon
* ./gradlew jmh -PincludePattern=BuilderBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* a 100% eviction rate to mimic worst case behavior.
* <p>
* <pre>{@code
* ./gradlew jmh -PincludePattern=EvictionBenchmark
* ./gradlew jmh -PincludePattern=EvictionBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

/**
* <pre>{@code
* ./gradlew jmh -PincludePattern=FrequencySketchBenchmark
* ./gradlew jmh -PincludePattern=FrequencySketchBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
* a 100% hit rate and a Zipf distribution of keys is used to mimic application usage patterns.
* <p>
* <pre>{@code
* ./gradlew jmh -PincludePattern=GetPutBenchmark
* // JAVA_VERSION=?? for an alternative jdk
* ./gradlew jmh -PincludePattern=GetPutBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* concerns and should not be used to compare implementations.
* <p>
* <pre>{@code
* ./gradlew jmh -PincludePattern=PutRemoveBenchmark
* ./gradlew jmh -PincludePattern=PutRemoveBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/**
* <pre>{@code
* ./gradlew jmh -PincludePattern=TimerWheelBenchmark
* ./gradlew jmh -PincludePattern=TimerWheelBenchmark -q --rerun
* }</pre>
*
* @author [email protected] (Ben Manes)
Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ dependency-check = "10.0.4"
eclipse-collections = "12.0.0.M3"
ehcache3 = "3.10.8"
errorprone = "2.34.0"
errorprone-plugin = "4.0.1"
errorprone-plugin = "4.1.0"
errorprone-support = "0.18.0"
expiring-map = "0.5.11"
fast-filter = "1.0.2"
fastutil = "8.5.14"
fastutil = "8.5.15"
felix-framework = "7.0.5"
felix-scr = "2.2.12"
findsecbugs = "1.13.0"
Expand Down Expand Up @@ -69,7 +69,7 @@ lincheck = "2.34"
mockito = "5.14.2"
nexus-publish = "2.0.0"
nullaway = "0.12.0"
nullaway-plugin = "2.0.0"
nullaway-plugin = "2.1.0"
okhttp-bom = "4.12.0"
okio-bom = "3.9.1"
osgi-annotations = "1.5.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ jmhReport {
jmhReportOutput = file(layout.buildDirectory.file("reports/jmh")).toString()
}

// Use --rerun for repeated executions
tasks.withType<JmhTask>().configureEach {
group = "Benchmarks"
description = "Executes a Java microbenchmark"
incompatibleWithConfigurationCache()
outputs.upToDateWhen { false }

doFirst {
if (!project.hasProperty("includePattern")) {
Expand Down
2 changes: 1 addition & 1 deletion jcache/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ tasks.named<Javadoc>("javadoc").configure {
tasks.withType<Test>().configureEach {
useJUnitPlatform()
dependsOn(unzipTestKit)
testClassesDirs += layout.buildDirectory.files("tck")
testClassesDirs = files(testClassesDirs, layout.buildDirectory.files("tck"))

project(":caffeine").plugins.withId("java-library") {
val caffeineJar = project(":caffeine").tasks.named<Jar>("jar")
Expand Down

0 comments on commit d93625c

Please sign in to comment.