Skip to content
Merged
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
76 changes: 76 additions & 0 deletions .github/workflows/mutablemaps-benchmarks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: MutableMaps Benchmarks
# JMH comparison of the verified maps of data-structures/maps/mutablemaps with the Scala standard library:
# verified MutableLongMap vs mutable.LongMap, verified MutableHashMap vs mutable.HashMap and immutable.HashMap.
# The standard profile takes about 2h15 (the full JMH suite takes about 48 hours and is not run here).
# The HTML report, the JMH JSON results and the logs are uploaded as the artifact "mutablemaps-benchmarks".
on:
workflow_dispatch:
inputs:
profile:
description: 'standard: about 2h15. smoke: about 10 minutes, checks the pipeline, not the numbers.'
type: choice
options:
- standard
- smoke
default: standard

# Two benchmark runs on the same machine would disturb each other
concurrency:
group: mutablemaps-benchmarks
cancel-in-progress: false

env:
# Java options of sbt. The benchmark JVMs are forked by JMH with their own heap (FORK_HEAP in run_benchmarks_ci.sh).
JAVA_OPTS: -Dsbt.io.implicit.relative.glob.conversion=allow -Xss512M -Xms1024M -Xmx8G -XX:MaxMetaspaceSize=2G -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=768M
JAVA_OPTS_TMP_DIR: /tmp/tmp_${{ github.run_id }}_${{ github.run_attempt }}
PROJECT_DIR: data-structures/maps/mutablemaps
RESULTS_DIR: data-structures/maps/mutablemaps/benchmark_results/raw/ci
jobs:
mutablemaps-benchmarks:
runs-on: [self-hosted, linux]
# The standard profile needs about 2h15; the measurements of the groups that finished are still reported after a timeout
timeout-minutes: 240
steps:
- name: Checkout
uses: actions/checkout@v6
# Stainless and the solvers are not needed to run the benchmarks, only a JDK and sbt:
# the sbt-stainless plugin is downloaded by run_benchmarks_ci.sh
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Setup java options, temp folder and sbt
run: |
rm -rf "$JAVA_OPTS_TMP_DIR" && mkdir -p "$JAVA_OPTS_TMP_DIR"
echo "JAVA_OPTS=$JAVA_OPTS -Djava.io.tmpdir=$JAVA_OPTS_TMP_DIR" >> "$GITHUB_ENV"
echo "SBT_OPTS=-Djava.io.tmpdir=$JAVA_OPTS_TMP_DIR --sbt-dir $JAVA_OPTS_TMP_DIR" >> "$GITHUB_ENV"
wget https://github.com/sbt/sbt/releases/download/v1.10.1/sbt-1.10.1.tgz -O "$JAVA_OPTS_TMP_DIR/sbt.tgz" --no-verbose
mkdir -p "$JAVA_OPTS_TMP_DIR/sbt-launcher" && tar xfz "$JAVA_OPTS_TMP_DIR/sbt.tgz" -C "$JAVA_OPTS_TMP_DIR/sbt-launcher"
echo "$JAVA_OPTS_TMP_DIR/sbt-launcher/sbt/bin" >> "$GITHUB_PATH"
- name: Run benchmarks
# Shorter than the timeout of the job, so that the report and the upload steps still have time to run
timeout-minutes: 225
env:
PROFILE: ${{ inputs.profile }}
run: |
rm -rf "$RESULTS_DIR"
"$PROJECT_DIR/run_benchmarks_ci.sh" --profile "$PROFILE" --output "$RESULTS_DIR"
- name: Generate report
# Also after a failure or a timeout: the groups that finished are reported
if: always()
run: |
python3 "$PROJECT_DIR/benchmark_results/generate_benchmark_report.py" "$RESULTS_DIR" \
-o "$RESULTS_DIR/benchmark-report.html" --summary "$RESULTS_DIR/summary.md"
cat "$RESULTS_DIR/summary.md" >> "$GITHUB_STEP_SUMMARY"
- name: Upload report and results
if: always()
uses: actions/upload-artifact@v4
with:
name: mutablemaps-benchmarks
path: ${{ env.RESULTS_DIR }}
if-no-files-found: warn
- name: Clean up
# Even after a failure, a timeout or a cancellation, so that jobs don't fill the runners' disk
if: always()
run: rm -rf "${JAVA_OPTS_TMP_DIR:?}"
15 changes: 14 additions & 1 deletion data-structures/maps/mutablemaps/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This project contains a verified implementation of the `LongMap` from the scala

To run this project, you need to install the Stainless sbt plugin. To do so, follow these steps:

1. Download the following archive: [Stainless SBT plugin download]("https://github.com/epfl-lara/stainless/releases/download/v0.9.8.2/sbt-stainless.zip")
1. Download the following archive: [Stainless SBT plugin download]("https://github.com/epfl-lara/stainless/releases/download/v0.10.5/sbt-stainless.zip")
2. Unzip the archive, it should contain a `project` folder and a `stainless` folder.
3. copy the `project/lib` folder into the `project` of this sbt project.
4. copy the `stainless` folder into the root of this sbt project.
Expand Down Expand Up @@ -35,6 +35,19 @@ To run benchmarks, run in `sbt`

```$ Jmh/run -i 10 -wi 10 -f1 -t1 <regex-if-only-some>```

### Comparison with the Scala standard library (CI)

The full suite takes about 48 hours. `./run_benchmarks_ci.sh` runs a time-boxed selection of it (about 2h15): the verified `LongMap` against `scala.collection.mutable.LongMap`, and the verified `HashMap` against `scala.collection.mutable.HashMap` and `scala.collection.immutable.HashMap`, on a few sizes per benchmark. It downloads the Stainless sbt plugin if it is not installed. `--profile smoke` checks the pipeline in about 10 minutes; `--help` lists the options.

```
$ ./run_benchmarks_ci.sh --output benchmark_results/raw/my_run
$ python3 benchmark_results/generate_benchmark_report.py benchmark_results/raw/my_run
```

The second command writes `benchmark-report.html` (charts, ratios and measurements) in the results directory.

The GitHub workflow `MutableMaps Benchmarks` (`.github/workflows/mutablemaps-benchmarks.yml`) runs both on manual dispatch and uploads the report, the JMH JSON results and the logs as the artifact `mutablemaps-benchmarks`.

## Verification

To verify using Stainless, first install Stainless following the instructions [here]("github.com/epfl-lara/stainless"). Please note that the external solvers such as z3 and cvc5 must be installed separately and accessible in the `PATH`.
Expand Down
Loading
Loading