Skip to content

Commit

Permalink
add gRPC-haskell benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
4eUeP committed Jul 29, 2023
1 parent 282fd74 commit be65da5
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,42 @@ jobs:
GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }}


haskell_grpc_haskell_bench:
runs-on: ubuntu-latest
needs:
- set-image-name
- changed
if: fromJSON(needs.changed.outputs.base) || contains(needs.changed.outputs.files, 'haskell_grpc_haskell_bench/')
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Build haskell_grpc_haskell_bench
run: ./build.sh haskell_grpc_haskell_bench
env:
GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }}

- name: Benchmark haskell_grpc_haskell_bench
run: ./bench.sh haskell_grpc_haskell_bench
env:
GRPC_BENCHMARK_DURATION: 30s
GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }}

- if: github.ref == 'refs/heads/master'
name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- if: github.ref == 'refs/heads/master'
name: If on master push image to GHCR
run: docker push $GRPC_IMAGE_NAME:haskell_grpc_haskell_bench-complex_proto
env:
GRPC_IMAGE_NAME: ${{ needs.set-image-name.outputs.name }}


java_aot_bench:
runs-on: ubuntu-latest
needs:
Expand Down
2 changes: 2 additions & 0 deletions haskell_grpc_haskell_bench/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist-newstyle
src-gen/
29 changes: 29 additions & 0 deletions haskell_grpc_haskell_bench/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM docker.io/library/haskell:8.10.7

RUN apt-get update && apt-get install -y \
build-essential autoconf libtool libssl-dev pkg-config cmake git

ARG PARALLEL
RUN BUILD_DIR=$(mktemp -d) && \
cd $BUILD_DIR && \
git clone --depth 1 --branch v1.42.0 --recurse-submodules https://github.com/grpc/grpc && \
cd grpc && \
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DgRPC_BUILD_TESTS=OFF \
-DBUILD_SHARED_LIBS=ON \
-DgRPC_INSTALL=ON \
-DCMAKE_BUILD_TYPE=Release \
-DgRPC_SSL_PROVIDER=package \
. && \
make -j ${PARALLEL:-$(nproc)} && \
make install -j${PARALLEL:-$(nproc)} && \
rm -rf $BUILD_DIR

COPY haskell_grpc_haskell_bench /app/bench
COPY proto /app/proto

RUN cd /app/bench && cabal update && make && cabal install

RUN rm -rf /app

ENTRYPOINT /root/.cabal/bin/haskell-grpc-haskell-bench +RTS -N${GRPC_SERVER_CPUS:-1}
11 changes: 11 additions & 0 deletions haskell_grpc_haskell_bench/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CABAL ?= cabal
PROTO_COMPILE_HS = ~/.cabal/bin/compile-proto-file

grpc-haskell:
($(CABAL) build proto3-suite && mkdir -p ~/.cabal/bin && \
$(CABAL) exec which compile-proto-file | tail -1 | xargs -I{} cp {} $(PROTO_COMPILE_HS))
($(PROTO_COMPILE_HS) \
--includeDir /usr/local/include \
--includeDir ../proto/helloworld \
--proto helloworld.proto \
--out ./src-gen/)
24 changes: 24 additions & 0 deletions haskell_grpc_haskell_bench/app/Main.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}

module Main where

import Network.GRPC.HighLevel
import Network.GRPC.HighLevel.Generated

import Helloworld

main :: IO ()
main =
greeterServer
(Greeter{ greeterSayHello = sayHello })
defaultServiceOptions{serverHost = "0.0.0.0", serverPort = 50051}

sayHello
:: ServerRequest 'Normal HelloRequest HelloReply
-> IO (ServerResponse 'Normal HelloReply)
sayHello (ServerNormalRequest _metadata HelloRequest{..}) = do
return $ ServerNormalResponse (HelloReply helloRequestRequest) [] StatusOk ""
17 changes: 17 additions & 0 deletions haskell_grpc_haskell_bench/cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
packages:
.

source-repository-package
type: git
location: https://github.com/awakesecurity/gRPC-haskell.git
tag: d20c20d63c170b5eaf5725f03f7b7060352af402

source-repository-package
type: git
location: https://github.com/awakesecurity/gRPC-haskell.git
tag: d20c20d63c170b5eaf5725f03f7b7060352af402
subdir: core

package grpc-haskell-core
extra-include-dirs: /usr/local/include
extra-lib-dirs: /usr/local/lib
25 changes: 25 additions & 0 deletions haskell_grpc_haskell_bench/grpc-haskell-bench.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cabal-version: 2.4
name: grpc-haskell-bench
version: 0.1.0.0

executable haskell-grpc-haskell-bench
main-is: Main.hs
hs-source-dirs: app src-gen
other-modules: Helloworld
build-depends:
, base >=4.14 && <5
, bytestring
, containers
, deepseq
, grpc-haskell
, grpc-haskell-core
, proto3-suite ^>=0.6
, proto3-wire ^>=1.4
, text
, vector

default-language: Haskell2010
ghc-options:
-O2 -Wall -Wcompat -Widentities -Wincomplete-record-updates
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints
-threaded -rtsopts

0 comments on commit be65da5

Please sign in to comment.