Skip to content

Commit c312c96

Browse files
committed
Split benchmarks into separate package & project
This way we can build&run them with v2-build and on CI
1 parent fd68bcf commit c312c96

16 files changed

+365
-74
lines changed
+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
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.3
36+
allow-failure: false
37+
- ghc: 8.6.5
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+
- ghc: 7.10.3
46+
allow-failure: false
47+
- ghc: 7.8.4
48+
allow-failure: false
49+
- ghc: 7.6.3
50+
allow-failure: false
51+
- ghc: 7.4.2
52+
allow-failure: false
53+
fail-fast: false
54+
steps:
55+
- name: apt
56+
run: |
57+
apt-get update
58+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common
59+
apt-add-repository -y 'ppa:hvr/ghc'
60+
apt-get update
61+
apt-get install -y ghc-$GHC_VERSION cabal-install-3.2
62+
env:
63+
GHC_VERSION: ${{ matrix.ghc }}
64+
- name: Set PATH and environment variables
65+
run: |
66+
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
67+
echo "LANG=C.UTF-8" >> $GITHUB_ENV
68+
echo "CABAL_DIR=$HOME/.cabal" >> $GITHUB_ENV
69+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> $GITHUB_ENV
70+
HC=/opt/ghc/$GHC_VERSION/bin/ghc
71+
echo "HC=$HC" >> $GITHUB_ENV
72+
echo "HCPKG=/opt/ghc/$GHC_VERSION/bin/ghc-pkg" >> $GITHUB_ENV
73+
echo "HADDOCK=/opt/ghc/$GHC_VERSION/bin/haddock" >> $GITHUB_ENV
74+
echo "CABAL=/opt/cabal/3.2/bin/cabal -vnormal+nowrap" >> $GITHUB_ENV
75+
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
76+
echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
77+
echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
78+
echo "ARG_BENCH=--disable-benchmarks" >> $GITHUB_ENV
79+
echo "HEADHACKAGE=false" >> $GITHUB_ENV
80+
echo "ARG_COMPILER=--ghc --with-compiler=/opt/ghc/$GHC_VERSION/bin/ghc" >> $GITHUB_ENV
81+
echo "GHCJSARITH=0" >> $GITHUB_ENV
82+
env:
83+
GHC_VERSION: ${{ matrix.ghc }}
84+
- name: env
85+
run: |
86+
env
87+
- name: write cabal config
88+
run: |
89+
mkdir -p $CABAL_DIR
90+
cat >> $CABAL_CONFIG <<EOF
91+
remote-build-reporting: anonymous
92+
write-ghc-environment-files: never
93+
remote-repo-cache: $CABAL_DIR/packages
94+
logs-dir: $CABAL_DIR/logs
95+
world-file: $CABAL_DIR/world
96+
extra-prog-path: $CABAL_DIR/bin
97+
symlink-bindir: $CABAL_DIR/bin
98+
installdir: $CABAL_DIR/bin
99+
build-summary: $CABAL_DIR/logs/build.log
100+
store-dir: $CABAL_DIR/store
101+
install-dirs user
102+
prefix: $CABAL_DIR
103+
repository hackage.haskell.org
104+
url: http://hackage.haskell.org/
105+
EOF
106+
cat $CABAL_CONFIG
107+
- name: versions
108+
run: |
109+
$HC --version || true
110+
$HC --print-project-git-commit-id || true
111+
$CABAL --version || true
112+
- name: update cabal index
113+
run: |
114+
$CABAL v2-update -v
115+
- name: install cabal-plan
116+
run: |
117+
mkdir -p $HOME/.cabal/bin
118+
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
119+
echo 'de73600b1836d3f55e32d80385acc055fd97f60eaa0ab68a755302685f5d81bc cabal-plan.xz' | sha256sum -c -
120+
xz -d < cabal-plan.xz > $HOME/.cabal/bin/cabal-plan
121+
rm -f cabal-plan.xz
122+
chmod a+x $HOME/.cabal/bin/cabal-plan
123+
cabal-plan --version
124+
- name: checkout
125+
uses: actions/checkout@v2
126+
with:
127+
path: source
128+
- name: initial cabal.project for sdist
129+
run: |
130+
touch cabal.project
131+
echo "packages: $GITHUB_WORKSPACE/source/hashable-bench" >> cabal.project
132+
cat cabal.project
133+
- name: sdist
134+
run: |
135+
mkdir -p sdist
136+
$CABAL sdist all --output-dir $GITHUB_WORKSPACE/sdist
137+
- name: unpack
138+
run: |
139+
mkdir -p unpacked
140+
find sdist -maxdepth 1 -type f -name '*.tar.gz' -exec tar -C $GITHUB_WORKSPACE/unpacked -xzvf {} \;
141+
- name: generate cabal.project
142+
run: |
143+
PKGDIR_hashable_bench="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/hashable-bench-[0-9.]*')"
144+
echo "PKGDIR_hashable_bench=${PKGDIR_hashable_bench}" >> $GITHUB_ENV
145+
touch cabal.project
146+
touch cabal.project.local
147+
echo "packages: ${PKGDIR_hashable_bench}" >> cabal.project
148+
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo "package hashable-bench" >> cabal.project ; fi
149+
if [ $((HCNUMVER >= 80200)) -ne 0 ] ; then echo " ghc-options: -Werror=missing-methods" >> cabal.project ; fi
150+
cat >> cabal.project <<EOF
151+
EOF
152+
$HCPKG list --simple-output --names-only | perl -ne 'for (split /\s+/) { print "constraints: $_ installed\n" unless /^(hashable-bench)$/; }' >> cabal.project.local
153+
cat cabal.project
154+
cat cabal.project.local
155+
- name: dump install plan
156+
run: |
157+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
158+
cabal-plan
159+
- name: cache
160+
uses: actions/cache@v2
161+
with:
162+
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
163+
path: ~/.cabal/store
164+
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
165+
- name: install dependencies
166+
run: |
167+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
168+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dependencies-only -j2 all
169+
- name: build w/o tests
170+
run: |
171+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
172+
- name: build
173+
run: |
174+
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
175+
- name: cabal check
176+
run: |
177+
cd ${PKGDIR_hashable_bench} || false
178+
${CABAL} -vnormal check
179+
- name: haddock
180+
run: |
181+
$CABAL v2-haddock $ARG_COMPILER --with-haddock $HADDOCK $ARG_TESTS $ARG_BENCH all
182+
- name: unconstrained build
183+
run: |
184+
rm -f cabal.project.local
185+
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all

