on master help sign in
Move benchmarks into separate project and package

This allows benchmarking without forcing e.g. aeson to depend on local uuid-types. Also, conveniently, we can generate own GHA workflow for second, benchmark, project. So we can still run CI that benchmarks are building fine.

commit2cea75baa9258dfdd90865d4d403cefdb5810ec8 authorOleg Grenrus <oleg.grenrus@iki.fi> dateWed 17 Feb 2021, 00:31 (6 years ago) parent68e8fb4
18 files changed+344−78
.git-blame-ignore-revs+1−1 .github/workflows/haskell-ci-bench.yml+177 .github/workflows/haskell-ci.yml+1−1 cabal.bench.project+4 cabal.haskell-ci−1 cabal.project−2 haskell-ci.sh+5 uuid-bench/LICENSE+28 uuid/tests/BenchUUID.hs → uuid-bench/bench/uuid-benchmark.hs uuid-types/tests/BenchUUID.hs → uuid-bench/bench/uuid-types-benchmark.hs uuid-bench/src-uuid+1 uuid-bench/src-uuid-types+1 uuid-bench/uuid-bench.cabal+119 uuid-types/cabal.project+1 uuid-types/tests/summarize-bench-results.pl−14 uuid-types/uuid-types.cabal+3−22 uuid/tests/summarize-bench-results.pl−14 uuid/uuid.cabal+3−23
.git-blame-ignore-revs+1−1
@@ -1,2 +1,2 @@
11# Move code into subdirectories
2−37ae11973e287135e02cfcbde17b7830f79f5e69
2+bf1ac1bad848bb2c081f0cae1631bf53811ec05a
.github/workflows/haskell-ci-bench.ymlnew file+177
@@ -0,0 +1,177 @@
1+# This GitHub workflow config has been generated by a script via
2+#
3+# haskell-ci 'github' '--project' 'cabal.bench.project' '-o' '.github/workflows/haskell-ci-bench.yml' '--github-action-name' 'Benchmarks'
4+#
5+# To regenerate the script (for example after adjusting tested-with) run
6+#
7+# haskell-ci regenerate
8+#
9+# For more information, see https://github.com/haskell-CI/haskell-ci
10+#
11+# version: 0.11.20210214
12+#
13+# REGENDATA ("0.11.20210214",["github","--project","cabal.bench.project","-o",".github/workflows/haskell-ci-bench.yml","--github-action-name","Benchmarks"])
14+#
15+name: Benchmarks
16+on:
17+ push:
18+ branches:
19+ - master
20+ pull_request:
21+ branches:
22+ - master
23+jobs:
24+ linux:
25+ name: Benchmarks - Linux - GHC ${{ matrix.ghc }}
26+ runs-on: ubuntu-18.04
27+ container:
28+ image: buildpack-deps:bionic
29+ continue-on-error: ${{ matrix.allow-failure }}
30+ strategy:
31+ matrix:
32+ include:
33+ - ghc: 8.10.3
34+ allow-failure: false
35+ - ghc: 8.8.4
36+ allow-failure: false
37+ - ghc: 8.6.4
38+ allow-failure: false
39+ - ghc: 8.4.4
40+ allow-failure: false
41+ - ghc: 8.2.2
42+ allow-failure: false
43+ - ghc: 8.0.2
44+ allow-failure: false
45+ fail-fast: false
46+ steps:
47+ - name: apt
48+ run: |
49+ apt-get update
50+ apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common
51+ apt-add-repository -y 'ppa:hvr/ghc'
52+ apt-get update
53+ apt-get install -y ghc-$GHC_VERSION cabal-install-3.2
54+ env:
55+ GHC_VERSION: ${{ matrix.ghc }}
56+ - name: Set PATH and environment variables
57+ run: |
58+ echo "$HOME/.cabal/bin" >> $GITHUB_PATH
59+ echo "LANG=C.UTF-8" >> $GITHUB_ENV
60+ echo "CABAL_DIR=$HOME/.cabal" >> $GITHUB_ENV
61+ echo "CABAL_CONFIG=$HOME/.cabal/config" >> $GITHUB_ENV
62+ HC=/opt/ghc/$GHC_VERSION/bin/ghc
63+ echo "HC=$HC" >> $GITHUB_ENV
64+ echo "HCPKG=/opt/ghc/$GHC_VERSION/bin/ghc-pkg" >> $GITHUB_ENV
65+ echo "HADDOCK=/opt/ghc/$GHC_VERSION/bin/haddock" >> $GITHUB_ENV
66+ echo "CABAL=/opt/cabal/3.2/bin/cabal -vnormal+nowrap" >> $GITHUB_ENV
67+ HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
68+ echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
69+ echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
70+ echo "ARG_BENCH=--enable-benchmarks" >> $GITHUB_ENV
71+ echo "HEADHACKAGE=false" >> $GITHUB_ENV
72+ echo "ARG_COMPILER=--ghc --with-compiler=/opt/ghc/$GHC_VERSION/bin/ghc" >> $GITHUB_ENV
73+ echo "GHCJSARITH=0" >> $GITHUB_ENV
74+ env:
75+ GHC_VERSION: ${{ matrix.ghc }}
76+ - name: env
77+ run: |
78+ env
79+ - name: write cabal config
80+ run: |
81+ mkdir -p $CABAL_DIR
82+ cat >> $CABAL_CONFIG <<EOF
83+ remote-build-reporting: anonymous
84+ write-ghc-environment-files: never
85+ remote-repo-cache: $CABAL_DIR/packages
86+ logs-dir: $CABAL_DIR/logs
87+ world-file: $CABAL_DIR/world
88+ extra-prog-path: $CABAL_DIR/bin
89+ symlink-bindir: $CABAL_DIR/bin
90+ installdir: $CABAL_DIR/bin
91+ build-summary: $CABAL_DIR/logs/build.log
92+ store-dir: $CABAL_DIR/store
93+ install-dirs user
94+ prefix: $CABAL_DIR
95+ repository hackage.haskell.org
96+ url: http://hackage.haskell.org/
97+ EOF
98+ cat $CABAL_CONFIG
99+ - name: versions
100+ run: |
101+ $HC --version || true
102+ $HC --print-project-git-commit-id || true
103+ $CABAL --version || true
104+ - name: update cabal index
105+ run: |
106+ $CABAL v2-update -v
107+ - name: install cabal-plan
108+ run: |
109+ mkdir -p $HOME/.cabal/bin
110+ curl -sL https://github.com/haskell-hvr/cabal-plan/releases/download/v0.6.2.0/cabal-plan-0.6.2.0-x86_64-linux.xz > cabal-plan.xz
111+ echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c -
112+ xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
113+ rm -f cabal-plan.xz
114+ chmod a+x $HOME/.cabal/bin/cabal-plan
115+ cabal-plan --version
116+ - name: checkout
117+ uses: actions/checkout@v2
118+ with:
119+ path: source
120+ - name: initial cabal.project for sdist
121+ run: |
122+ touch cabal.project
123+ echo "packages: $GITHUB_WORKSPACE/source/uuid-bench" >> cabal.project
124+ cat cabal.project
125+ - name: sdist
126+ run: |
127+ mkdir -p sdist
128+ $CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
129+ - name: unpack
130+ run: |
131+ mkdir -p unpacked
132+ find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
133+ - name: generate cabal.project
134+ run: |
135+ PKGDIR_uuid_bench="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/uuid-bench-[0-9.]*')"
136+ echo "PKGDIR_uuid_bench=${PKGDIR_uuid_bench}" >> $GITHUB_ENV
137+ touch cabal.project
138+ touch cabal.project.local
139+ echo "packages: ${PKGDIR_uuid_bench}" >> cabal.project
140+ if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package uuid-bench" >> cabal.project ; fi
141+ if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
142+ cat >> cabal.project <<EOF
143+ EOF
144+ $HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(uuid-bench)$/; }' >> cabal.project.local
145+ cat cabal.project
146+ cat cabal.project.local
147+ - name: dump install plan
148+ run: |
149+ $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
150+ cabal-plan
151+ - name: cache
152+ uses: actions/cache@v2
153+ with:
154+ key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
155+ path: ~/.cabal/store
156+ restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
157+ - name: install dependencies
158+ run: |
159+ $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
160+ $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
161+ - name: build w/o tests
162+ run: |
163+ $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
164+ - name: build
165+ run: |
166+ $CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
167+ - name: cabal check
168+ run: |
169+ cd ${PKGDIR_uuid_bench} || false
170+ ${CABAL} -vnormal check
171+ - name: haddock
172+ run: |
173+ $CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
174+ - name: unconstrained build
175+ run: |
176+ rm -f cabal.project.local
177+ $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
.github/workflows/haskell-ci.yml+1−1
@@ -75,7 +75,7 @@ jobs:
7575 HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
7676 echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
7777 echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
78− echo "ARG_BENCH=--disable-benchmarks" >> $GITHUB_ENV
78+ echo "ARG_BENCH=--enable-benchmarks" >> $GITHUB_ENV
7979 echo "HEADHACKAGE=false" >> $GITHUB_ENV
8080 echo "ARG_COMPILER=--ghc --with-compiler=/opt/ghc/$GHC_VERSION/bin/ghc" >> $GITHUB_ENV
8181 echo "GHCJSARITH=0" >> $GITHUB_ENV
cabal.bench.projectnew file+4
@@ -0,0 +1,4 @@
1+-- separate package for benchmarks
2+-- this way we can build criterion
3+packages: uuid-bench
4+benchmarks: True
cabal.haskell-ci−1
@@ -1,2 +1 @@
11branches: master
2−benchmarks: False
cabal.project−2
@@ -6,12 +6,10 @@ packages: uuid-types/
66
77package uuid-types
88 tests: True
9− benchmarks: False
109 -- profiling: True
1110 -- profiling-detail: toplevel-functions
1211
1312package uuid
1413 tests: True
15− benchmarks: False
1614 -- profiling: True
1715 -- profiling-detail: toplevel-functions
haskell-ci.shnew file+5
@@ -0,0 +1,5 @@
1+#!/bin/sh
2+
3+# haskell-ci doesn't know how to regenerate multiple GHA workflows
4+haskell-ci github cabal.project
5+haskell-ci github --project cabal.bench.project -o .github/workflows/haskell-ci-bench.yml --github-action-name Benchmarks
uuid-bench/LICENSEnew file+28
@@ -0,0 +1,28 @@
1+Copyright (c) 2008, Antoine Latter
2+
3+All rights reserved.
4+
5+Redistribution and use in source and binary forms, with or without
6+modification, are permitted provided that the following conditions are
7+met:
8+
9+ * Redistributions of source code must retain the above copyright
10+notice, this list of conditions and the following disclaimer.
11+ * Redistributions in binary form must reproduce the above copyright
12+notice, this list of conditions and the following disclaimer in the
13+documentation and/or other materials provided with the distribution.
14+ * The names of the authors may not be used to endorse or promote
15+products derived from this software without specific prior written
16+permission.
17+
18+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
uuid/tests/BenchUUID.hs → uuid-bench/bench/uuid-benchmark.hsrenamed

