Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up some GHA CI #4

Merged
merged 4 commits into from
Mar 7, 2024
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
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Note: later rules override earlier rules.

# Default
* @dcoutts @jorisdral
101 changes: 101 additions & 0 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: Haskell CI

on:
push:
branches: [ "main" ]
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true


permissions:
contents: read

jobs:
# Build and test
build:
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
ghc: ["9.2.8", "9.4.8", "9.6.4", "9.8.2"]
cabal: ["3.10.2.1"]
os: [ubuntu-latest]

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Haskell
id: setup-haskell
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
cabal-update: true

- name: Install liburing (on Linux)
id: setup-liburing
run: |
sudo apt-get update
sudo apt-get -y install pkg-config
echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
mkdir tmp
cd tmp
git clone https://github.com/axboe/liburing.git
cd liburing
git checkout liburing-2.5
./configure --cc=gcc --cxx=g++
make -j$(nproc)
sudo make install
cd ../..
sudo rm -rf ./tmp
pkg-config --modversion liburing

- name: Configure the build
run: |
cabal configure --enable-test --enable-benchmark --ghc-options="-Werror" --ghc-options="-fno-ignore-asserts"
cat cabal.project.local

- name: Record cabal dependencies
id: record-deps
run: |
cabal build all --dry-run

- name: "Restore cache"
uses: actions/cache/restore@v4
id: restore-cabal-cache
env:
cache-name: cache-cabal-build
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-
${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-

- name: Install cabal dependencies
id: build-dependencies
run: cabal build --only-dependencies --enable-tests --enable-benchmarks all

- name: "Save cache"
uses: actions/cache/save@v4
id: save-cabal-cache
# Note: cache-hit will be set to true only when cache hit occurs for the
# exact key match. For a partial key match via restore-keys or a cache
# miss, it will be set to false.
if: steps.build-dependencies.outcome == 'success' && steps.restore-cabal-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.setup-haskell.outputs.cabal-store }}
key: ${{ steps.restore-cabal-cache.outputs.cache-primary-key }}

- name: Build
run: cabal build all

- name: Run tests
run: cabal test -j1 --test-show-details=direct all
4 changes: 2 additions & 2 deletions benchmark/Bench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ main = do
main_lowlevel :: FilePath -> IO ()
main_lowlevel filename = do
putStrLn "Low-level API benchmark"
fd <- openFd filename ReadOnly Nothing defaultFileFlags
fd <- openFd filename ReadOnly defaultFileFlags
status <- getFdStatus fd
let size = fileSize status
lastBlock :: Int
Expand Down Expand Up @@ -88,7 +88,7 @@ main_lowlevel filename = do
main_highlevel :: FilePath -> IO ()
main_highlevel filename = do
putStrLn "High-level API benchmark"
fd <- openFd filename ReadOnly Nothing defaultFileFlags
fd <- openFd filename ReadOnly defaultFileFlags
status <- getFdStatus fd
rng <- initStdGen
let size = fileSize status
Expand Down
112 changes: 66 additions & 46 deletions blockio-uring.cabal
Copy link
Collaborator Author

@jorisdral jorisdral Mar 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcoutts I formatted the file using cabal-fmt in the last commit. If you prefer I undo the formatting, then I can remove just the last commit. If you want to see just the changes to the cabal file sans formatting, then you can disable showing the last commit in the diff

Original file line number Diff line number Diff line change
@@ -1,51 +1,71 @@
cabal-version: >=1.10

name: blockio-uring
version: 0.1.0.0
synopsis: Perform batches of asynchronous disk IO operations.
description: Support for disk I/O operations using the Linux io_uring
API. The library supports submitting large batches of I/O
operations in one go. It also supports submitting batches
from multiple Haskell threads concurrently. The I/O only
blocks the calling thread, not all other Haskell threads.
In this style, using a combination of batching and
concurrency, it is possible to saturate modern SSDs, thus
achieving maximum I/O throughput. This is particularly
helpful for performing lots of random reads.

The library only supports recent versions of Linux, because
it uses the io_uring kernel API. It only supports disk
operations, not socket operations.

-- bug-reports:
license: MIT
license-file: LICENSE
author: Duncan Coutts
maintainer: [email protected]
copyright: (c) Well-Typed LLP 2022
category: System
build-type: Simple
extra-source-files: CHANGELOG.md
cabal-version: 3.4
name: blockio-uring
version: 0.1.0.0
synopsis: Perform batches of asynchronous disk IO operations.
description:
Support for disk I/O operations using the Linux io_uring
API. The library supports submitting large batches of I/O
operations in one go. It also supports submitting batches
from multiple Haskell threads concurrently. The I/O only
blocks the calling thread, not all other Haskell threads.
In this style, using a combination of batching and
concurrency, it is possible to saturate modern SSDs, thus
achieving maximum I/O throughput. This is particularly
helpful for performing lots of random reads.

The library only supports recent versions of Linux, because
it uses the io_uring kernel API. It only supports disk
operations, not socket operations.

license: MIT
license-file: LICENSE
author: Duncan Coutts
maintainer: [email protected]
copyright: (c) Well-Typed LLP 2022 - 2024
category: System
build-type: Simple
tested-with: GHC ==9.2 || ==9.4 || ==9.6 || ==9.8
extra-doc-files:
CHANGELOG.md
README.md

source-repository head
type: git
location: https://github.com/well-typed/blockio-uring

library
exposed-modules: System.IO.BlockIO
other-modules: System.IO.BlockIO.URing
System.IO.BlockIO.URingFFI
-- other-extensions:
build-depends: base, array, unix
pkgconfig-depends: liburing
default-language: Haskell2010
ghc-options: -Wall
exposed-modules: System.IO.BlockIO
other-modules:
System.IO.BlockIO.URing
System.IO.BlockIO.URingFFI

build-depends:
, array ^>=0.5
, base >=4.16 && <4.20
, unix ^>=2.8

pkgconfig-depends: liburing
default-language: Haskell2010
ghc-options: -Wall

benchmark bench
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmark, .
main-is: Bench.hs
build-depends: base, array, unix, random, time, containers, async
pkgconfig-depends: liburing
other-modules: System.IO.BlockIO
System.IO.BlockIO.URing
System.IO.BlockIO.URingFFI
ghc-options: -Wall -threaded
default-language: Haskell2010
type: exitcode-stdio-1.0
hs-source-dirs: benchmark .
main-is: Bench.hs
build-depends:
, array
, async
, base
, containers
, random
, time
, unix

pkgconfig-depends: liburing
other-modules:
System.IO.BlockIO
System.IO.BlockIO.URing
System.IO.BlockIO.URingFFI

ghc-options: -Wall -threaded
Loading