Skip to content

Fix typos in comments and docs #4794

Fix typos in comments and docs

Fix typos in comments and docs #4794

name: PERF
on:
workflow_dispatch:
pull_request:
# On master only the benchmarks are built and cached, so that pull requests
# can reuse them.
push:
branches:
- master
# References:
# https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#reusable-workflows-and-starter-workflows
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onworkflow_call
# https://docs.github.com/en/actions/learn-github-actions/contexts#about-contexts-and-expressions
# You can override the default DIFF_CUTOFF_PERCENT by specifying a cutoff along
# with the benchmark target.
# Eg, "Data.Async:12" where "Data.Async" is the benchmark target, ":" is the
# seperator, and "12" is the new cutoff percent
#----------------------------------------------------------------------
#-- Benchmarks listed in alphabetical order
#----------------------------------------------------------------------
jobs:
build:
name: "Comparison: master vs PR (ubuntu-latest ghc-9.14.1)"
env:
GHCVER: 9.14.1
GHCUP_VERSION: 0.1.50.2
CI_BENCHMARKS_WITH_CUTOFF: >-
Data.Array
Data.Array.Generic
Data.Fold
Data.Fold.Prelude
Data.MutArray
Data.MutByteArray.DeriveSerialize
Data.MutByteArray.DeriveUnboxGeneric
Data.MutByteArray.DeriveUnboxTH
Data.Parser
Data.ParserK
Data.ParserK.Chunked
Data.ParserK.Chunked.Generic
Data.Pipe
Data.RingArray
Data.Scan
Data.Scanl
Data.Scanl.Concurrent
Data.Stream
Data.Stream.Concurrent
Data.Stream.ConcurrentEager
Data.Stream.ConcurrentInterleaved
Data.Stream.ConcurrentOrdered
Data.Stream.Prelude
Data.StreamK:6
Data.Unfold
Data.Unfold.Prelude
CrossModule
FileSystem.DirIO
FileSystem.Handle
Unicode.Parser
Unicode.Stream
CI_FIELDS: allocated
CI_DIFF_CUTOFF_PERCENT: 3
runs-on: ubuntu-latest
steps:
- name: Checkout the PR branch
uses: actions/checkout@v4
# This should happen before cache restore.
- name: Remove ~/.ghcup symlink
run: |
rm -f ~/.ghcup
# Saved by the TEST workflow on master
- name: Restore ghcup and ghc
uses: actions/cache/restore@v4
with:
path: |
~/.ghcup
key: ghc-${{ env.GHCVER }}-v-ubuntu-latest
# Saved by the TEST workflow on master, "cabal update" updates it.
- name: Restore hackage package index
uses: actions/cache/restore@v4
with:
path: |
~/.cache/cabal/packages
key: cabal-hackage-index
- name: Determine the "master" commit
run: |
if test "${{ github.event_name }}" = push
then
sha=${{ github.sha }}
else
sha=$(git ls-remote origin refs/heads/master | cut -f1)
fi
echo "MASTER_SHA=$sha" >> $GITHUB_ENV
# Saved by the push to master run of this workflow. A pull request can
# restore only the caches saved by itself or by master. When master has
# not changed the master benchmarks are up to date and only need to be
# run, otherwise an older master build is restored and the build is
# incremental. The cabal store is in the same cache so that the
# dependencies match the build directory.
- name: Restore the "master" build
id: master-build
uses: actions/cache/restore@v4
with:
path: |
~/.local/state/cabal
dist-newstyle
key: perf-master-build-${{ env.GHCVER }}-${{ env.MASTER_SHA }}
restore-keys: perf-master-build-${{ env.GHCVER }}-
- name: Cache bench-runner
id: bench-runner
uses: actions/cache@v4
with:
path: bench-runner
key: bench-runner-${{ env.GHCVER }}-${{ hashFiles('cabal.project.report', 'benchmark/bench-runner/**', 'targets/**') }}
- name: Update CI_BENCHMARKS environment variable
run: |
CI_BENCHMARKS=""
for i in $CI_BENCHMARKS_WITH_CUTOFF
do
bname=$(echo "$i" | cut -d: -f1)
CI_BENCHMARKS="$CI_BENCHMARKS $bname"
done
echo "CI_BENCHMARKS=$CI_BENCHMARKS" >> $GITHUB_ENV
# Use a sane PATH, especially to pick the right GHC
- name: Set PATH to add .local and .ghcup
run: echo "$HOME/.local/bin:$HOME/.ghcup/bin:/bin:/usr/bin" > $GITHUB_PATH
- name: Download ghc
run: |
if ! ghc --version 2>/dev/null | grep -q "$GHCVER" || ! command -v cabal
then
curl -sL -o ./ghcup https://downloads.haskell.org/~ghcup/$GHCUP_VERSION/x86_64-linux-ghcup-$GHCUP_VERSION
chmod +x ./ghcup
export GHCUP_INSTALL_BASE_PREFIX=$HOME
./ghcup install ghc $GHCVER
./ghcup set ghc $GHCVER
./ghcup install cabal
fi
# XXX update only if not present
cabal update
# Use a separate build directory to keep dist-newstyle for the benchmarks
- name: Install bench-runner from PR branch
if: steps.bench-runner.outputs.cache-hit != 'true'
run: |
cabal install bench-runner --project-file=cabal.project.report --builddir=dist-bench-runner --installdir=./ --allow-newer
# -----------------------------------------------------------------
# -- Generate reports for the base branch and upload
# -----------------------------------------------------------------
- name: Checkout the "master" branch
uses: actions/checkout@v4
with:
ref: ${{ env.MASTER_SHA }}
clean: false
# Only build on master. The build command must be the same as the one
# that bench-runner uses, otherwise the pull request runs rebuild.
- name: Build benchmarks for "master" branch
if: github.event_name == 'push'
run: |
targets=
for b in $CI_BENCHMARKS
do
targets="$targets streamly-benchmarks:bench:$b"
done
cabal v2-build --flag fusion-plugin --flag limit-build-mem \
--with-compiler ghc --enable-benchmarks $targets
- name: Save the "master" build
if: github.event_name == 'push' && steps.master-build.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: |
~/.local/state/cabal
dist-newstyle
key: ${{ steps.master-build.outputs.cache-primary-key }}
- name: Run benchmarks for "master" branch
if: github.event_name != 'push'
run: |
# --cabal-build-options "-j1"
./bench-runner --package-name streamly-benchmarks --package-version 0.0.0 --targets "$CI_BENCHMARKS" --raw
# XXX Print dependencies of streamly-core and streamly for comparison
# in case there is a regression due to version changes.
# ghc-pkg --package-db=./dist-newstyle/packagedb/ghc-9.10.3/ field streamly depends
# -----------------------------------------------------------------
# -- Download, generate reports for the current branch and append
# -----------------------------------------------------------------
- name: Checkout the PR branch
if: github.event_name != 'push'
uses: actions/checkout@v4
with:
# preserve bench-runner and the "charts" directory created by bench-runner
clean: false
- name: Run benchmarks and append
if: github.event_name != 'push'
run: |
# --cabal-build-options "-j1"
./bench-runner --package-name streamly-benchmarks --package-version 0.0.0 --targets "$CI_BENCHMARKS" --raw --append
# -----------------------------------------------------------------
# -- Compare
# -----------------------------------------------------------------
- name: List all benchmarks
if: github.event_name != 'push'
run: |
./bench-runner --package-name streamly-benchmarks --package-version 0.0.0 --targets "$CI_BENCHMARKS" --no-measure
- name: Compare benchmarks
if: github.event_name != 'push'
run: |
EXIT_STATUS=0
for i in $CI_BENCHMARKS_WITH_CUTOFF
do
arrI=(${i//:/ })
bname=${arrI[0]}
cutoff=${arrI[1]}
test -z "$cutoff" && cutoff=$CI_DIFF_CUTOFF_PERCENT
echo
echo "Checking $bname for regressions greater than $cutoff percent"
! ./bench-runner \
--package-name streamly-benchmarks \
--package-version 0.0.0 \
--targets "$bname" \
--fields "$CI_FIELDS" \
--no-measure --silent \
--diff-cutoff-percent $cutoff \
| grep -v "^$"
test $? -eq 1 && EXIT_STATUS=1
done
# Always exit with success so that we are able to use the cache
echo
echo "------------------------------------------------------------------------"
if test $EXIT_STATUS -ne 0
then
echo "ERROR: Performance regressions are more than ${CI_DIFF_CUTOFF_PERCENT}%."
else
echo "SUCCESS: Performance regressions are within ${CI_DIFF_CUTOFF_PERCENT}%."
fi
echo "------------------------------------------------------------------------"
exit 0