The content is the same.

uuid-types/tests/BenchUUID.hs → uuid-bench/bench/uuid-types-benchmark.hsrenamed

The content is the same.

uuid-bench/src-uuidnew file+1
@@ -0,0 +1 @@
1+../uuid/src
uuid-bench/src-uuid-typesnew file+1
@@ -0,0 +1 @@
1+../uuid-types/src
uuid-bench/uuid-bench.cabalnew file+119
@@ -0,0 +1,119 @@
1+cabal-version: 1.12
2+name: uuid-bench
3+version: 0
4+copyright:
5+ (c) 2017-2018 Herbert Valerio Riedel
6+ (c) 2008-2014 Antoine Latter
7+
8+author: Antoine Latter
9+maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>
10+license: BSD3
11+license-file: LICENSE
12+category: Data
13+build-type: Simple
14+
15+-- Benchmarking with older GHCs is not meaningful
16+tested-with:
17+ GHC ==8.0.2 || ==8.2.2 || ==8.4.4 || ==8.6.4 || ==8.8.4 || ==8.10.3
18+
19+synopsis: UUID benchmarks
20+description:
21+ UUID benchmarks.
22+ This package is combined uuid and uuid-types, renamed so we do not
23+ cause benchmark tools to be build against local package.
24+
25+homepage: https://github.com/haskell-hvr/uuid
26+bug-reports: https://github.com/haskell-hvr/uuid/issues
27+
28+source-repository head
29+ type: git
30+ location: https://github.com/haskell-hvr/uuid.git
31+ subdir: uuid-bench
32+
33+library
34+ build-depends:
35+ base >=4.9 && <5
36+ , binary >=0.4 && <0.9
37+ , bytestring >=0.9 && <0.11
38+ , cryptohash-md5 >=0.11.100 && <0.12
39+ , cryptohash-sha1 >=0.11.100 && <0.12
40+ , deepseq >=1.3 && <1.5
41+ , entropy >=0.3.7 && <0.5
42+ , hashable >=1.2.7.0 && <1.4
43+ , network-info >=0.2 && <0.3
44+ , random >=1.0.1 && <1.2
45+ , text >=1.2.3 && <1.3
46+ , time >=1.1 && <1.12
47+ , uuid-types >=1.0.2 && <2
48+
49+ -- uuid modules
50+ exposed-modules:
51+ Data.UUID
52+ Data.UUID.Util
53+ Data.UUID.V1
54+ Data.UUID.V3
55+ Data.UUID.V4
56+ Data.UUID.V5
57+
58+ other-modules:
59+ Data.UUID.Named
60+ Data.Word.Util
61+
62+ -- uuid-types modules
63+ exposed-modules: Data.UUID.Types
64+
65+ -- Exposed for companion projects; *NOT* part of the official API:
66+ exposed-modules:
67+ Data.UUID.Types.Internal
68+ Data.UUID.Types.Internal.Builder
69+
70+ default-language: Haskell2010
71+ other-extensions:
72+ DeriveDataTypeable
73+ TypeFamilies
74+
75+ ghc-options: -Wall
76+ hs-source-dirs: src-uuid-types src-uuid
77+
78+benchmark uuid-types-benchmark
79+ type: exitcode-stdio-1.0
80+ main-is: uuid-types-benchmark.hs
81+ hs-source-dirs: bench
82+ default-language: Haskell2010
83+ other-extensions: CPP
84+ ghc-options: -Wall
85+
86+ -- inherited constraints
87+ build-depends:
88+ base
89+ , bytestring
90+ , random
91+ , uuid-bench
92+
93+ -- deps w/o inherited constraints
94+ build-depends:
95+ containers >=0.5 && <0.7
96+ , criterion >=1.5 && <1.6
97+ , unordered-containers >=0.2.7 && <0.3
98+
99+benchmark uuid-benchmark
100+ type: exitcode-stdio-1.0
101+ main-is: uuid-benchmark.hs
102+ hs-source-dirs: bench
103+ default-language: Haskell2010
104+ default-extensions:
105+ CPP
106+ DeriveDataTypeable
107+
108+ ghc-options: -Wall -fno-warn-orphans
109+
110+ -- inherited constraints
111+ build-depends:
112+ base
113+ , random
114+ , uuid
115+
116+ -- deps w/o inherited constraints
117+ build-depends:
118+ criterion >=1.5 && <1.6
119+ , mersenne-random-pure64 >=0.2 && <0.3
uuid-types/cabal.projectnew file+1
@@ -0,0 +1 @@
1+packages: .
uuid-types/tests/summarize-bench-results.pldeleted−14
@@ -1,14 +0,0 @@
1−#!/usr/bin/env perl
2−
3−
4−while(<>) {
5− if (/^benchmarking (.*)$/) {
6− $name = $1;
7− }
8− if (/^mean:\s*([\d.]*) (\w*),/) {
9− $mean = 1 * $1;
10− $units = $2;
11−
12− printf "%-30s %10.2f %2s\n", $name, $mean, $units;
13− }
14−}
uuid-types/uuid-types.cabal+3−22
@@ -50,7 +50,7 @@ library
5050 , bytestring >=0.9 && <0.11
5151 , deepseq >=1.3 && <1.5
5252 , hashable >=1.2.7.0 && <1.4
53− , random >=1.0.1 && <1.2
53+ , random >=1.1 && <1.2
5454 , text >=1.2.3 && <1.3
5555
5656 exposed-modules: Data.UUID.Types
@@ -66,7 +66,7 @@ library
6666 TypeFamilies
6767
6868 ghc-options: -Wall
69− hs-source-dirs: src
69+ hs-source-dirs: src
7070
7171test-suite testuuid
7272 type: exitcode-stdio-1.0
@@ -86,26 +86,7 @@ test-suite testuuid
8686 -- deps w/o inherited constraints
8787 build-depends:
8888 ghc-byteorder >=4.11 && <4.12
89− , QuickCheck >=2.14 && <2.15
89+ , QuickCheck >=2.14.2 && <2.15
9090 , tasty >=1.4.0.1 && <1.5
9191 , tasty-hunit >=0.10 && <0.11
9292 , tasty-quickcheck >=0.10 && <0.11
93−
94−benchmark benchmark
95− type: exitcode-stdio-1.0
96− main-is: BenchUUID.hs
97− hs-source-dirs: tests
98− default-language: Haskell2010
99− other-extensions: CPP
100− ghc-options: -Wall
101− build-depends:
102− base
103− , bytestring
104− , containers >=0.4 && <0.7
105− , criterion >=1.5 && <1.6
106− , random
107− , unordered-containers >=0.2.7 && <0.3
108− , uuid-types
109−
110−-- inherited constraints
111−-- deps w/o inherited constraints
uuid/tests/summarize-bench-results.pldeleted−14
@@ -1,14 +0,0 @@
1−#!/usr/bin/env perl
2−
3−
4−while(<>) {
5− if (/^benchmarking (.*)$/) {
6− $name = $1;
7− }
8− if (/^mean:\s*([\d.]*) (\w*),/) {
9− $mean = 1 * $1;
10− $units = $2;
11−
12− printf "%-30s %10.2f %2s\n", $name, $mean, $units;
13− }
14−}
uuid/uuid.cabal+3−23
@@ -47,7 +47,7 @@ library
4747 , cryptohash-sha1 >=0.11.100 && <0.12
4848 , entropy >=0.3.7 && <0.5
4949 , network-info >=0.2 && <0.3
50− , random >=1.0.1 && <1.2
50+ , random >=1.1 && <1.2
5151 , text >=1.2.3 && <1.3
5252 , time >=1.1 && <1.12
5353 , uuid-types >=1.0.2 && <2
@@ -86,29 +86,9 @@ test-suite testuuid
8686 , random
8787 , uuid
8888
89+ -- deps w/o inherited constraints
8990 build-depends:
90− QuickCheck >=2.14 && <2.15
91+ QuickCheck >=2.14.2 && <2.15
9192 , tasty >=1.4.0.1 && <1.5
9293 , tasty-hunit >=0.10 && <0.11
9394 , tasty-quickcheck >=0.10 && <0.11
94−
95−-- deps w/o inherited constraints
96−benchmark benchmark
97− type: exitcode-stdio-1.0
98− main-is: BenchUUID.hs
99− hs-source-dirs: tests
100− default-language: Haskell2010
101− default-extensions:
102− CPP
103− DeriveDataTypeable
104−
105− ghc-options: -Wall -fno-warn-orphans
106− build-depends:
107− base
108− , criterion >=1.5 && <1.6
109− , mersenne-random-pure64 >=0.2 && <0.3
110− , random
111− , uuid
112−
113−-- inherited constraints
114−-- deps w/o inherited constraints