Skip to content

Commit 3c35bc2

Browse files
authored
Merge pull request #199 from Bodigrim/bench
Make benchmarks buildable + fix segmentation fault with text-2.0
2 parents aef8d4d + 87a0283 commit 3c35bc2

File tree

21 files changed

+188
-131
lines changed

21 files changed

+188
-131
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 113 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,150 @@
11
# This GitHub workflow config has been generated by a script via
22
#
3-
# haskell-ci 'github' './attoparsec.cabal' '--no-benchmarks' '--branches' 'master'
3+
# haskell-ci 'github' 'attoparsec.cabal' '--benchmarks-jobs' '>=7.8'
44
#
55
# To regenerate the script (for example after adjusting tested-with) run
66
#
77
# haskell-ci regenerate
88
#
99
# For more information, see https://github.com/haskell-CI/haskell-ci
1010
#
11-
# version: 0.12.1
11+
# version: 0.14
1212
#
13-
# REGENDATA ("0.12.1",["github","./attoparsec.cabal","--no-benchmarks","--branches","master"])
13+
# REGENDATA ("0.14",["github","attoparsec.cabal","--benchmarks-jobs",">=7.8"])
1414
#
1515
name: Haskell-CI
1616
on:
17-
push:
18-
branches:
19-
- master
20-
pull_request:
21-
branches:
22-
- master
17+
- push
18+
- pull_request
2319
jobs:
2420
linux:
2521
name: Haskell-CI - Linux - ${{ matrix.compiler }}
2622
runs-on: ubuntu-18.04
23+
timeout-minutes:
24+
60
2725
container:
28-
image: buildpack-deps:xenial
26+
image: buildpack-deps:bionic
2927
continue-on-error: ${{ matrix.allow-failure }}
3028
strategy:
3129
matrix:
3230
include:
33-
- compiler: ghc-9.0.1
31+
- compiler: ghc-9.2.1
32+
compilerKind: ghc
33+
compilerVersion: 9.2.1
34+
setup-method: ghcup
3435
allow-failure: false
35-
- compiler: ghc-8.10.4
36+
- compiler: ghc-9.0.2
37+
compilerKind: ghc
38+
compilerVersion: 9.0.2
39+
setup-method: ghcup
40+
allow-failure: false
41+
- compiler: ghc-8.10.7
42+
compilerKind: ghc
43+
compilerVersion: 8.10.7
44+
setup-method: ghcup
3645
allow-failure: false
3746
- compiler: ghc-8.8.4
47+
compilerKind: ghc
48+
compilerVersion: 8.8.4
49+
setup-method: hvr-ppa
3850
allow-failure: false
3951
- compiler: ghc-8.6.5
52+
compilerKind: ghc
53+
compilerVersion: 8.6.5
54+
setup-method: hvr-ppa
4055
allow-failure: false
4156
- compiler: ghc-8.4.4
57+
compilerKind: ghc
58+
compilerVersion: 8.4.4
59+
setup-method: hvr-ppa
4260
allow-failure: false
4361
- compiler: ghc-8.2.2
62+
compilerKind: ghc
63+
compilerVersion: 8.2.2
64+
setup-method: hvr-ppa
4465
allow-failure: false
4566
- compiler: ghc-8.0.2
67+
compilerKind: ghc
68+
compilerVersion: 8.0.2
69+
setup-method: hvr-ppa
4670
allow-failure: false
4771
- compiler: ghc-7.10.3
72+
compilerKind: ghc
73+
compilerVersion: 7.10.3
74+
setup-method: hvr-ppa
4875
allow-failure: false
4976
- compiler: ghc-7.8.4
77+
compilerKind: ghc
78+
compilerVersion: 7.8.4
79+
setup-method: hvr-ppa
5080
allow-failure: false
5181
- compiler: ghc-7.6.3
82+
compilerKind: ghc
83+
compilerVersion: 7.6.3
84+
setup-method: hvr-ppa
5285
allow-failure: false
5386
- compiler: ghc-7.4.2
87+
compilerKind: ghc
88+
compilerVersion: 7.4.2
89+
setup-method: hvr-ppa
5490
allow-failure: false
5591
fail-fast: false
5692
steps:
5793
- name: apt
5894
run: |
5995
apt-get update
60-
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common
61-
apt-add-repository -y 'ppa:hvr/ghc'
62-
apt-get update
63-
apt-get install -y $CC cabal-install-3.4
96+
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
97+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
98+
mkdir -p "$HOME/.ghcup/bin"
99+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
100+
chmod a+x "$HOME/.ghcup/bin/ghcup"
101+
"$HOME/.ghcup/bin/ghcup" install ghc "$HCVER"
102+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
103+
else
104+
apt-add-repository -y 'ppa:hvr/ghc'
105+
apt-get update
106+
apt-get install -y "$HCNAME"
107+
mkdir -p "$HOME/.ghcup/bin"
108+
curl -sL https://downloads.haskell.org/ghcup/0.1.17.3/x86_64-linux-ghcup-0.1.17.3 > "$HOME/.ghcup/bin/ghcup"
109+
chmod a+x "$HOME/.ghcup/bin/ghcup"
110+
"$HOME/.ghcup/bin/ghcup" install cabal 3.6.2.0
111+
fi
64112
env:
65-
CC: ${{ matrix.compiler }}
113+
HCKIND: ${{ matrix.compilerKind }}
114+
HCNAME: ${{ matrix.compiler }}
115+
HCVER: ${{ matrix.compilerVersion }}
66116
- name: Set PATH and environment variables
67117
run: |
68118
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
69-
echo "LANG=C.UTF-8" >> $GITHUB_ENV
70-
echo "CABAL_DIR=$HOME/.cabal" >> $GITHUB_ENV
71-
echo "CABAL_CONFIG=$HOME/.cabal/config" >> $GITHUB_ENV
72-
HCDIR=$(echo "/opt/$CC" | sed 's/-/\//')
73-
HCNAME=ghc
74-
HC=$HCDIR/bin/$HCNAME
75-
echo "HC=$HC" >> $GITHUB_ENV
76-
echo "HCPKG=$HCDIR/bin/$HCNAME-pkg" >> $GITHUB_ENV
77-
echo "HADDOCK=$HCDIR/bin/haddock" >> $GITHUB_ENV
78-
echo "CABAL=/opt/cabal/3.4/bin/cabal -vnormal+nowrap" >> $GITHUB_ENV
119+
echo "LANG=C.UTF-8" >> "$GITHUB_ENV"
120+
echo "CABAL_DIR=$HOME/.cabal" >> "$GITHUB_ENV"
121+
echo "CABAL_CONFIG=$HOME/.cabal/config" >> "$GITHUB_ENV"
122+
HCDIR=/opt/$HCKIND/$HCVER
123+
if [ "${{ matrix.setup-method }}" = ghcup ]; then
124+
HC=$HOME/.ghcup/bin/$HCKIND-$HCVER
125+
echo "HC=$HC" >> "$GITHUB_ENV"
126+
echo "HCPKG=$HOME/.ghcup/bin/$HCKIND-pkg-$HCVER" >> "$GITHUB_ENV"
127+
echo "HADDOCK=$HOME/.ghcup/bin/haddock-$HCVER" >> "$GITHUB_ENV"
128+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
129+
else
130+
HC=$HCDIR/bin/$HCKIND
131+
echo "HC=$HC" >> "$GITHUB_ENV"
132+
echo "HCPKG=$HCDIR/bin/$HCKIND-pkg" >> "$GITHUB_ENV"
133+
echo "HADDOCK=$HCDIR/bin/haddock" >> "$GITHUB_ENV"
134+
echo "CABAL=$HOME/.ghcup/bin/cabal-3.6.2.0 -vnormal+nowrap" >> "$GITHUB_ENV"
135+
fi
136+
79137
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
80-
echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
81-
echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
82-
echo "ARG_BENCH=--disable-benchmarks" >> $GITHUB_ENV
83-
echo "HEADHACKAGE=false" >> $GITHUB_ENV
84-
echo "ARG_COMPILER=--$HCNAME --with-compiler=$HC" >> $GITHUB_ENV
85-
echo "GHCJSARITH=0" >> $GITHUB_ENV
138+
echo "HCNUMVER=$HCNUMVER" >> "$GITHUB_ENV"
139+
echo "ARG_TESTS=--enable-tests" >> "$GITHUB_ENV"
140+
if [ $((HCNUMVER >= 70800)) -ne 0 ] ; then echo "ARG_BENCH=--enable-benchmarks" >> "$GITHUB_ENV" ; else echo "ARG_BENCH=--disable-benchmarks" >> "$GITHUB_ENV" ; fi
141+
echo "HEADHACKAGE=false" >> "$GITHUB_ENV"
142+
echo "ARG_COMPILER=--$HCKIND --with-compiler=$HC" >> "$GITHUB_ENV"
143+
echo "GHCJSARITH=0" >> "$GITHUB_ENV"
86144
env:
87-
CC: ${{ matrix.compiler }}
145+
HCKIND: ${{ matrix.compilerKind }}
146+
HCNAME: ${{ matrix.compiler }}
147+
HCVER: ${{ matrix.compilerVersion }}
88148
- name: env
89149
run: |
90150
env
@@ -107,6 +167,10 @@ jobs:
107167
repository hackage.haskell.org
108168
url: http://hackage.haskell.org/
109169
EOF
170+
cat >> $CABAL_CONFIG <<EOF
171+
program-default-options
172+
ghc-options: $GHCJOBS +RTS -M3G -RTS
173+
EOF
110174
cat $CABAL_CONFIG
111175
- name: versions
112176
run: |
@@ -145,7 +209,8 @@ jobs:
145209
- name: generate cabal.project
146210
run: |
147211
PKGDIR_attoparsec="$(find "$GITHUB_WORKSPACE/unpacked" -maxdepth 1 -type d -regex '.*/attoparsec-[0-9.]*')"
148-
echo "PKGDIR_attoparsec=${PKGDIR_attoparsec}" >> $GITHUB_ENV
212+
echo "PKGDIR_attoparsec=${PKGDIR_attoparsec}" >> "$GITHUB_ENV"
213+
rm -f cabal.project cabal.project.local
149214
touch cabal.project
150215
touch cabal.project.local
151216
echo "packages: ${PKGDIR_attoparsec}" >> cabal.project
@@ -190,3 +255,16 @@ jobs:
190255
run: |
191256
rm -f cabal.project.local
192257
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
258+
- name: prepare for constraint sets
259+
run: |
260+
rm -f cabal.project.local
261+
- name: constraint set text-2
262+
run: |
263+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text >= 2' --dependencies-only -j2 all ; fi
264+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text >= 2' all ; fi
265+
if [ $((HCNUMVER >= 80400)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text >= 2' all ; fi
266+
- name: constraint set text-1
267+
run: |
268+
if [ $((HCNUMVER < 80400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text < 2' --dependencies-only -j2 all ; fi
269+
if [ $((HCNUMVER < 80400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text < 2' all ; fi
270+
if [ $((HCNUMVER < 80400)) -ne 0 ] ; then $CABAL v2-test $ARG_COMPILER --enable-tests --disable-benchmarks --constraint='text < 2' all ; fi

attoparsec.cabal

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ category: Text, Parsing
66
author: Bryan O'Sullivan <[email protected]>
77
maintainer: Bryan O'Sullivan <[email protected]>, Ben Gamari <[email protected]>
88
stability: experimental
9-
tested-with: GHC == 7.4.2, GHC ==7.6.3, GHC ==7.8.4, GHC ==7.10.3, GHC ==8.0.2, GHC ==8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.4, GHC==8.10.4, GHC == 9.0.1
9+
tested-with: GHC == 7.4.2, GHC ==7.6.3, GHC ==7.8.4, GHC ==7.10.3, GHC ==8.0.2, GHC ==8.2.2, GHC==8.4.4, GHC==8.6.5, GHC==8.8.4, GHC==8.10.7, GHC ==9.0.2, GHC ==9.2.1
1010
synopsis: Fast combinator parsing for bytestrings and text
1111
cabal-version: 2.0
1212
homepage: https://github.com/bgamari/attoparsec
@@ -18,8 +18,6 @@ description:
1818
file formats.
1919
extra-source-files:
2020
README.markdown
21-
benchmarks/*.cabal
22-
benchmarks/*.hs
2321
benchmarks/*.txt
2422
benchmarks/json-data/*.json
2523
benchmarks/Makefile
@@ -28,15 +26,31 @@ extra-source-files:
2826
examples/*.c
2927
examples/*.hs
3028
examples/Makefile
31-
tests/*.hs
32-
tests/QC/*.hs
33-
tests/QC/IPv6/*.hs
3429

3530
Flag developer
3631
Description: Whether to build the library in development mode
3732
Default: False
3833
Manual: True
3934

35+
-- We need to test and benchmark these modules,
36+
-- but do not want to expose them to end users
37+
library attoparsec-internal
38+
hs-source-dirs: internal
39+
build-depends: array,
40+
base >= 4.3 && < 5,
41+
bytestring <0.12,
42+
text >= 1.1.1.3
43+
if !impl(ghc >= 8.0)
44+
build-depends: semigroups >=0.16.1 && <0.21
45+
exposed-modules: Data.Attoparsec.ByteString.Buffer
46+
Data.Attoparsec.ByteString.FastSet
47+
Data.Attoparsec.Internal.Compat
48+
Data.Attoparsec.Internal.Fhthagn
49+
Data.Attoparsec.Text.Buffer
50+
Data.Attoparsec.Text.FastSet
51+
ghc-options: -O2 -Wall
52+
default-language: Haskell2010
53+
4054
library
4155
build-depends: array,
4256
base >= 4.3 && < 5,
@@ -46,7 +60,8 @@ library
4660
scientific >= 0.3.1 && < 0.4,
4761
transformers >= 0.2 && (< 0.4 || >= 0.4.1.0) && < 0.7,
4862
text >= 1.1.1.3,
49-
ghc-prim <0.9
63+
ghc-prim <0.9,
64+
attoparsec-internal
5065
if impl(ghc < 7.4)
5166
build-depends:
5267
bytestring < 0.10.4.0
@@ -70,13 +85,7 @@ library
7085
Data.Attoparsec.Text.Lazy
7186
Data.Attoparsec.Types
7287
Data.Attoparsec.Zepto
73-
other-modules: Data.Attoparsec.ByteString.Buffer
74-
Data.Attoparsec.ByteString.FastSet
75-
Data.Attoparsec.ByteString.Internal
76-
Data.Attoparsec.Internal.Compat
77-
Data.Attoparsec.Internal.Fhthagn
78-
Data.Attoparsec.Text.Buffer
79-
Data.Attoparsec.Text.FastSet
88+
other-modules: Data.Attoparsec.ByteString.Internal
8089
Data.Attoparsec.Text.Internal
8190
ghc-options: -O2 -Wall
8291

@@ -86,9 +95,9 @@ library
8695
ghc-prof-options: -auto-all
8796
ghc-options: -Werror
8897

89-
test-suite tests
98+
test-suite attoparsec-tests
9099
type: exitcode-stdio-1.0
91-
hs-source-dirs: tests .
100+
hs-source-dirs: tests
92101
main-is: QC.hs
93102
other-modules: QC.Buffer
94103
QC.ByteString
@@ -102,25 +111,6 @@ test-suite tests
102111
QC.Text.FastSet
103112
QC.Text.Regressions
104113

105-
other-modules: Data.Attoparsec.ByteString
106-
Data.Attoparsec.ByteString.Buffer
107-
Data.Attoparsec.ByteString.Char8
108-
Data.Attoparsec.ByteString.FastSet
109-
Data.Attoparsec.ByteString.Internal
110-
Data.Attoparsec.ByteString.Lazy
111-
Data.Attoparsec.Combinator
112-
Data.Attoparsec.Internal
113-
Data.Attoparsec.Internal.Compat
114-
Data.Attoparsec.Internal.Fhthagn
115-
Data.Attoparsec.Internal.Types
116-
Data.Attoparsec.Number
117-
Data.Attoparsec.Text
118-
Data.Attoparsec.Text.Buffer
119-
Data.Attoparsec.Text.FastSet
120-
Data.Attoparsec.Text.Internal
121-
Data.Attoparsec.Text.Lazy
122-
Data.Attoparsec.Zepto
123-
124114
ghc-options:
125115
-Wall -threaded -rtsopts
126116

@@ -129,6 +119,8 @@ test-suite tests
129119

130120
build-depends:
131121
array,
122+
attoparsec,
123+
attoparsec-internal,
132124
base,
133125
bytestring,
134126
deepseq >= 1.1,
@@ -148,13 +140,15 @@ test-suite tests
148140
build-depends: fail == 4.9.*,
149141
semigroups >=0.16.1 && <0.19
150142

151-
benchmark benchmarks
143+
benchmark attoparsec-benchmarks
152144
type: exitcode-stdio-1.0
153-
hs-source-dirs: benchmarks benchmarks/warp-3.0.1.1 .
145+
hs-source-dirs: benchmarks benchmarks/warp-3.0.1.1
154146
ghc-options: -O2 -Wall -rtsopts
155147
main-is: Benchmarks.hs
156148
other-modules:
149+
Aeson
157150
Common
151+
Genome
158152
HeadersByteString
159153
HeadersByteString.Atto
160154
HeadersText
@@ -172,18 +166,20 @@ benchmark benchmarks
172166

173167
build-depends:
174168
array,
169+
attoparsec,
170+
attoparsec-internal,
175171
base == 4.*,
176172
bytestring >= 0.10.4.0,
177173
case-insensitive,
178174
containers,
179-
criterion >= 1.0,
180175
deepseq >= 1.1,
181176
directory,
182177
filepath,
183178
ghc-prim,
184179
http-types,
185180
parsec >= 3.1.2,
186181
scientific,
182+
tasty-bench >= 0.3,
187183
text >= 1.1.1.0,
188184
transformers,
189185
unordered-containers,
@@ -199,4 +195,3 @@ benchmark benchmarks
199195
source-repository head
200196
type: git
201197
location: https://github.com/bgamari/attoparsec
202-

0 commit comments

Comments
 (0)