cabal.bench.project

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- separate package for benchmarks
2+
-- this way we can build criterion
3+
packages: hashable-bench
4+
benchmarks: True

hashable-bench/LICENSE

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Copyright Milan Straka 2010
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 met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above
12+
copyright notice, this list of conditions and the following
13+
disclaimer in the documentation and/or other materials provided
14+
with the distribution.
15+
16+
* Neither the name of Milan Straka nor the names of other
17+
contributors may be used to endorse or promote products derived
18+
from this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
File renamed without changes.
File renamed without changes.

hashable-bench/cabal.project

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- this project files is here, so you could work just in
2+
-- the haskell-bench directory
3+
packages: .

hashable-bench/cbits

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../cbits

hashable-bench/hashable-bench.cabal

+135
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
Cabal-version: 1.12
2+
Name: hashable-bench
3+
Version: 0
4+
Synopsis: hashable benchmarks
5+
Description: hashable benchmarks.
6+
Homepage: http://github.com/haskell-unordered-containers/hashable
7+
-- SPDX-License-Identifier : BSD-3-Clause
8+
License: BSD3
9+
License-file: LICENSE
10+
Author: Milan Straka <[email protected]>
11+
Johan Tibell <[email protected]>
12+
Maintainer: Oleg Grenrus <[email protected]>
13+
bug-reports: https://github.com/haskell-unordered-containers/hashable/issues
14+
Stability: Provisional
15+
Category: Data
16+
Build-type: Simple
17+
tested-with: GHC==8.10.3, GHC==8.8.3, GHC==8.6.5, GHC==8.4.4, GHC==8.2.2, GHC==8.0.2, GHC==7.10.3, GHC==7.8.4, GHC==7.6.3, GHC==7.4.2
18+
extra-source-files: benchmarks/cbits/*.h
19+
20+
Flag integer-gmp
21+
Description: Are we using @integer-gmp@ to provide fast Integer instances? No effect on GHC-9.0 or later.
22+
Default: True
23+
24+
Flag sse2
25+
Description: Do we want to assume that a target supports SSE 2?
26+
Default: True
27+
Manual: True
28+
29+
Flag sse41
30+
Description: Do we want to assume that a target supports SSE 4.1?
31+
Default: False
32+
Manual: True
33+
34+
Library
35+
Exposed-modules: Data.Hashable
36+
Data.Hashable.Lifted
37+
Data.Hashable.Generic
38+
Other-modules: Data.Hashable.Class
39+
Data.Hashable.Generic.Instances
40+
41+
-- this are only for benchmark
42+
Exposed-modules: Data.Hashable.SipHash
43+
c-sources: cbits/getRandomBytes.c
44+
other-modules: Data.Hashable.RandomSource
45+
if os(windows)
46+
extra-libraries: advapi32
47+
48+
C-sources: cbits/fnv.c
49+
hs-source-dirs: src
50+
51+
Build-depends: base >= 4.5 && < 4.16
52+
, bytestring >= 0.9 && < 0.12
53+
, deepseq >= 1.3 && < 1.5
54+
, text >= 0.12 && < 1.3
55+
, ghc-prim
56+
57+
if impl(ghc >= 9)
58+
Build-depends: ghc-bignum >= 1.0 && <1.1
59+
else
60+
if flag(integer-gmp)
61+
Build-depends: integer-gmp >= 0.4 && < 1.1
62+
else
63+
-- this is needed for the automatic flag to be well-balanced
64+
Build-depends: integer-simple
65+
66+
Default-Language: Haskell2010
67+
Other-Extensions: BangPatterns
68+
CPP
69+
DeriveDataTypeable
70+
FlexibleContexts
71+
FlexibleInstances
72+
GADTs
73+
KindSignatures
74+
MagicHash
75+
MultiParamTypeClasses
76+
ScopedTypeVariables
77+
Trustworthy
78+
TypeOperators
79+
UnliftedFFITypes
80+
81+
Ghc-options: -Wall -fwarn-tabs
82+
83+
benchmark hashable-benchmark
84+
-- We cannot depend on the hashable library directly as that creates
85+
-- a dependency cycle.
86+
hs-source-dirs: benchmarks
87+
88+
main-is: Benchmarks.hs
89+
type: exitcode-stdio-1.0
90+
91+
build-depends:
92+
hashable-bench,
93+
base,
94+
bytestring,
95+
criterion >= 1.0,
96+
ghc-prim,
97+
siphash,
98+
text
99+
100+
if impl(ghc)
101+
Build-depends: ghc-prim,
102+
text >= 0.11.0.5
103+
if impl(ghc) && flag(integer-gmp)
104+
Build-depends: integer-gmp >= 0.2
105+
106+
if impl(ghc >= 7.2.1)
107+
CPP-Options: -DGENERICS
108+
109+
include-dirs:
110+
benchmarks/cbits
111+
112+
includes:
113+
siphash.h
114+
115+
c-sources:
116+
benchmarks/cbits/inthash.c
117+
benchmarks/cbits/siphash.c
118+
benchmarks/cbits/wang.c
119+
120+
if (arch(i386) || arch(x86_64)) && flag(sse2)
121+
cpp-options: -DHAVE_SSE2
122+
c-sources:
123+
benchmarks/cbits/siphash-sse2.c
124+
125+
if flag(sse41)
126+
cpp-options: -DHAVE_SSE41
127+
c-sources:
128+
benchmarks/cbits/siphash-sse41.c
129+
130+
Ghc-options: -Wall -O2
131+
Default-Language: Haskell2010
132+
133+
source-repository head
134+
type: git
135+
location: https://github.com/haskell-unordered-containers/hashable.git

hashable-bench/src

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../src

0 commit comments

Comments
 (0)