Skip to content

Commit

Permalink
feat: portable rpc server builds use fork/threading less (#1231)
Browse files Browse the repository at this point in the history
Now the `NotThreaded` cabal flag can be used to
omit the `-threaded` flag when building the rpc
servers, which reduces the number of `fork`
invocations when running the servers.
  • Loading branch information
Andrew Kent authored Jul 8, 2021
1 parent c1a2bfb commit ddde44c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 3 additions & 1 deletion cryptol-remote-api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ ENV LANG=C.UTF-8 \
LC_ALL=C.UTF-8
COPY cabal.GHC-${GHCVER}.config cabal.project.freeze

RUN if ${PORTABILITY}; then SERVERS_NOT_THREADED="true"; fi

RUN cabal v2-update && \
cabal v2-build -j cryptol-remote-api:exe:cryptol-remote-api cryptol-remote-api:exe:cryptol-eval-server && \
cabal v2-build -j ${SERVERS_NOT_THREADED:+-fNotThreaded} cryptol-remote-api:exe:cryptol-remote-api cryptol-remote-api:exe:cryptol-eval-server && \
mkdir -p rootfs/usr/local/bin && \
cp $(cabal v2-exec which cryptol-remote-api) rootfs/usr/local/bin && \
cp $(cabal v2-exec which cryptol-eval-server) rootfs/usr/local/bin
Expand Down
17 changes: 13 additions & 4 deletions cryptol-remote-api/cryptol-remote-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ flag static
default: False
description: Create a statically-linked binary

flag NotThreaded
default: false
manual: true
description: Omit the -threaded ghc flag

common warnings
ghc-options:
-Wall
Expand Down Expand Up @@ -79,8 +84,10 @@ executable cryptol-remote-api
import: deps, warnings, errors
main-is: Main.hs
hs-source-dirs: cryptol-remote-api
ghc-options:
-threaded -rtsopts -with-rtsopts=-xb0x200000000
if flag(NotThreaded)
ghc-options: -rtsopts -with-rtsopts=-xb0x200000000
else
ghc-options: -threaded -rtsopts -with-rtsopts=-xb0x200000000

build-depends:
cryptol-remote-api,
Expand All @@ -93,8 +100,10 @@ executable cryptol-eval-server
import: deps, warnings, errors
main-is: Main.hs
hs-source-dirs: cryptol-eval-server
ghc-options:
-threaded -rtsopts
if flag(NotThreaded)
ghc-options: -rtsopts -with-rtsopts=-xb0x200000000
else
ghc-options: -threaded -rtsopts -with-rtsopts=-xb0x200000000

build-depends:
cryptol-remote-api,
Expand Down

0 comments on commit ddde44c

Please sign in to comment.